]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4027-diff-submodule.sh
Merge branch 'jc/maint-checkout-index-to-prefix'
[thirdparty/git.git] / t / t4027-diff-submodule.sh
CommitLineData
2b459b48
JH
1#!/bin/sh
2
3test_description='difference in submodules'
4
5. ./test-lib.sh
bfdbee98 6. "$TEST_DIRECTORY"/diff-lib.sh
2b459b48
JH
7
8_z40=0000000000000000000000000000000000000000
9test_expect_success setup '
10 test_tick &&
11 test_create_repo sub &&
12 (
13 cd sub &&
14 echo hello >world &&
15 git add world &&
16 git commit -m submodule
17 ) &&
18
19 test_tick &&
20 echo frotz >nitfol &&
21 git add nitfol sub &&
22 git commit -m superproject &&
23
24 (
25 cd sub &&
26 echo goodbye >world &&
27 git add world &&
28 git commit -m "submodule #2"
29 ) &&
30
31 set x $(
32 cd sub &&
33 git rev-list HEAD
34 ) &&
35 echo ":160000 160000 $3 $_z40 M sub" >expect
36'
37
38test_expect_success 'git diff --raw HEAD' '
39 git diff --raw --abbrev=40 HEAD >actual &&
82ebb0b6 40 test_cmp expect actual
2b459b48
JH
41'
42
43test_expect_success 'git diff-index --raw HEAD' '
44 git diff-index --raw HEAD >actual.index &&
82ebb0b6 45 test_cmp expect actual.index
2b459b48
JH
46'
47
48test_expect_success 'git diff-files --raw' '
49 git diff-files --raw >actual.files &&
82ebb0b6 50 test_cmp expect actual.files
2b459b48
JH
51'
52
1392a377 53test_expect_success 'git diff (empty submodule dir)' '
7c08a2a6
PY
54 : >empty &&
55 rm -rf sub/* sub/.git &&
56 git diff > actual.empty &&
57 test_cmp empty actual.empty
58'
59
7dae8b21
JH
60test_expect_success 'conflicted submodule setup' '
61
62 # 39 efs
63 c=fffffffffffffffffffffffffffffffffffffff
64 (
65 echo "000000 $_z40 0 sub"
66 echo "160000 1$c 1 sub"
67 echo "160000 2$c 2 sub"
68 echo "160000 3$c 3 sub"
69 ) | git update-index --index-info &&
70 echo >expect.nosub '\''diff --cc sub
71index 2ffffff,3ffffff..0000000
72--- a/sub
73+++ b/sub
74@@@ -1,1 -1,1 +1,1 @@@
75- Subproject commit 2fffffffffffffffffffffffffffffffffffffff
76 -Subproject commit 3fffffffffffffffffffffffffffffffffffffff
77++Subproject commit 0000000000000000000000000000000000000000'\'' &&
78
79 hh=$(git rev-parse HEAD) &&
80 sed -e "s/$_z40/$hh/" expect.nosub >expect.withsub
81
82'
83
84test_expect_success 'combined (empty submodule)' '
85 rm -fr sub && mkdir sub &&
86 git diff >actual &&
87 test_cmp expect.nosub actual
88'
89
90test_expect_success 'combined (with submodule)' '
91 rm -fr sub &&
92 git clone --no-checkout . sub &&
93 git diff >actual &&
94 test_cmp expect.withsub actual
95'
96
97
98
2b459b48 99test_done