summaryrefslogtreecommitdiff
path: root/t/t2013-checkout-submodule.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2009-04-02 13:30:25 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-04-02 20:16:42 (GMT)
commitbef3894847118ab8c8668ddc90fa238ae9e05baa (patch)
treecc0f8e7e6a15179d61c83cfbaca53db380a35ad0 /t/t2013-checkout-submodule.sh
parent763481787174adfcc247d6044bea330edcb2cc24 (diff)
downloadgit-bef3894847118ab8c8668ddc90fa238ae9e05baa.zip
git-bef3894847118ab8c8668ddc90fa238ae9e05baa.tar.gz
git-bef3894847118ab8c8668ddc90fa238ae9e05baa.tar.bz2
Fix 'git checkout <submodule>' to update the index
While 'git checkout <submodule>' should not update the submodule's working directory, it should update the index. This is in line with how submodules are handled in the rest of Git. While at it, test 'git reset [<commit>] <submodule>', too. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2013-checkout-submodule.sh')
-rwxr-xr-xt/t2013-checkout-submodule.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh
new file mode 100755
index 0000000..fda3f0a
--- /dev/null
+++ b/t/t2013-checkout-submodule.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='checkout can handle submodules'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ mkdir submodule &&
+ (cd submodule &&
+ git init &&
+ test_commit first) &&
+ git add submodule &&
+ test_tick &&
+ git commit -m superproject &&
+ (cd submodule &&
+ test_commit second) &&
+ git add submodule &&
+ test_tick &&
+ git commit -m updated.superproject
+'
+
+test_expect_success '"reset <submodule>" updates the index' '
+ git update-index --refresh &&
+ git diff-files --quiet &&
+ git diff-index --quiet --cached HEAD &&
+ test_must_fail git reset HEAD^ submodule &&
+ test_must_fail git diff-files --quiet &&
+ git reset submodule &&
+ git diff-files --quiet
+'
+
+test_expect_success '"checkout <submodule>" updates the index only' '
+ git update-index --refresh &&
+ git diff-files --quiet &&
+ git diff-index --quiet --cached HEAD &&
+ git checkout HEAD^ submodule &&
+ test_must_fail git diff-files --quiet &&
+ git checkout HEAD submodule &&
+ git diff-files --quiet
+'
+
+test_done