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: しらいしななこ <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nanako Shiraishi committed
Jan 24, 2009 at 10:18 UTC
a79ec62d064e32b5c3979a16d215fdb70fe965c0
3 files changed
+37
-1
Documentation/git-am.txt
+16
-1
@@ -10,7 +10,8 @@ SYNOPSIS
10
--------
11
[verse]
12
'git am' [--signoff] [--keep] [--utf8 | --no-utf8]
13
- [--3way] [--interactive]
13
+ [--3way] [--interactive] [--committer-date-is-author-date]
14
+ [--ignore-date]
15
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
16
[--reject]
17
[<mbox> | <Maildir>...]
@@ -73,6 +74,20 @@ default. You could use `--no-utf8` to override this.
74
--interactive::
75
Run interactively.
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
+
91
--skip::
92
Skip the current patch. This is only meaningful when
93
restarting an aborted patch.
git-am.sh
+8
@@ -25,6 +25,7 @@ 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
+ignore-date use current timestamp for author date
29
rebasing (internal use for git-rebase)"
30
31
. git-sh-setup
@@ -136,6 +137,7 @@ sign= utf8=t keep= skip= interactive= resolved= rebasing= abort=
137
resolvemsg= resume=
138
git_apply_opt=
139
committer_date_is_author_date=
140
+ignore_date=
141
142
while test $# != 0
143
do
@@ -175,6 +177,8 @@ do
177
git_apply_opt="$git_apply_opt $1" ;;
178
--committer-date-is-author-date)
179
committer_date_is_author_date=t ;;
180
+ --ignore-date)
181
+ ignore_date=t ;;
182
--)
183
shift; break ;;
184
*)
@@ -529,6 +533,10 @@ do
533
tree=$(git write-tree) &&
534
parent=$(git rev-parse --verify HEAD) &&
535
commit=$(
536
+ if test -n "$ignore_date"
537
+ then
538
+ GIT_AUTHOR_DATE=
539
+ fi
540
if test -n "$committer_date_is_author_date"
541
then
542
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
t/t4150-am.sh
+13
@@ -277,4 +277,17 @@ test_expect_success 'am without --committer-date-is-author-date' '
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
+
293
test_done