Skip to content

Commit b527773

Browse files
SamBgitster
authored andcommitted
t4056: add new tests for "git diff -O"
Adapted from $gmane/236427 by Anders Waldenborg, "diff: Add diff.orderfile configuration variable". Signed-off-by: Anders Waldenborg <[email protected]> Signed-off-by: Samuel Bronson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d7aced9 commit b527773

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

t/t4056-diff-order.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/sh
2+
3+
test_description='diff order'
4+
5+
. ./test-lib.sh
6+
7+
create_files () {
8+
echo "$1" >a.h &&
9+
echo "$1" >b.c &&
10+
echo "$1" >c/Makefile &&
11+
echo "$1" >d.txt &&
12+
git add a.h b.c c/Makefile d.txt &&
13+
git commit -m"$1"
14+
}
15+
16+
test_expect_success 'setup' '
17+
mkdir c &&
18+
create_files 1 &&
19+
create_files 2 &&
20+
21+
cat >order_file_1 <<-\EOF &&
22+
*Makefile
23+
*.txt
24+
*.h
25+
EOF
26+
27+
cat >order_file_2 <<-\EOF &&
28+
*Makefile
29+
*.h
30+
*.c
31+
EOF
32+
33+
cat >expect_none <<-\EOF &&
34+
a.h
35+
b.c
36+
c/Makefile
37+
d.txt
38+
EOF
39+
40+
cat >expect_1 <<-\EOF &&
41+
c/Makefile
42+
d.txt
43+
a.h
44+
b.c
45+
EOF
46+
47+
cat >expect_2 <<-\EOF
48+
c/Makefile
49+
a.h
50+
b.c
51+
d.txt
52+
EOF
53+
'
54+
55+
test_expect_success "no order (=tree object order)" '
56+
git diff --name-only HEAD^..HEAD >actual &&
57+
test_cmp expect_none actual
58+
'
59+
60+
for i in 1 2
61+
do
62+
test_expect_success "orderfile using option ($i)" '
63+
git diff -Oorder_file_$i --name-only HEAD^..HEAD >actual &&
64+
test_cmp expect_$i actual
65+
'
66+
done
67+
68+
test_done

0 commit comments

Comments
 (0)