am: Add --committer-date-is-author-date option
This new option tells 'git-am' to use the timestamp recorded in the Email message as both author and committer date. Signed-off-by: しらいしななこ <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jan 22, 2009 at 16:14 UTC
3f01ad665493e09aa816d84a872d9874f33a8c16
2 files changed
+32
-1
git-am.sh
+12
-1
@@ -24,6 +24,7 @@ resolvemsg= override error message when patch failure occurs
24
r,resolved to be used after a patch failure
25
skip skip the current patch
26
abort restore the original branch and abort the patching operation.
27
+committer-date-is-author-date lie about committer date
28
rebasing (internal use for git-rebase)"
29
30
. git-sh-setup
@@ -134,6 +135,7 @@ dotest="$GIT_DIR/rebase-apply"
135
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
136
resolvemsg= resume=
137
git_apply_opt=
138
+committer_date_is_author_date=
139
140
while test $# != 0
141
do
@@ -171,6 +173,8 @@ do
173
git_apply_opt="$git_apply_opt $(sq "$1$2")"; shift ;;
174
--reject)
175
git_apply_opt="$git_apply_opt $1" ;;
176
+ --committer-date-is-author-date)
177
+ committer_date_is_author_date=t ;;
178
--)
179
shift; break ;;
180
*)
@@ -524,7 +528,14 @@ do
528
529
tree=$(git write-tree) &&
530
parent=$(git rev-parse --verify HEAD) &&
527
- commit=$(git commit-tree $tree -p $parent <"$dotest/final-commit") &&
531
+ commit=$(
532
+ if test -n "$committer_date_is_author_date"
533
+ then
534
+ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
535
+ export GIT_COMMITTER_DATE
536
+ fi &&
537
+ git commit-tree $tree -p $parent <"$dotest/final-commit"
538
+ ) &&
539
git update-ref -m "$GIT_REFLOG_ACTION: $FIRSTLINE" HEAD $commit $parent ||
540
stop_here $this
541
t/t4150-am.sh
+20
@@ -257,4 +257,24 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
257
test -z "$(git diff second)"
258
'
259
260
+test_expect_success 'am --committer-date-is-author-date' '
261
+ git checkout first &&
262
+ test_tick &&
263
+ git am --committer-date-is-author-date patch1 &&
264
+ git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
265
+ at=$(sed -ne "/^author /s/.*> //p" head1) &&
266
+ ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
267
+ test "$at" = "$ct"
268
+'
269
+
270
+test_expect_success 'am without --committer-date-is-author-date' '
271
+ git checkout first &&
272
+ test_tick &&
273
+ git am patch1 &&
274
+ git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
275
+ at=$(sed -ne "/^author /s/.*> //p" head1) &&
276
+ ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
277
+ test "$at" != "$ct"
278
+'
279
+
280
test_done