3 test_description
='diff order & rotate'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
14 echo "$1" >c
/Makefile
&&
16 git add a.h b.c c
/Makefile d.txt
&&
20 test_expect_success
'setup' '
25 cat >order_file_1 <<-\EOF &&
31 cat >order_file_2 <<-\EOF &&
37 cat >expect_none <<-\EOF &&
44 cat >expect_1 <<-\EOF &&
59 test_expect_success
"no order (=tree object order)" '
60 git diff --name-only HEAD^..HEAD >actual &&
61 test_cmp expect_none actual
64 test_expect_success
'missing orderfile' '
66 test_must_fail git diff -Obogus_file --name-only HEAD^..HEAD
69 test_expect_success POSIXPERM
,SANITY
'unreadable orderfile' '
71 chmod -r unreadable_file &&
72 test_must_fail git diff -Ounreadable_file --name-only HEAD^..HEAD
75 test_expect_success
"orderfile using option from subdir with --output" '
77 git -C subdir diff -O../order_file_1 --output ../actual --name-only HEAD^..HEAD &&
78 test_cmp expect_1 actual
83 test_expect_success
"orderfile using option ($i)" '
84 git diff -Oorder_file_$i --name-only HEAD^..HEAD >actual &&
85 test_cmp expect_$i actual
88 test_expect_success PIPE
"orderfile is fifo ($i)" '
92 cat order_file_$i >order_fifo &
94 git diff -O order_fifo --name-only HEAD^..HEAD >actual &&
96 test_cmp expect_$i actual
99 test_expect_success
"orderfile using config ($i)" '
100 git -c diff.orderfile=order_file_$i diff --name-only HEAD^..HEAD >actual &&
101 test_cmp expect_$i actual
104 test_expect_success
"cancelling configured orderfile ($i)" '
105 git -c diff.orderfile=order_file_$i diff -O/dev/null --name-only HEAD^..HEAD >actual &&
106 test_cmp expect_none actual
110 test_expect_success
'setup for testing combine-diff order' '
111 git checkout -b tmp HEAD~ &&
114 git merge --no-commit -s ours tmp &&
118 test_expect_success
"combine-diff: no order (=tree object order)" '
119 git diff --name-only HEAD HEAD^ HEAD^2 >actual &&
120 test_cmp expect_none actual
125 test_expect_success
"combine-diff: orderfile using option ($i)" '
126 git diff -Oorder_file_$i --name-only HEAD HEAD^ HEAD^2 >actual &&
127 test_cmp expect_$i actual
133 test_expect_success
'rotate and skip setup' '
138 git add sample[1234].t &&
139 git commit -m "added" sample[1234].t &&
140 echo modified >>sample1.t &&
141 echo modified >>sample2.t &&
142 echo modified >>sample4.t &&
143 git commit -m "updated" sample[1234].t
146 test_expect_success
'diff --rotate-to' '
147 git diff --rotate-to=sample2.t --name-only HEAD^ >actual &&
148 test_write_lines sample2.t sample4.t sample1.t >expect &&
149 test_cmp expect actual
152 test_expect_success
'diff --skip-to' '
153 git diff --skip-to=sample2.t --name-only HEAD^ >actual &&
154 test_write_lines sample2.t sample4.t >expect &&
155 test_cmp expect actual
158 test_expect_success
'diff --rotate/skip-to error condition' '
159 test_must_fail git diff --rotate-to=sample3.t HEAD^ &&
160 test_must_fail git diff --skip-to=sample3.t HEAD^
163 test_expect_success
'log --rotate-to' '
164 git log --rotate-to=sample3.t --raw HEAD~2.. >raw &&
165 # just distill the commit header and paths
166 sed -n -e "s/^commit.*/commit/p" \
167 -e "/^:/s/^.* //p" raw >actual &&
169 cat >expect <<-\EOF &&
181 test_cmp expect actual
184 test_expect_success
'log --skip-to' '
185 git log --skip-to=sample3.t --raw HEAD~2.. >raw &&
186 # just distill the commit header and paths
187 sed -n -e "s/^commit.*/commit/p" \
188 -e "/^:/s/^.* //p" raw >actual &&
190 cat >expect <<-\EOF &&
198 test_cmp expect actual