File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ SYNOPSIS
1010--------
1111[verse]
1212'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
13- [--3way] [--interactive]
13+ [--3way] [--interactive] [--committer-date-is-author-date]
14+ [--ignore-date]
1415 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
1516 [--reject]
1617 [<mbox> | <Maildir>...]
@@ -73,6 +74,20 @@ default. You could use `--no-utf8` to override this.
7374--interactive::
7475 Run interactively.
7576
77+ --committer-date-is-author-date::
78+ By default the command records the date from the e-mail
79+ message as the commit author date, and uses the time of
80+ commit creation as the committer date. This allows the
81+ user to lie about the committer date by using the same
82+ timestamp as the author date.
83+
84+ --ignore-date::
85+ By default the command records the date from the e-mail
86+ message as the commit author date, and uses the time of
87+ commit creation as the committer date. This allows the
88+ user to lie about author timestamp by using the same
89+ timestamp as the committer date.
90+
7691--skip::
7792 Skip the current patch. This is only meaningful when
7893 restarting an aborted patch.
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ resolvemsg= override error message when patch failure occurs
2323r,resolved to be used after a patch failure
2424skip skip the current patch
2525abort restore the original branch and abort the patching operation.
26+ committer-date-is-author-date lie about committer date
27+ ignore-date use current timestamp for author date
2628rebasing* (internal use for git-rebase)"
2729
2830. git-sh-setup
@@ -133,6 +135,8 @@ dotest="$GIT_DIR/rebase-apply"
133135sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
134136resolvemsg= resume=
135137git_apply_opt=
138+ committer_date_is_author_date=
139+ ignore_date=
136140
137141while test $# ! = 0
138142do
170174 git_apply_opt=" $git_apply_opt $( sq " $1$2 " ) " ; shift ;;
171175 --reject)
172176 git_apply_opt=" $git_apply_opt $1 " ;;
177+ --committer-date-is-author-date)
178+ committer_date_is_author_date=t ;;
179+ --ignore-date)
180+ ignore_date=t ;;
173181 --)
174182 shift ; break ;;
175183 * )
520528
521529 tree=$( git write-tree) &&
522530 parent=$( git rev-parse --verify HEAD) &&
523- commit=$( git commit-tree $tree -p $parent < " $dotest /final-commit" ) &&
531+ commit=$(
532+ if test -n " $ignore_date "
533+ then
534+ GIT_AUTHOR_DATE=
535+ fi
536+ if test -n " $committer_date_is_author_date "
537+ then
538+ GIT_COMMITTER_DATE=" $GIT_AUTHOR_DATE "
539+ export GIT_COMMITTER_DATE
540+ fi &&
541+ git commit-tree $tree -p $parent < " $dotest /final-commit"
542+ ) &&
524543 git update-ref -m " $GIT_REFLOG_ACTION : $FIRSTLINE " HEAD $commit $parent ||
525544 stop_here $this
526545
Original file line number Diff line number Diff line change @@ -257,4 +257,37 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
257257 test -z "$(git diff second)"
258258'
259259
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+ # This checks for +0000 because TZ is set to UTC and that should
281+ # show up when the current time is used. The date in message is set
282+ # by test_tick that uses -0700 timezone; if this feature does not
283+ # work, we will see that instead of +0000.
284+ test_expect_success ' am --ignore-date' '
285+ git checkout first &&
286+ test_tick &&
287+ git am --ignore-date patch1 &&
288+ git cat-file commit HEAD | sed -e "/^$/q" >head1 &&
289+ at=$(sed -ne "/^author /s/.*> //p" head1) &&
290+ echo "$at" | grep "+0000"
291+ '
292+
260293test_done
You can’t perform that action at this time.
0 commit comments