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>
This commit is contained in:

committed by
Junio C Hamano

parent
1a4437675e
commit
4fb554af49
@ -450,6 +450,7 @@ See also INCOMPATIBLE OPTIONS below.
|
|||||||
date. This option implies --force-rebase.
|
date. This option implies --force-rebase.
|
||||||
|
|
||||||
--ignore-date::
|
--ignore-date::
|
||||||
|
--reset-author-date::
|
||||||
Instead of using the author date of the original commit, use
|
Instead of using the author date of the original commit, use
|
||||||
the current time as the author date of the rebased commit. This
|
the current time as the author date of the rebased commit. This
|
||||||
option implies `--force-rebase`.
|
option implies `--force-rebase`.
|
||||||
|
@ -1519,8 +1519,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||||||
OPT_BOOL(0, "committer-date-is-author-date",
|
OPT_BOOL(0, "committer-date-is-author-date",
|
||||||
&options.committer_date_is_author_date,
|
&options.committer_date_is_author_date,
|
||||||
N_("make committer date match author date")),
|
N_("make committer date match author date")),
|
||||||
OPT_BOOL(0, "ignore-date", &options.ignore_date,
|
OPT_BOOL(0, "reset-author-date", &options.ignore_date,
|
||||||
"ignore author date and use current date"),
|
N_("ignore author date and use current date")),
|
||||||
|
OPT_HIDDEN_BOOL(0, "ignore-date", &options.ignore_date,
|
||||||
|
N_("synonym of --reset-author-date")),
|
||||||
OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
|
OPT_PASSTHRU_ARGV('C', NULL, &options.git_am_opts, N_("n"),
|
||||||
N_("passed to 'git apply'"), 0),
|
N_("passed to 'git apply'"), 0),
|
||||||
OPT_BOOL(0, "ignore-whitespace", &options.ignore_whitespace,
|
OPT_BOOL(0, "ignore-whitespace", &options.ignore_whitespace,
|
||||||
|
@ -137,22 +137,22 @@ test_expect_success '--committer-date-is-author-date works when committing confl
|
|||||||
# Checking for +0000 in author time is enough since default
|
# Checking for +0000 in author time is enough since default
|
||||||
# timezone is UTC, but the timezone used while committing
|
# timezone is UTC, but the timezone used while committing
|
||||||
# sets to +0530.
|
# sets to +0530.
|
||||||
test_expect_success '--ignore-date works with apply backend' '
|
test_expect_success '--reset-author-date works with apply backend' '
|
||||||
git commit --amend --date="$GIT_AUTHOR_DATE" &&
|
git commit --amend --date="$GIT_AUTHOR_DATE" &&
|
||||||
git rebase --apply --ignore-date HEAD^ &&
|
git rebase --apply --reset-author-date HEAD^ &&
|
||||||
git log -1 --pretty=%ai >authortime &&
|
git log -1 --pretty=%ai >authortime &&
|
||||||
grep "+0000" authortime
|
grep "+0000" authortime
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--ignore-date works with merge backend' '
|
test_expect_success '--reset-author-date works with merge backend' '
|
||||||
git commit --amend --date="$GIT_AUTHOR_DATE" &&
|
git commit --amend --date="$GIT_AUTHOR_DATE" &&
|
||||||
git rebase --ignore-date -m HEAD^ &&
|
git rebase --reset-author-date -m HEAD^ &&
|
||||||
git log -1 --pretty=%ai >authortime &&
|
git log -1 --pretty=%ai >authortime &&
|
||||||
grep "+0000" authortime
|
grep "+0000" authortime
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--ignore-date works after conflict resolution' '
|
test_expect_success '--reset-author-date works after conflict resolution' '
|
||||||
test_must_fail git rebase --ignore-date -m \
|
test_must_fail git rebase --reset-author-date -m \
|
||||||
--onto commit2^^ commit2^ commit2 &&
|
--onto commit2^^ commit2^ commit2 &&
|
||||||
echo resolved >foo &&
|
echo resolved >foo &&
|
||||||
git add foo &&
|
git add foo &&
|
||||||
@ -161,17 +161,17 @@ test_expect_success '--ignore-date works after conflict resolution' '
|
|||||||
grep +0000 authortime
|
grep +0000 authortime
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--ignore-date works with rebase -r' '
|
test_expect_success '--reset-author-date works with rebase -r' '
|
||||||
git checkout side &&
|
git checkout side &&
|
||||||
git merge --no-ff commit3 &&
|
git merge --no-ff commit3 &&
|
||||||
git rebase -r --root --ignore-date &&
|
git rebase -r --root --reset-author-date &&
|
||||||
git log --pretty=%ai >authortime &&
|
git log --pretty=%ai >authortime &&
|
||||||
! grep -v "+0000" authortime
|
! grep -v "+0000" authortime
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--ignore-date with --committer-date-is-author-date works' '
|
test_expect_success '--reset-author-date with --committer-date-is-author-date works' '
|
||||||
test_must_fail git rebase -m --committer-date-is-author-date \
|
test_must_fail git rebase -m --committer-date-is-author-date \
|
||||||
--ignore-date --onto commit2^^ commit2^ commit3 &&
|
--reset-author-date --onto commit2^^ commit2^ commit3 &&
|
||||||
git checkout --theirs foo &&
|
git checkout --theirs foo &&
|
||||||
git add foo &&
|
git add foo &&
|
||||||
git rebase --continue &&
|
git rebase --continue &&
|
||||||
@ -181,9 +181,9 @@ test_expect_success '--ignore-date with --committer-date-is-author-date works' '
|
|||||||
! grep -v "+0000" authortime
|
! grep -v "+0000" authortime
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '--ignore-date --committer-date-is-author-date works when forking merge' '
|
test_expect_success '--reset-author-date --committer-date-is-author-date works when forking merge' '
|
||||||
GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \
|
GIT_SEQUENCE_EDITOR="echo \"merge -C $(git rev-parse HEAD) commit3\">" \
|
||||||
git rebase -i --strategy=resolve --ignore-date \
|
git rebase -i --strategy=resolve --reset-author-date \
|
||||||
--committer-date-is-author-date side side &&
|
--committer-date-is-author-date side side &&
|
||||||
git log -1 --pretty=%ai >authortime &&
|
git log -1 --pretty=%ai >authortime &&
|
||||||
git log -1 --pretty=%ci >committertime &&
|
git log -1 --pretty=%ci >committertime &&
|
||||||
@ -191,6 +191,16 @@ test_expect_success '--ignore-date --committer-date-is-author-date works when fo
|
|||||||
grep "+0000" authortime
|
grep "+0000" authortime
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '--ignore-date is an alias for --reset-author-date' '
|
||||||
|
git commit --amend --date="$GIT_AUTHOR_DATE" &&
|
||||||
|
git rebase --apply --ignore-date HEAD^ &&
|
||||||
|
git commit --allow-empty -m empty --date="$GIT_AUTHOR_DATE" &&
|
||||||
|
git rebase -m --ignore-date HEAD^ &&
|
||||||
|
git log -2 --pretty=%ai >authortime &&
|
||||||
|
grep "+0000" authortime >output &&
|
||||||
|
test_line_count = 2 output
|
||||||
|
'
|
||||||
|
|
||||||
# This must be the last test in this file
|
# This must be the last test in this file
|
||||||
test_expect_success '$EDITOR and friends are unchanged' '
|
test_expect_success '$EDITOR and friends are unchanged' '
|
||||||
test_editor_unchanged
|
test_editor_unchanged
|
||||||
|
Reference in New Issue
Block a user