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