File tree Expand file tree Collapse file tree 3 files changed +69
-2
lines changed Expand file tree Collapse file tree 3 files changed +69
-2
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ SYNOPSIS
10
10
--------
11
11
[verse]
12
12
'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
13
- [--3way] [--interactive]
13
+ [--3way] [--interactive] [--committer-date-is-author-date]
14
+ [--ignore-date]
14
15
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
15
16
[--reject]
16
17
[<mbox> | <Maildir>...]
@@ -73,6 +74,20 @@ default. You could use `--no-utf8` to override this.
73
74
--interactive::
74
75
Run interactively.
75
76
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
+
76
91
--skip::
77
92
Skip the current patch. This is only meaningful when
78
93
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
23
23
r,resolved to be used after a patch failure
24
24
skip skip the current patch
25
25
abort 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
26
28
rebasing* (internal use for git-rebase)"
27
29
28
30
. git-sh-setup
@@ -133,6 +135,8 @@ dotest="$GIT_DIR/rebase-apply"
133
135
sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
134
136
resolvemsg= resume=
135
137
git_apply_opt=
138
+ committer_date_is_author_date=
139
+ ignore_date=
136
140
137
141
while test $# ! = 0
138
142
do
170
174
git_apply_opt=" $git_apply_opt $( sq " $1$2 " ) " ; shift ;;
171
175
--reject)
172
176
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 ;;
173
181
--)
174
182
shift ; break ;;
175
183
* )
520
528
521
529
tree=$( git write-tree) &&
522
530
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
+ ) &&
524
543
git update-ref -m " $GIT_REFLOG_ACTION : $FIRSTLINE " HEAD $commit $parent ||
525
544
stop_here $this
526
545
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' '
257
257
test -z "$(git diff second)"
258
258
'
259
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
+ # 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
+
260
293
test_done
You can’t perform that action at this time.
0 commit comments