From bef3894847118ab8c8668ddc90fa238ae9e05baa Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 2 Apr 2009 15:30:25 +0200 Subject: [PATCH] Fix 'git checkout ' to update the index While 'git checkout ' 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 [] ', too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-checkout.c | 3 --- t/t2013-checkout-submodule.sh | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 t/t2013-checkout-submodule.sh diff --git a/builtin-checkout.c b/builtin-checkout.c index 20b34ce6e..c0abe1ca7 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 000000000..fda3f0af7 --- /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 " 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 " 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 -- 2.30.2