Skip to content

Commit

Permalink
Merge branch 'js/maint-submodule-checkout' into maint
Browse files Browse the repository at this point in the history
* js/maint-submodule-checkout:
  Fix 'git checkout <submodule>' to update the index
  • Loading branch information
Junio C Hamano committed Apr 18, 2009
2 parents eb8a1c4 + bef3894 commit f392485
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
3 changes: 0 additions & 3 deletions builtin-checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
42 changes: 42 additions & 0 deletions t/t2013-checkout-submodule.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f392485

Please sign in to comment.