summaryrefslogtreecommitdiff
path: root/t/t3433-rebase-options-compatibility.sh
blob: 5166f158dd80dd6e1cdb4f27b61f6d90f0d3e83a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
#
# Copyright (c) 2019 Rohit Ashiwal
#
 
test_description='tests to ensure compatibility between am and interactive backends'
 
. ./test-lib.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.
test_expect_success 'setup' '
	git checkout -b topic &&
	q_to_tab >file <<-\EOF &&
	line 1
	Qline 2
	line 3
	EOF
	git add file &&
	git commit -m "add file" &&
	cat >file <<-\EOF &&
	line 1
	new line 2
	line 3
	EOF
	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 &&
	git rm --cached foo &&
	rm foo &&
	sed -e "s/^|//" >file <<-\EOF &&
	|line 1
	|        line 2
	|line 3
	EOF
	git add file &&
	git commit -m "add file" &&
	git tag main
'
 
test_expect_success '--ignore-whitespace works with am backend' '
	cat >expect <<-\EOF &&
	line 1
	new line 2
	line 3
	EOF
	test_must_fail git rebase main side &&
	git rebase --abort &&
	git rebase --ignore-whitespace main side &&
	test_cmp expect file
'
 
test_expect_success '--ignore-whitespace works with interactive backend' '
	cat >expect <<-\EOF &&
	line 1
	new line 2
	line 3
	EOF
	test_must_fail git rebase --merge main side &&
	git rebase --abort &&
	git rebase --merge --ignore-whitespace main side &&
	test_cmp expect file
'
 
test_expect_success '--committer-date-is-author-date works with am backend' '
	git commit --amend &&
	git rebase --committer-date-is-author-date HEAD^ &&
	git show HEAD --pretty="format:%ai" >authortime &&
	git show HEAD --pretty="format:%ci" >committertime &&
	test_cmp authortime committertime
'
 
test_expect_success '--committer-date-is-author-date works with interactive backend' '
	git commit --amend &&
	git rebase -i --committer-date-is-author-date HEAD^ &&
	git show HEAD --pretty="format:%ai" >authortime &&
	git show HEAD --pretty="format:%ci" >committertime &&
	test_cmp authortime committertime
'
 
test_expect_success '--committer-date-is-author-date works with rebase -r' '
	git checkout side &&
	git merge --no-ff commit3 &&
	git rebase -r --root --committer-date-is-author-date &&
	git rev-list HEAD >rev_list &&
	while read HASH
	do
		git show $HASH --pretty="format:%ai" >authortime
		git show $HASH --pretty="format:%ci" >committertime
		test_cmp authortime committertime
	done <rev_list
'
 
# Checking for +0000 in author time is enough since default
# timezone is UTC, but the timezone used while committing
# sets to +0530.
test_expect_success '--ignore-date works with am backend' '
	git commit --amend --date="$GIT_AUTHOR_DATE" &&
	git rebase --ignore-date HEAD^ &&
	git show HEAD --pretty="format:%ai" >authortime &&
	grep "+0000" authortime
'
 
test_expect_success '--ignore-date works with interactive backend' '
	git commit --amend --date="$GIT_AUTHOR_DATE" &&
	git rebase --ignore-date -i HEAD^ &&
	git show HEAD --pretty="format:%ai" >authortime &&
	grep "+0000" authortime
'
 
test_expect_success '--ignore-date works with rebase -r' '
	git checkout side &&
	git merge --no-ff commit3 &&
	git rebase -r --root --ignore-date &&
	git rev-list HEAD >rev_list &&
	while read HASH
	do
		git show $HASH --pretty="format:%ai" >authortime
		grep "+0000" authortime
	done <rev_list
'
 
test_done