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

[PATCH] subtree.sh: Use raw subject and body modifier "%B" instead of "%s%n%n%b"

From
Techlive Zheng <techlivezheng@gmail.com>
Date
Aug 10, 2012, 01:15 UTC
Message-ID
<1344561358-2953-2-git-send-email-techlivezheng@gmail.com>
In-Reply-To
<1344561358-2953-1-git-send-email-techlivezheng@gmail.com>

"%s%n%n%b" is not always equal to "%B". If the commit msg does not have a body, this will append an extra new-line character to the msg title which would cause the splited commit has a new sha1 hash. In most cases, this does not matter, but for a project which did not merged using this script initially, the 'split' command would not genereate the same commits as the orginal which may cause conflicts.

Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
---
 contrib/subtree/git-subtree.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 920c664..5598210 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -296,7 +296,7 @@ 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" |
+	git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
 	(
 		read GIT_AUTHOR_NAME
 		read GIT_AUTHOR_EMAIL
-- 
1.7.11.4
Previous: Techlive ZhengNext: greened@obbligato.org
Message 2 of 6 in “[git-subtree.sh] Use raw subject and body modifier "%B" instead of "%s%n%n%b" for commit”
  1. [git-subtree.sh] Use raw subject and body modifier "%B" instead of "%s%n%n%b" for commitTechlive Zheng, Aug 10, 2012
  2. subtree.sh: Use raw subject and body modifier "%B" instead of "%s%n%n%b"Techlive Zheng, Aug 10, 2012
  3. greened@obbligato.orgAug 21, 2012
  4. greened@obbligato.orgDec 31, 2012
  5. greened@obbligato.orgJan 1, 2013
  6. greened@obbligato.orgAug 21, 2012

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.