Rebase is implemented with two different backends - 'apply' and
'merge' each of which support a different set of options. In
particular the apply backend supports a number of options implemented
by 'git am' that are not implemented in the merge backend. This means
that the available options are different depending on which backend is
used which is confusing. This patch adds support for the --ignore-date
option to the merge backend. This option uses the current time as the
author date rather than reusing the original author date when
rewriting commits. We take care to handle the combination of
--ignore-date and --committer-date-is-author-date in the same way as
the apply backend.
Original-patch-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
@ -617,6 +617,7 @@ In addition, the following pairs of options are incompatible:
@@ -617,6 +617,7 @@ In addition, the following pairs of options are incompatible:
* --preserve-merges and --empty=
* --preserve-merges and --ignore-whitespace
* --preserve-merges and --committer-date-is-author-date
@ -108,6 +108,62 @@ test_expect_success '--committer-date-is-author-date works when committing confl
@@ -108,6 +108,62 @@ test_expect_success '--committer-date-is-author-date works when committing confl
test_ctime_is_atime -1
'
# Checking for +0000 in the author date is sufficient since the
# default timezone is UTC but the timezone used while committing is
# +0530. The inverted logic in the grep is necessary to check all the
# author dates in the file.
test_atime_is_ignored () {
git log $1 --format=%ai >authortime &&
! grep -v +0000 authortime
}
test_expect_success '--ignore-date works with apply backend' '
git commit --amend --date="$GIT_AUTHOR_DATE" &&
git rebase --apply --ignore-date HEAD^ &&
test_atime_is_ignored -1
'
test_expect_success '--ignore-date works with merge backend' '
git commit --amend --date="$GIT_AUTHOR_DATE" &&
git rebase --ignore-date -m HEAD^ &&
test_atime_is_ignored -1
'
test_expect_success '--ignore-date works after conflict resolution' '
test_must_fail git rebase --ignore-date -m \
--onto commit2^^ commit2^ commit2 &&
echo resolved >foo &&
git add foo &&
git rebase --continue &&
test_atime_is_ignored -1
'
test_expect_success '--ignore-date works with rebase -r' '
git checkout side &&
git merge --no-ff commit3 &&
git rebase -r --root --ignore-date &&
test_atime_is_ignored
'
test_expect_success '--ignore-date with --committer-date-is-author-date works' '
test_must_fail git rebase -m --committer-date-is-author-date \