Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [PATCH] format-patch: fix skipping of blank-lines (take 2)
Date: Fri, 08 Jul 2005 19:27:15 -0700	[thread overview]
Message-ID: <7vhdf43e9o.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.58.0507081838560.17536@g5.osdl.org> (Linus Torvalds's message of "Fri, 8 Jul 2005 18:42:26 -0700 (PDT)")

If it is fed a commit with more than one leading blank lines,
the sed scripts git-format-patch-script used looped forever.
Using git-stripspace upfront makes the sed script somewhat
simpler to work around this problem.

Also use git-rev-parse so that we can say

    $ git-format-patch-script HEAD^^^^

to prepare the latest four patches for e-mail submission.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 >>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

 LT> How about using "git-stripspace"?

 I first thought it would be an overkill, but it lets me cheat in
 the sed script.  Thanks for the suggestion.

 git-format-patch-script |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

3006f6c35d08a0f060e021573771b3cfc70c0682
diff --git a/git-format-patch-script b/git-format-patch-script
--- a/git-format-patch-script
+++ b/git-format-patch-script
@@ -53,6 +53,8 @@ case "$#" in
 1)    linus="$1" junio=HEAD ;;
 *)    usage ;;
 esac
+junio=`git-rev-parse --verify "$junio"`
+linus=`git-rev-parse --verify "$linus"`
 
 case "$outdir" in
 */) ;;
@@ -66,9 +68,9 @@ trap 'rm -f $tmp-*' 0 1 2 3 15
 series=$tmp-series
 
 titleScript='
-	1,/^$/d
-	: loop
-	/^$/b loop
+	/./d
+	/^$/n
+	s/^\[PATCH[^]]*\] *//
 	s/[^-a-z.A-Z_0-9]/-/g
         s/\.\.\.*/\./g
 	s/\.*$//
@@ -76,6 +78,7 @@ titleScript='
 	s/^-//
 	s/-$//
 	s/$/./
+	p
 	q
 '
 
@@ -88,7 +91,9 @@ total=`wc -l <$series`
 i=$total
 while read commit
 do
-    title=`git-cat-file commit "$commit" | sed -e "$titleScript"`
+    title=`git-cat-file commit "$commit" |
+    git-stripspace |
+    sed -ne "$titleScript"`
     case "$numbered" in
     '') num= ;;
     *)
@@ -102,16 +107,17 @@ do
     echo "$file"
     {
 	mailScript='
-	1,/^$/d
-	: loop
-	/^$/b loop
+	/./d
+	/^$/n
 	s|^|[PATCH'"$num"'] |
 	: body
 	p
 	n
 	b body'
 
-	git-cat-file commit "$commit" | sed -ne "$mailScript"
+	git-cat-file commit "$commit" |
+	git-stripspace |
+	sed -ne "$mailScript"
 	echo '---'
 	echo
 	git-diff-tree -p $diff_opts "$commit" | git-apply --stat --summary

      reply	other threads:[~2005-07-09  2:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-09  0:46 [PATCH] format-patch: fix skipping of blank-lines Junio C Hamano
2005-07-09  1:42 ` Linus Torvalds
2005-07-09  2:27   ` Junio C Hamano [this message]

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=7vhdf43e9o.fsf_-_@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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