The eleventh batch
[git/gitster.git] / t / t3040-subprojects-basic.sh
blobbd65dfcffc7b80e6dceb1603a189d07ab0d4b0b3
1 #!/bin/sh
3 test_description='Basic subproject functionality'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup: create superproject' '
9 : >Makefile &&
10 git add Makefile &&
11 git commit -m "Superproject created"
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" &&
24 GIT_PRINT_SHA1_ELLIPSIS="yes" git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
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
33 test_expect_success 'check if fsck ignores the subprojects' '
34 git fsck --full
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
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
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
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
58 test_expect_success 'check if git diff works for subproject elements' '
59 test_expect_code 1 git diff --exit-code HEAD^ HEAD
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
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
77 # the index must contain the object name the HEAD of the
78 # subproject sub1 was at the point "save"
79 test_expect_success 'checkout in superproject' '
80 git checkout save &&
81 git diff-index --exit-code --raw --cached save -- sub1
84 test_done