From 0e8341f29d6541f661cc52f27f96877c0fd469c2 Mon Sep 17 00:00:00 2001 From: David Barr Date: Mon, 8 Aug 2011 04:49:04 +0200 Subject: am: ignore leading whitespace before patch Some web-based email clients prepend whitespace to raw message transcripts to workaround content-sniffing in some browsers. Adjust the patch format detection logic to ignore leading whitespace. So now you can apply patches from GMail with "git am" in three steps: 1. choose "show original" 2. tell the browser to "save as" (for example by pressing Ctrl+S) 3. run "git am" on the saved file This fixes a regression introduced by v1.6.4-rc0~15^2~2 (git-am foreign patch support: autodetect some patch formats, 2009-05-27). GMail support was first introduced to "git am" by v1.5.4-rc0~274^2 (Make mailsplit and mailinfo strip whitespace from the start of the input, 2007-11-01). Signed-off-by: David Barr Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- git-am.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'git-am.sh') diff --git a/git-am.sh b/git-am.sh index 463c741dfc..c8422dbe6e 100755 --- a/git-am.sh +++ b/git-am.sh @@ -196,10 +196,15 @@ check_patch_format () { return 0 fi - # otherwise, check the first few lines of the first patch to try - # to detect its format + # otherwise, check the first few non-blank lines of the first + # patch to try to detect its format { - read l1 + # Start from first line containing non-whitespace + l1= + while test -z "$l1" + do + read l1 + done read l2 read l3 case "$l1" in -- cgit v1.2.1