# -add an entry to .gitmodules for submodule 'example'
#
test_expect_success 'Prepare submodule testing' '
+ : > t &&
+ git-add t &&
+ git-commit -m "initial commit" &&
+ git branch initial HEAD &&
mkdir lib &&
cd lib &&
git init &&
git-submodule --cached status | grep "^+$rev1"
'
+test_expect_success 'git diff should report the SHA1 of the new submodule commit' '
+ git-diff | grep "^+Subproject commit $rev2"
+'
+
test_expect_success 'update should checkout rev1' '
git-submodule update &&
head=$(cd lib && git rev-parse HEAD) &&
git-submodule status | grep "^ $rev1"
'
+test_expect_success 'checkout superproject with subproject already present' '
+ git-checkout initial &&
+ git-checkout master
+'
+
+test_expect_success 'apply submodule diff' '
+ git branch second &&
+ (
+ cd lib &&
+ echo s >s &&
+ git add s &&
+ git commit -m "change subproject"
+ ) &&
+ git update-index --add lib &&
+ git-commit -m "change lib" &&
+ git-format-patch -1 --stdout >P.diff &&
+ git checkout second &&
+ git apply --index P.diff &&
+ D=$(git diff --cached master) &&
+ test -z "$D"
+'
+
test_done