Skip to contentSkip to conversation

contrib/subtree: ignore log.date configuration

PATCH New David Aguilar 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 contrib/subtree: ignore log.date configuration

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.

---
 contrib/subtree/git-subtree.sh     | 2 +-
 contrib/subtree/t/t7900-subtree.sh | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)
contrib/subtree/git-subtree.sh +1 -1
index 07bd77c..9f06571 100755
@@ -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
contrib/subtree/t/t7900-subtree.sh +5 -0
index bd3df97..cd2dfe7 100755
@@ -94,6 +94,11 @@ test_expect_success 'add sub3' '
 # Back to mainline
 cd ..
 
+# Enable log.date=relative to catch errors
+test_expect_success 'enable log.date=relative to catch error' '
+	git config log.date relative
+'
+
 test_expect_success 'add main4' '
 	create main4 &&
 	git commit -m "main4" &&
Signature · 1 line
2.5.0.rc3