From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: David Barr <davidbarr@google.com>,
Git Mailing List <git@vger.kernel.org>,
Tay Ray Chuan <rctay89@gmail.com>,
Sverre Rabbelier <srabbelier@gmail.com>,
Giuseppe Bilotta <giuseppe.bilotta@gmail.com>,
Simon Sasburg <simon.sasburg@gmail.com>
Subject: [PATCH v2] am: ignore leading whitespace before patch
Date: Mon, 8 Aug 2011 04:49:04 +0200 [thread overview]
Message-ID: <20110808024904.GF19551@elie.gateway.2wire.net> (raw)
In-Reply-To: <7vvcub16e7.fsf@alter.siamese.dyndns.org>
From: David Barr <davidbarr@google.com>
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 <davidbarr@google.com>
Acked-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Junio C Hamano wrote:
> It no longer checks "the first few lines" but can read a lot more, so the
> comment that precedes this block is now invalid.
>
> Also we are rather old fashioned and we never say "until [ ... ]" anywhere
> in our shell scripts.
Good ideas, thanks. While at it, let's initialize l1 to protect
against any stray value it might have inherited from the environment.
Looking forward to the promised test, :)
Jonathan
git-am.sh | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index 463c741d..c8422dbe 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
--
1.7.6
next prev parent reply other threads:[~2011-08-08 2:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-02 22:20 [PATCH] git-am: ignore leading whitespace before patch David Barr
2011-08-03 12:28 ` Tay Ray Chuan
2011-08-03 13:21 ` Sverre Rabbelier
2011-08-03 13:31 ` Tay Ray Chuan
2011-08-03 13:33 ` Sverre Rabbelier
2011-08-06 1:56 ` David Barr
2011-08-06 5:00 ` Junio C Hamano
2011-08-08 2:49 ` Jonathan Nieder [this message]
2011-08-08 5:10 ` [PATCH v2] am: " David Barr
2011-08-08 5:31 ` David Barr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110808024904.GF19551@elie.gateway.2wire.net \
--to=jrnieder@gmail.com \
--cc=davidbarr@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=giuseppe.bilotta@gmail.com \
--cc=rctay89@gmail.com \
--cc=simon.sasburg@gmail.com \
--cc=srabbelier@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).