3 # Copyright (c) 2019 Rohit Ashiwal
6 test_description
='tests to ensure compatibility between am and interactive backends'
10 GIT_AUTHOR_DATE
="1999-04-02T08:03:20+05:30"
11 export GIT_AUTHOR_DATE
13 # This is a special case in which both am and interactive backends
14 # provide the same output. It was done intentionally because
15 # both the backends fall short of optimal behaviour.
16 test_expect_success
'setup' '
17 git checkout -b topic &&
18 q_to_tab >file <<-\EOF &&
24 git commit -m "add file" &&
30 git commit -am "update file" &&
32 test_commit commit1 foo foo1 &&
33 test_commit commit2 foo foo2 &&
34 test_commit commit3 foo foo3 &&
36 git checkout --orphan master &&
37 git rm --cached foo &&
39 sed -e "s/^|//" >file <<-\EOF &&
45 git commit -m "add file" &&
49 test_expect_success
'--ignore-whitespace works with am backend' '
50 cat >expect <<-\EOF &&
55 test_must_fail git rebase main side &&
57 git rebase --ignore-whitespace main side &&
61 test_expect_success
'--ignore-whitespace works with interactive backend' '
62 cat >expect <<-\EOF &&
67 test_must_fail git rebase --merge main side &&
69 git rebase --merge --ignore-whitespace main side &&
73 test_expect_success
'--committer-date-is-author-date works with am backend' '
75 git rebase --committer-date-is-author-date HEAD^ &&
76 git show HEAD --pretty="format:%ai" >authortime &&
77 git show HEAD --pretty="format:%ci" >committertime &&
78 test_cmp authortime committertime
81 test_expect_success
'--committer-date-is-author-date works with interactive backend' '
83 git rebase -i --committer-date-is-author-date HEAD^ &&
84 git show HEAD --pretty="format:%ai" >authortime &&
85 git show HEAD --pretty="format:%ci" >committertime &&
86 test_cmp authortime committertime
89 test_expect_success
'--committer-date-is-author-date works with rebase -r' '
91 git merge --no-ff commit3 &&
92 git rebase -r --root --committer-date-is-author-date &&
93 git rev-list HEAD >rev_list &&
96 git show $HASH --pretty="format:%ai" >authortime
97 git show $HASH --pretty="format:%ci" >committertime
98 test_cmp authortime committertime
102 # Checking for +0000 in author time is enough since default
103 # timezone is UTC, but the timezone used while committing
105 test_expect_success
'--ignore-date works with am backend' '
106 git commit --amend --date="$GIT_AUTHOR_DATE" &&
107 git rebase --ignore-date HEAD^ &&
108 git show HEAD --pretty="format:%ai" >authortime &&
109 grep "+0000" authortime
112 test_expect_success
'--ignore-date works with interactive backend' '
113 git commit --amend --date="$GIT_AUTHOR_DATE" &&
114 git rebase --ignore-date -i HEAD^ &&
115 git show HEAD --pretty="format:%ai" >authortime &&
116 grep "+0000" authortime
119 test_expect_success
'--ignore-date works with rebase -r' '
121 git merge --no-ff commit3 &&
122 git rebase -r --root --ignore-date &&
123 git rev-list HEAD >rev_list &&
126 git show $HASH --pretty="format:%ai" >authortime
127 grep "+0000" authortime