3 test_description='diff order & rotate'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13 echo "$1" >c/Makefile &&
15 git add a.h b.c c/Makefile d.txt &&
19 test_expect_success 'setup' '
24 cat >order_file_1 <<-\EOF &&
30 cat >order_file_2 <<-\EOF &&
36 cat >expect_none <<-\EOF &&
43 cat >expect_1 <<-\EOF &&
58 test_expect_success "no order (=tree object order)" '
59 git diff --name-only HEAD^..HEAD >actual &&
60 test_cmp expect_none actual
63 test_expect_success 'missing orderfile' '
65 test_must_fail git diff -Obogus_file --name-only HEAD^..HEAD
68 test_expect_success POSIXPERM,SANITY 'unreadable orderfile' '
70 chmod -r unreadable_file &&
71 test_must_fail git diff -Ounreadable_file --name-only HEAD^..HEAD
74 test_expect_success "orderfile using option from subdir with --output" '
76 git -C subdir diff -O../order_file_1 --output ../actual --name-only HEAD^..HEAD &&
77 test_cmp expect_1 actual
82 test_expect_success "orderfile using option ($i)" '
83 git diff -Oorder_file_$i --name-only HEAD^..HEAD >actual &&
84 test_cmp expect_$i actual
87 test_expect_success PIPE "orderfile is fifo ($i)" '
91 cat order_file_$i >order_fifo &
93 git diff -O order_fifo --name-only HEAD^..HEAD >actual &&
95 test_cmp expect_$i actual
98 test_expect_success "orderfile using config ($i)" '
99 git -c diff.orderfile=order_file_$i diff --name-only HEAD^..HEAD >actual &&
100 test_cmp expect_$i actual
103 test_expect_success "cancelling configured orderfile ($i)" '
104 git -c diff.orderfile=order_file_$i diff -O/dev/null --name-only HEAD^..HEAD >actual &&
105 test_cmp expect_none actual
109 test_expect_success 'setup for testing combine-diff order' '
110 git checkout -b tmp HEAD~ &&
113 git merge --no-commit -s ours tmp &&
117 test_expect_success "combine-diff: no order (=tree object order)" '
118 git diff --name-only HEAD HEAD^ HEAD^2 >actual &&
119 test_cmp expect_none actual
124 test_expect_success "combine-diff: orderfile using option ($i)" '
125 git diff -Oorder_file_$i --name-only HEAD HEAD^ HEAD^2 >actual &&
126 test_cmp expect_$i actual
132 test_expect_success 'rotate and skip setup' '
137 git add sample[1234].t &&
138 git commit -m "added" sample[1234].t &&
139 echo modified >>sample1.t &&
140 echo modified >>sample2.t &&
141 echo modified >>sample4.t &&
142 git commit -m "updated" sample[1234].t
145 test_expect_success 'diff --rotate-to' '
146 git diff --rotate-to=sample2.t --name-only HEAD^ >actual &&
147 test_write_lines sample2.t sample4.t sample1.t >expect &&
148 test_cmp expect actual
151 test_expect_success 'diff --skip-to' '
152 git diff --skip-to=sample2.t --name-only HEAD^ >actual &&
153 test_write_lines sample2.t sample4.t >expect &&
154 test_cmp expect actual
157 test_expect_success 'diff --rotate/skip-to error condition' '
158 test_must_fail git diff --rotate-to=sample3.t HEAD^ &&
159 test_must_fail git diff --skip-to=sample3.t HEAD^
162 test_expect_success 'log --rotate-to' '
163 git log --rotate-to=sample3.t --raw HEAD~2.. >raw &&
164 # just distill the commit header and paths
165 sed -n -e "s/^commit.*/commit/p" \
166 -e "/^:/s/^.* //p" raw >actual &&
168 cat >expect <<-\EOF &&
180 test_cmp expect actual
183 test_expect_success 'log --skip-to' '
184 git log --skip-to=sample3.t --raw HEAD~2.. >raw &&
185 # just distill the commit header and paths
186 sed -n -e "s/^commit.*/commit/p" \
187 -e "/^:/s/^.* //p" raw >actual &&
189 cat >expect <<-\EOF &&
197 test_cmp expect actual