summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-04-08 05:33:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-04-08 05:33:02 (GMT)
commita9906723b23b058cffadaf5db9d87b67384c60c3 (patch)
tree2f84e6ebe8c98a1cbcd699ee7504e7151d56e9f0
parent2149e0f6a66cb4a5707ef6201763051d94f288af (diff)
parentbef3894847118ab8c8668ddc90fa238ae9e05baa (diff)
downloadgit-a9906723b23b058cffadaf5db9d87b67384c60c3.zip
git-a9906723b23b058cffadaf5db9d87b67384c60c3.tar.gz
git-a9906723b23b058cffadaf5db9d87b67384c60c3.tar.bz2
Merge branch 'js/maint-submodule-checkout'
* js/maint-submodule-checkout: Fix 'git checkout <submodule>' to update the index
-rw-r--r--builtin-checkout.c3
-rwxr-xr-xt/t2013-checkout-submodule.sh42
2 files changed, 42 insertions, 3 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 33d1fec..2e4fe1a 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -53,9 +53,6 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
int len;
struct cache_entry *ce;
- if (S_ISGITLINK(mode))
- return 0;
-
if (S_ISDIR(mode))
return READ_TREE_RECURSIVE;
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