git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <junkio@cox.net>
Date
Jul 9, 2005, 00:46 UTC
Message-ID
<7vu0j44xi4.fsf@assigned-by-dhcp.cox.net>

If it is fed a commit with more than one leading blank lines, the sed scripts git-format-patch-script used looped forever. This patch fixes it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git-format-patch-script |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
58a3c79b488a28897cd5556dab0dd599b4ed9f0c
diff --git a/git-format-patch-script b/git-format-patch-script
--- a/git-format-patch-script
+++ b/git-format-patch-script
@@ -66,9 +66,13 @@ trap 'rm -f $tmp-*' 0 1 2 3 15
 series=$tmp-series
 
 titleScript='
-	1,/^$/d
+	/./d
 	: loop
-	/^$/b loop
+	/^$/{
+		n
+		b loop
+	}
+	s/^\[PATCH[^]]*\] *//
 	s/[^-a-z.A-Z_0-9]/-/g
         s/\.\.\.*/\./g
 	s/\.*$//
@@ -76,6 +80,7 @@ titleScript='
 	s/^-//
 	s/-$//
 	s/$/./
+	p
 	q
 '
 
@@ -88,7 +93,7 @@ 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" | sed -ne "$titleScript"`
     case "$numbered" in
     '') num= ;;
     *)
@@ -102,9 +107,12 @@ do
     echo "$file"
     {
 	mailScript='
-	1,/^$/d
+	/./d
 	: loop
-	/^$/b loop
+	/^$/{
+		n
+		b loop
+	}
 	s|^|[PATCH'"$num"'] |
 	: body
 	p
Next: Linus Torvalds
Message 1 of 3 in “format-patch: fix skipping of blank-lines”
  1. format-patch: fix skipping of blank-linesJunio C Hamano, Jul 9, 2005
  2. Linus TorvaldsJul 9, 2005
  3. format-patch: fix skipping of blank-lines (take 2)Junio C Hamano, Jul 9, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.