Skip to content

Commit

Permalink
Merge branch 'sb/submodule-module-list-pathspec-fix'
Browse files Browse the repository at this point in the history
A fix for a small regression in "module_list" helper that was
rewritten in C (also applies to 2.7.x).

* sb/submodule-module-list-pathspec-fix:
  submodule: fix regression for deinit without submodules
  • Loading branch information
Junio C Hamano committed Mar 24, 2016
2 parents 7e4ba36 + 84ba959 commit 2a4c8c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions builtin/submodule--helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ static int module_list_compute(int argc, const char **argv,
for (i = 0; i < active_nr; i++) {
const struct cache_entry *ce = active_cache[i];

if (!S_ISGITLINK(ce->ce_mode) ||
!match_pathspec(pathspec, ce->name, ce_namelen(ce),
0, ps_matched, 1))
if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
0, ps_matched, 1) ||
!S_ISGITLINK(ce->ce_mode))
continue;

ALLOC_GROW(list->entries, list->nr + 1, list->alloc);
Expand Down
13 changes: 13 additions & 0 deletions t/t7400-submodule-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,19 @@ test_expect_success 'set up a second submodule' '
git commit -m "submodule example2 added"
'

test_expect_success 'submodule deinit works on repository without submodules' '
test_when_finished "rm -rf newdirectory" &&
mkdir newdirectory &&
(
cd newdirectory &&
git init &&
>file &&
git add file &&
git commit -m "repo should not be empty"
git submodule deinit .
)
'

test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '
git config submodule.example.foo bar &&
git config submodule.example2.frotz nitfol &&
Expand Down

0 comments on commit 2a4c8c3

Please sign in to comment.