Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH 2/7] contrib/subtree: Use %B for Split Subject/Body

From: <hidden>
Date: 2016-06-15 22:55:47

Junio C Hamano [off-list ref] writes:
"David A. Greene" [off-list ref] writes:
quoted
From: Techlive Zheng <redacted>

Use %B to format the commit message and body to avoid an extra newline
if a commit only has a subject line.

Signed-off-by: Techlive Zheng <redacted>

Signed-off-by: David A. Greene <redacted>
---
This time (only), I'll try to fix them up at my end, but please
check your toolchain, find out where the extra blank line between
S-o-b: lines we see above come from, and fix that, so that I won't
have to do so again.
Will do.
quoted
 contrib/subtree/git-subtree.sh     |    6 +++++-
 contrib/subtree/t/t7900-subtree.sh |   15 +++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 920c664..5341b36 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -296,7 +296,11 @@ copy_commit()
 	# We're going to set some environment vars here, so
 	# do it in a subshell to get rid of them safely later
 	debug copy_commit "{$1}" "{$2}" "{$3}"
-	git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
+	# Use %B rather than %s%n%n%b to handle the special case of a
+	# commit that only has a subject line.  We don't want to
+	# introduce a newline after the subject, causing generation of
+	# a new hash.
+	git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
The new format template is fine, but I do not think the comment
should be there.  It does not give any useful information to people
who are reading the end result of applying this patch and is useful
only in the context of comparing the old and new templates, iow, it
belongs to the commit log message.
I'll delete the comment.

                           -David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help