@matheusbsbs / matheus-bagliano / commits / 27126692ba
Fork 0

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 <gitster@pobox.com> Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rohit Ashiwal committed Aug 17, 2020 at 18:40 UTC 27126692ba1688081d8427220087bb7662594bd9
3 files changed +25 -14
Documentation/git-rebase.txt
+1
@@ -450,6 +450,7 @@ See also INCOMPATIBLE OPTIONS below.
450 date. This option implies `--force-rebase`.
451
452 --ignore-date::
453 +--reset-author-date::
454 Instead of using the author date of the original commit, use
455 the current time as the author date of the rebased commit. This
456 option implies `--force-rebase`.
builtin/rebase.c
+3 -1
@@ -1505,8 +1505,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1505 OPT_BOOL(0, "committer-date-is-author-date",
1506 &options.committer_date_is_author_date,
1507 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,
1509 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")),
1512 OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
1513 N_("passed to 'git apply'"), 0),
1514 OPT_BOOL(0, "ignore-whitespace", &ignore_whitespace,
t/t3436-rebase-more-options.sh
+21 -13
@@ -117,20 +117,20 @@ test_atime_is_ignored () {
117 ! grep -v +0000 authortime
118 }
119
120 -test_expect_success '--ignore-date works with apply backend' '
120 +test_expect_success '--reset-author-date works with apply backend' '
121 git commit --amend --date="$GIT_AUTHOR_DATE" &&
122 - git rebase --apply --ignore-date HEAD^ &&
122 + git rebase --apply --reset-author-date HEAD^ &&
123 test_atime_is_ignored -1
124 '
125
126 -test_expect_success '--ignore-date works with merge backend' '
126 +test_expect_success '--reset-author-date works with merge backend' '
127 git commit --amend --date="$GIT_AUTHOR_DATE" &&
128 - git rebase --ignore-date -m HEAD^ &&
128 + git rebase --reset-author-date -m HEAD^ &&
129 test_atime_is_ignored -1
130 '
131
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 \
134 --onto commit2^^ commit2^ commit2 &&
135 echo resolved >foo &&
136 git add foo &&
@@ -138,16 +138,16 @@ test_expect_success '--ignore-date works after conflict resolution' '
138 test_atime_is_ignored -1
139 '
140
141 -test_expect_success '--ignore-date works with rebase -r' '
141 +test_expect_success '--reset-author-date works with rebase -r' '
142 git checkout side &&
143 git merge --no-ff commit3 &&
144 - git rebase -r --root --ignore-date &&
144 + git rebase -r --root --reset-author-date &&
145 test_atime_is_ignored
146 '
147
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' '
149 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 &&
151 git checkout --theirs foo &&
152 git add foo &&
153 git rebase --continue &&
@@ -155,15 +155,23 @@ test_expect_success '--ignore-date with --committer-date-is-author-date works' '
155 test_atime_is_ignored -2
156 '
157
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' '
159 GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \
160 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 &&
163 test_ctime_is_atime -1 &&
164 test_atime_is_ignored -1
165 '
166
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 +
175 # This must be the last test in this file
176 test_expect_success '$EDITOR and friends are unchanged' '
177 test_editor_unchanged