Commits

Junio C Hamano  committed 1855c04

[PATCH] format-patch: fix skipping of blank-lines

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>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

  • Participants
  • Parent commits ed61604

Comments (0)

Files changed (1)

File git-format-patch-script

 1)    linus="$1" junio=HEAD ;;
 *)    usage ;;
 esac
+junio=`git-rev-parse --verify "$junio"`
+linus=`git-rev-parse --verify "$linus"`
 
 case "$outdir" in
 */) ;;
 series=$tmp-series
 
 titleScript='
-	1,/^$/d
-	: loop
-	/^$/b loop
+	/./d
+	/^$/n
+	s/^\[PATCH[^]]*\] *//
 	s/[^-a-z.A-Z_0-9]/-/g
         s/\.\.\.*/\./g
 	s/\.*$//
 	s/^-//
 	s/-$//
 	s/$/./
+	p
 	q
 '
 
 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= ;;
     *)
     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