]>
Commit | Line | Data |
---|---|---|
1c3e5c4e AR |
1 | #!/bin/sh |
2 | ||
3 | test_description='Basic subproject functionality' | |
9081a421 ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
1c3e5c4e AR |
6 | . ./test-lib.sh |
7 | ||
5e113622 RR |
8 | test_expect_success 'setup: create superproject' ' |
9 | : >Makefile && | |
10 | git add Makefile && | |
11 | git commit -m "Superproject created" | |
12 | ' | |
13 | ||
14 | test_expect_success 'setup: create subprojects' ' | |
15 | mkdir sub1 && | |
16 | ( cd sub1 && git init && : >Makefile && git add * && | |
17 | git commit -q -m "subproject 1" ) && | |
18 | mkdir sub2 && | |
19 | ( cd sub2 && git init && : >Makefile && git add * && | |
20 | git commit -q -m "subproject 2" ) && | |
21 | git update-index --add sub1 && | |
22 | git add sub2 && | |
23 | git commit -q -m "subprojects added" && | |
a2cd709d | 24 | GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current && |
5e113622 RR |
25 | git branch save HEAD && |
26 | cat >expected <<-\EOF && | |
27 | :000000 160000 00000... A sub1 | |
28 | :000000 160000 00000... A sub2 | |
29 | EOF | |
30 | test_cmp expected current | |
31 | ' | |
32 | ||
33 | test_expect_success 'check if fsck ignores the subprojects' ' | |
34 | git fsck --full | |
35 | ' | |
36 | ||
37 | test_expect_success 'check if commit in a subproject detected' ' | |
38 | ( cd sub1 && | |
39 | echo "all:" >>Makefile && | |
40 | echo " true" >>Makefile && | |
41 | git commit -q -a -m "make all" ) && | |
42 | test_expect_code 1 git diff-files --exit-code | |
43 | ' | |
44 | ||
45 | test_expect_success 'check if a changed subproject HEAD can be committed' ' | |
46 | git commit -q -a -m "sub1 changed" && | |
47 | test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD | |
48 | ' | |
49 | ||
50 | test_expect_success 'check if diff-index works for subproject elements' ' | |
51 | test_expect_code 1 git diff-index --exit-code --cached save -- sub1 | |
52 | ' | |
53 | ||
54 | test_expect_success 'check if diff-tree works for subproject elements' ' | |
55 | test_expect_code 1 git diff-tree --exit-code HEAD^ HEAD -- sub1 | |
56 | ' | |
57 | ||
58 | test_expect_success 'check if git diff works for subproject elements' ' | |
59 | test_expect_code 1 git diff --exit-code HEAD^ HEAD | |
60 | ' | |
61 | ||
62 | test_expect_success 'check if clone works' ' | |
63 | git ls-files -s >expected && | |
64 | git clone -l -s . cloned && | |
65 | ( cd cloned && git ls-files -s ) >current && | |
66 | test_cmp expected current | |
67 | ' | |
68 | ||
69 | test_expect_success 'removing and adding subproject' ' | |
70 | git update-index --force-remove -- sub2 && | |
71 | mv sub2 sub3 && | |
72 | git add sub3 && | |
73 | git commit -q -m "renaming a subproject" && | |
74 | test_expect_code 1 git diff -M --name-status --exit-code HEAD^ HEAD | |
75 | ' | |
1c3e5c4e AR |
76 | |
77 | # the index must contain the object name the HEAD of the | |
78 | # subproject sub1 was at the point "save" | |
5e113622 RR |
79 | test_expect_success 'checkout in superproject' ' |
80 | git checkout save && | |
81 | git diff-index --exit-code --raw --cached save -- sub1 | |
82 | ' | |
1c3e5c4e | 83 | |
1c3e5c4e | 84 | test_done |