mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
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>
This commit is contained in:
parent
7634817871
commit
bef3894847
|
@ -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;
|
||||
|
||||
|
|
42
t/t2013-checkout-submodule.sh
Executable file
42
t/t2013-checkout-submodule.sh
Executable file
|
@ -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
|
Loading…
Reference in a new issue