]>
Commit | Line | Data |
---|---|---|
ba51d2fb RA |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2019 Rohit Ashiwal | |
4 | # | |
5 | ||
6 | test_description='tests to ensure compatibility between am and interactive backends' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
cbd8db17 RA |
10 | GIT_AUTHOR_DATE="1999-04-02T08:03:20+05:30" |
11 | export GIT_AUTHOR_DATE | |
12 | ||
ba51d2fb RA |
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 && | |
19 | line 1 | |
20 | Qline 2 | |
21 | line 3 | |
22 | EOF | |
23 | git add file && | |
24 | git commit -m "add file" && | |
25 | cat >file <<-\EOF && | |
26 | line 1 | |
27 | new line 2 | |
28 | line 3 | |
29 | EOF | |
30 | git commit -am "update file" && | |
31 | git tag side && | |
cbd8db17 RA |
32 | test_commit commit1 foo foo1 && |
33 | test_commit commit2 foo foo2 && | |
34 | test_commit commit3 foo foo3 && | |
ba51d2fb RA |
35 | |
36 | git checkout --orphan master && | |
cbd8db17 RA |
37 | git rm --cached foo && |
38 | rm foo && | |
ba51d2fb RA |
39 | sed -e "s/^|//" >file <<-\EOF && |
40 | |line 1 | |
41 | | line 2 | |
42 | |line 3 | |
43 | EOF | |
44 | git add file && | |
45 | git commit -m "add file" && | |
46 | git tag main | |
47 | ' | |
48 | ||
49 | test_expect_success '--ignore-whitespace works with am backend' ' | |
50 | cat >expect <<-\EOF && | |
51 | line 1 | |
52 | new line 2 | |
53 | line 3 | |
54 | EOF | |
55 | test_must_fail git rebase main side && | |
56 | git rebase --abort && | |
57 | git rebase --ignore-whitespace main side && | |
58 | test_cmp expect file | |
59 | ' | |
60 | ||
61 | test_expect_success '--ignore-whitespace works with interactive backend' ' | |
62 | cat >expect <<-\EOF && | |
63 | line 1 | |
64 | new line 2 | |
65 | line 3 | |
66 | EOF | |
67 | test_must_fail git rebase --merge main side && | |
68 | git rebase --abort && | |
69 | git rebase --merge --ignore-whitespace main side && | |
70 | test_cmp expect file | |
71 | ' | |
72 | ||
cbd8db17 RA |
73 | test_expect_success '--committer-date-is-author-date works with am backend' ' |
74 | git commit --amend && | |
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 | |
79 | ' | |
80 | ||
81 | test_expect_success '--committer-date-is-author-date works with interactive backend' ' | |
82 | git commit --amend && | |
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 | |
87 | ' | |
88 | ||
89 | test_expect_success '--committer-date-is-author-date works with rebase -r' ' | |
90 | git checkout side && | |
91 | git merge --no-ff commit3 && | |
92 | git rebase -r --root --committer-date-is-author-date && | |
93 | git rev-list HEAD >rev_list && | |
94 | while read HASH | |
95 | do | |
96 | git show $HASH --pretty="format:%ai" >authortime | |
97 | git show $HASH --pretty="format:%ci" >committertime | |
98 | test_cmp authortime committertime | |
99 | done <rev_list | |
100 | ' | |
101 | ||
08187b4c RA |
102 | # Checking for +0000 in author time is enough since default |
103 | # timezone is UTC, but the timezone used while committing | |
104 | # sets to +0530. | |
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 | |
110 | ' | |
111 | ||
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 | |
117 | ' | |
118 | ||
119 | test_expect_success '--ignore-date works with rebase -r' ' | |
120 | git checkout side && | |
121 | git merge --no-ff commit3 && | |
122 | git rebase -r --root --ignore-date && | |
123 | git rev-list HEAD >rev_list && | |
124 | while read HASH | |
125 | do | |
126 | git show $HASH --pretty="format:%ai" >authortime | |
127 | grep "+0000" authortime | |
128 | done <rev_list | |
129 | ' | |
130 | ||
ba51d2fb | 131 | test_done |