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

[PATCH v2] contrib/subtree: ignore log.date configuration

From
David Aguilar <davvid@gmail.com>
Date
Jul 22, 2015, 00:01 UTC
Message-ID
<1437523262-29130-1-git-send-email-davvid@gmail.com>

git-subtree's log format string uses "%ad" and "%cd", which respect the user's configured log.date value.

This is problematic for git-subtree because it needs to use real dates so that copied commits come through unchanged.

Add a test and tweak the format strings to use %aD and %cD so that the default date format is used instead.

Reported-by: Bryan Jacobs <b@q3q.us>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Please ignore the previous patch -- it had a stray comment in the
test code that is not present in this version.
 contrib/subtree/git-subtree.sh     | 2 +-
 contrib/subtree/t/t7900-subtree.sh | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 07bd77c..9f06571 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -305,7 +305,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%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
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index bd3df97..9051982 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -94,6 +94,10 @@ test_expect_success 'add sub3' '
 # Back to mainline
 cd ..
 
+test_expect_success 'enable log.date=relative to catch errors' '
+	git config log.date relative
+'
+
 test_expect_success 'add main4' '
 	create main4 &&
 	git commit -m "main4" &&
-- 
2.5.0.rc3
Message 1 of 1 in “contrib/subtree: ignore log.date configuration”
  1. contrib/subtree: ignore log.date configurationDavid Aguilar, Jul 22, 2015

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.