{"thread":{"id":"1180","subject":"[PATCH] format-patch: fix skipping of blank-lines","startedAt":"2005-07-09T00:46:27Z","lastAt":"2005-07-09T02:27:15Z","messageCount":3,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"5843","messageId":"7vu0j44xi4.fsf@assigned-by-dhcp.cox.net","threadId":"1180","inReplyTo":null,"subject":"[PATCH] format-patch: fix skipping of blank-lines","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-09T00:46:27Z","receivedAt":"2005-07-09T00:46:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"If it is fed a commit with more than one leading blank lines,\nthe sed scripts git-format-patch-script used looped forever.\nThis patch fixes it.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n git-format-patch-script |   18 +++++++++++++-----\n 1 files changed, 13 insertions(+), 5 deletions(-)\n\n58a3c79b488a28897cd5556dab0dd599b4ed9f0c\ndiff --git a/git-format-patch-script b/git-format-patch-script\n--- a/git-format-patch-script\n+++ b/git-format-patch-script\n@@ -66,9 +66,13 @@ trap 'rm -f $tmp-*' 0 1 2 3 15\n series=$tmp-series\n \n titleScript='\n-\t1,/^$/d\n+\t/./d\n \t: loop\n-\t/^$/b loop\n+\t/^$/{\n+\t\tn\n+\t\tb loop\n+\t}\n+\ts/^\\[PATCH[^]]*\\] *//\n \ts/[^-a-z.A-Z_0-9]/-/g\n         s/\\.\\.\\.*/\\./g\n \ts/\\.*$//\n@@ -76,6 +80,7 @@ titleScript='\n \ts/^-//\n \ts/-$//\n \ts/$/./\n+\tp\n \tq\n '\n \n@@ -88,7 +93,7 @@ total=`wc -l <$series`\n i=$total\n while read commit\n do\n-    title=`git-cat-file commit \"$commit\" | sed -e \"$titleScript\"`\n+    title=`git-cat-file commit \"$commit\" | sed -ne \"$titleScript\"`\n     case \"$numbered\" in\n     '') num= ;;\n     *)\n@@ -102,9 +107,12 @@ do\n     echo \"$file\"\n     {\n \tmailScript='\n-\t1,/^$/d\n+\t/./d\n \t: loop\n-\t/^$/b loop\n+\t/^$/{\n+\t\tn\n+\t\tb loop\n+\t}\n \ts|^|[PATCH'\"$num\"'] |\n \t: body\n \tp\n"},{"id":"5847","messageId":"Pine.LNX.4.58.0507081838560.17536@g5.osdl.org","threadId":"1180","inReplyTo":"7vu0j44xi4.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] format-patch: fix skipping of blank-lines","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-09T01:42:26Z","receivedAt":"2005-07-09T01:42:26Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 8 Jul 2005, Junio C Hamano wrote:\n>\n> If it is fed a commit with more than one leading blank lines,\n> the sed scripts git-format-patch-script used looped forever.\n> This patch fixes it.\n\nHow about using \"git-stripspace\"? That's what it's there for. It strips\nwhitespace from the end of lines, from the beginning, and from the end. It\nalso removes multiple consecutive whitespace lines from within the body of\nthe message - which might turn some people off, but I use that same thing\nwhen I do my automated email commits, so if you don't strip those lines\nfrom the email, they _will_ get stripped at commit time, so..\n\n\"git-stripspace\" also doesn't get confused by non-empty lines that have \nspaces in them, like your script seems to be (ie /^$/ won't match a line \nthat has a space on it).\n\n\t\tLinus\n"},{"id":"5850","messageId":"7vhdf43e9o.fsf_-_@assigned-by-dhcp.cox.net","threadId":"1180","inReplyTo":"Pine.LNX.4.58.0507081838560.17536@g5.osdl.org","subject":"[PATCH] format-patch: fix skipping of blank-lines (take 2)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-09T02:27:15Z","receivedAt":"2005-07-09T02:27:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"If it is fed a commit with more than one leading blank lines,\nthe sed scripts git-format-patch-script used looped forever.\nUsing git-stripspace upfront makes the sed script somewhat\nsimpler to work around this problem.\n\nAlso use git-rev-parse so that we can say\n\n    $ git-format-patch-script HEAD^^^^\n\nto prepare the latest four patches for e-mail submission.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n >>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\n LT> How about using \"git-stripspace\"?\n\n I first thought it would be an overkill, but it lets me cheat in\n the sed script.  Thanks for the suggestion.\n\n git-format-patch-script |   22 ++++++++++++++--------\n 1 files changed, 14 insertions(+), 8 deletions(-)\n\n3006f6c35d08a0f060e021573771b3cfc70c0682\ndiff --git a/git-format-patch-script b/git-format-patch-script\n--- a/git-format-patch-script\n+++ b/git-format-patch-script\n@@ -53,6 +53,8 @@ case \"$#\" in\n 1)    linus=\"$1\" junio=HEAD ;;\n *)    usage ;;\n esac\n+junio=`git-rev-parse --verify \"$junio\"`\n+linus=`git-rev-parse --verify \"$linus\"`\n \n case \"$outdir\" in\n */) ;;\n@@ -66,9 +68,9 @@ trap 'rm -f $tmp-*' 0 1 2 3 15\n series=$tmp-series\n \n titleScript='\n-\t1,/^$/d\n-\t: loop\n-\t/^$/b loop\n+\t/./d\n+\t/^$/n\n+\ts/^\\[PATCH[^]]*\\] *//\n \ts/[^-a-z.A-Z_0-9]/-/g\n         s/\\.\\.\\.*/\\./g\n \ts/\\.*$//\n@@ -76,6 +78,7 @@ titleScript='\n \ts/^-//\n \ts/-$//\n \ts/$/./\n+\tp\n \tq\n '\n \n@@ -88,7 +91,9 @@ total=`wc -l <$series`\n i=$total\n while read commit\n do\n-    title=`git-cat-file commit \"$commit\" | sed -e \"$titleScript\"`\n+    title=`git-cat-file commit \"$commit\" |\n+    git-stripspace |\n+    sed -ne \"$titleScript\"`\n     case \"$numbered\" in\n     '') num= ;;\n     *)\n@@ -102,16 +107,17 @@ do\n     echo \"$file\"\n     {\n \tmailScript='\n-\t1,/^$/d\n-\t: loop\n-\t/^$/b loop\n+\t/./d\n+\t/^$/n\n \ts|^|[PATCH'\"$num\"'] |\n \t: body\n \tp\n \tn\n \tb body'\n \n-\tgit-cat-file commit \"$commit\" | sed -ne \"$mailScript\"\n+\tgit-cat-file commit \"$commit\" |\n+\tgit-stripspace |\n+\tsed -ne \"$mailScript\"\n \techo '---'\n \techo\n \tgit-diff-tree -p $diff_opts \"$commit\" | git-apply --stat --summary\n"}]}