diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2020-08-17 20:40:02 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-08-17 21:58:37 +0300 |
commit | 7573cec52c0274ceb166c425be4288f6b3103d6f (patch) | |
tree | 6c44e2d1c7c53f313cc6e5745c33e23e808f081e /t/t3436-rebase-more-options.sh | |
parent | e8cbe2118a8e3c1aa71ed8d93f96001decebde1d (diff) |
rebase -i: support --committer-date-is-author-date
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
--committer-date-is-author-date option to the merge backend. This
option uses the author date of the commit that is being rewritten as
the committer date when the new commit is created.
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>
Diffstat (limited to 't/t3436-rebase-more-options.sh')
-rwxr-xr-x | t/t3436-rebase-more-options.sh | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/t/t3436-rebase-more-options.sh b/t/t3436-rebase-more-options.sh index 4f8a6e51c9..50a63d8ebe 100755 --- a/t/t3436-rebase-more-options.sh +++ b/t/t3436-rebase-more-options.sh @@ -9,6 +9,9 @@ test_description='tests to ensure compatibility between am and interactive backe . "$TEST_DIRECTORY"/lib-rebase.sh +GIT_AUTHOR_DATE="1999-04-02T08:03:20+05:30" +export GIT_AUTHOR_DATE + # This is a special case in which both am and interactive backends # provide the same output. It was done intentionally because # both the backends fall short of optimal behaviour. @@ -21,11 +24,20 @@ test_expect_success 'setup' ' test_write_lines "line 1" "new line 2" "line 3" >file && git commit -am "update file" && git tag side && + test_commit commit1 foo foo1 && + test_commit commit2 foo foo2 && + test_commit commit3 foo foo3 && git checkout --orphan master && + rm foo && test_write_lines "line 1" " line 2" "line 3" >file && git commit -am "add file" && - git tag main + git tag main && + + mkdir test-bin && + write_script test-bin/git-merge-test <<-\EOF + exec git-merge-recursive "$@" + EOF ' test_expect_success '--ignore-whitespace works with apply backend' ' @@ -52,6 +64,50 @@ test_expect_success '--ignore-whitespace is remembered when continuing' ' git diff --exit-code side ' +test_ctime_is_atime () { + git log $1 --format=%ai >authortime && + git log $1 --format=%ci >committertime && + test_cmp authortime committertime +} + +test_expect_success '--committer-date-is-author-date works with apply backend' ' + GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author && + git rebase --apply --committer-date-is-author-date HEAD^ && + test_ctime_is_atime -1 +' + +test_expect_success '--committer-date-is-author-date works with merge backend' ' + GIT_AUTHOR_DATE="@1234 +0300" git commit --amend --reset-author && + git rebase -m --committer-date-is-author-date HEAD^ && + test_ctime_is_atime -1 +' + +test_expect_success '--committer-date-is-author-date works with rebase -r' ' + git checkout side && + GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 && + git rebase -r --root --committer-date-is-author-date && + test_ctime_is_atime +' + +test_expect_success '--committer-date-is-author-date works when forking merge' ' + git checkout side && + GIT_AUTHOR_DATE="@1234 +0300" git merge --no-ff commit3 && + PATH="./test-bin:$PATH" git rebase -r --root --strategy=test \ + --committer-date-is-author-date && + test_ctime_is_atime +' + +test_expect_success '--committer-date-is-author-date works when committing conflict resolution' ' + git checkout commit2 && + GIT_AUTHOR_DATE="@1980 +0000" git commit --amend --only --reset-author && + test_must_fail git rebase -m --committer-date-is-author-date \ + --onto HEAD^^ HEAD^ && + echo resolved > foo && + git add foo && + git rebase --continue && + test_ctime_is_atime -1 +' + # This must be the last test in this file test_expect_success '$EDITOR and friends are unchanged' ' test_editor_unchanged |