Skip to content

Commit 2712669

Browse files
r1walzgitster
authored andcommitted
rebase: add --reset-author-date
The previous commit introduced --ignore-date flag to rebase -i, but the name is rather vague as it does not say whether the author date or the committer date is ignored. Add an alias to convey the precise purpose. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Rohit Ashiwal <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a3894aa commit 2712669

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

Documentation/git-rebase.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ See also INCOMPATIBLE OPTIONS below.
450450
date. This option implies `--force-rebase`.
451451

452452
--ignore-date::
453+
--reset-author-date::
453454
Instead of using the author date of the original commit, use
454455
the current time as the author date of the rebased commit. This
455456
option implies `--force-rebase`.

builtin/rebase.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,8 +1505,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
15051505
OPT_BOOL(0, "committer-date-is-author-date",
15061506
&options.committer_date_is_author_date,
15071507
N_("make committer date match author date")),
1508-
OPT_BOOL(0, "ignore-date", &options.ignore_date,
1508+
OPT_BOOL(0, "reset-author-date", &options.ignore_date,
15091509
N_("ignore author date and use current date")),
1510+
OPT_HIDDEN_BOOL(0, "ignore-date", &options.ignore_date,
1511+
N_("synonym of --reset-author-date")),
15101512
OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
15111513
N_("passed to 'git apply'"), 0),
15121514
OPT_BOOL(0, "ignore-whitespace", &ignore_whitespace,

t/t3436-rebase-more-options.sh

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,53 +117,61 @@ test_atime_is_ignored () {
117117
! grep -v +0000 authortime
118118
}
119119

120-
test_expect_success '--ignore-date works with apply backend' '
120+
test_expect_success '--reset-author-date works with apply backend' '
121121
git commit --amend --date="$GIT_AUTHOR_DATE" &&
122-
git rebase --apply --ignore-date HEAD^ &&
122+
git rebase --apply --reset-author-date HEAD^ &&
123123
test_atime_is_ignored -1
124124
'
125125

126-
test_expect_success '--ignore-date works with merge backend' '
126+
test_expect_success '--reset-author-date works with merge backend' '
127127
git commit --amend --date="$GIT_AUTHOR_DATE" &&
128-
git rebase --ignore-date -m HEAD^ &&
128+
git rebase --reset-author-date -m HEAD^ &&
129129
test_atime_is_ignored -1
130130
'
131131

132-
test_expect_success '--ignore-date works after conflict resolution' '
133-
test_must_fail git rebase --ignore-date -m \
132+
test_expect_success '--reset-author-date works after conflict resolution' '
133+
test_must_fail git rebase --reset-author-date -m \
134134
--onto commit2^^ commit2^ commit2 &&
135135
echo resolved >foo &&
136136
git add foo &&
137137
git rebase --continue &&
138138
test_atime_is_ignored -1
139139
'
140140

141-
test_expect_success '--ignore-date works with rebase -r' '
141+
test_expect_success '--reset-author-date works with rebase -r' '
142142
git checkout side &&
143143
git merge --no-ff commit3 &&
144-
git rebase -r --root --ignore-date &&
144+
git rebase -r --root --reset-author-date &&
145145
test_atime_is_ignored
146146
'
147147

148-
test_expect_success '--ignore-date with --committer-date-is-author-date works' '
148+
test_expect_success '--reset-author-date with --committer-date-is-author-date works' '
149149
test_must_fail git rebase -m --committer-date-is-author-date \
150-
--ignore-date --onto commit2^^ commit2^ commit3 &&
150+
--reset-author-date --onto commit2^^ commit2^ commit3 &&
151151
git checkout --theirs foo &&
152152
git add foo &&
153153
git rebase --continue &&
154154
test_ctime_is_atime -2 &&
155155
test_atime_is_ignored -2
156156
'
157157

158-
test_expect_success '--ignore-date --committer-date-is-author-date works when forking merge' '
158+
test_expect_success '--reset-author-date --committer-date-is-author-date works when forking merge' '
159159
GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \
160160
PATH="./test-bin:$PATH" git rebase -i --strategy=test \
161-
--ignore-date --committer-date-is-author-date \
162-
side side &&
161+
--reset-author-date \
162+
--committer-date-is-author-date side side &&
163163
test_ctime_is_atime -1 &&
164164
test_atime_is_ignored -1
165165
'
166166

167+
test_expect_success '--ignore-date is an alias for --reset-author-date' '
168+
git commit --amend --date="$GIT_AUTHOR_DATE" &&
169+
git rebase --apply --ignore-date HEAD^ &&
170+
git commit --allow-empty -m empty --date="$GIT_AUTHOR_DATE" &&
171+
git rebase -m --ignore-date HEAD^ &&
172+
test_atime_is_ignored -2
173+
'
174+
167175
# This must be the last test in this file
168176
test_expect_success '$EDITOR and friends are unchanged' '
169177
test_editor_unchanged

0 commit comments

Comments
 (0)