Skip to content

Commit a79ec62

Browse files
Nanako Shiraishigitster
authored andcommitted
git-am: Add --ignore-date option
This new option tells 'git-am' to ignore the date header field recorded in the format-patch output. The commits will have the timestamp when they are created instead. You can work a lot in one day to accumulate many changes, but apply and push to the public repository only some of them at the end of the first day. Then next day you can spend all your working hours reading comics or chatting with your coworkers, and apply your remaining patches from the previous day using this option to pretend that you have been working at the end of the day. Signed-off-by: しらいしななこ <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f01ad6 commit a79ec62

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Documentation/git-am.txt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff 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.

git-am.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ r,resolved to be used after a patch failure
2525
skip skip the current patch
2626
abort restore the original branch and abort the patching operation.
2727
committer-date-is-author-date lie about committer date
28+
ignore-date use current timestamp for author date
2829
rebasing (internal use for git-rebase)"
2930

3031
. git-sh-setup
@@ -136,6 +137,7 @@ sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
136137
resolvemsg= resume=
137138
git_apply_opt=
138139
committer_date_is_author_date=
140+
ignore_date=
139141

140142
while test $# != 0
141143
do
@@ -175,6 +177,8 @@ do
175177
git_apply_opt="$git_apply_opt $1" ;;
176178
--committer-date-is-author-date)
177179
committer_date_is_author_date=t ;;
180+
--ignore-date)
181+
ignore_date=t ;;
178182
--)
179183
shift; break ;;
180184
*)
@@ -529,6 +533,10 @@ do
529533
tree=$(git write-tree) &&
530534
parent=$(git rev-parse --verify HEAD) &&
531535
commit=$(
536+
if test -n "$ignore_date"
537+
then
538+
GIT_AUTHOR_DATE=
539+
fi
532540
if test -n "$committer_date_is_author_date"
533541
then
534542
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"

t/t4150-am.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,17 @@ test_expect_success 'am without --committer-date-is-author-date' '
277277
test "$at" != "$ct"
278278
'
279279

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+
280293
test_done

0 commit comments

Comments
 (0)