Skip to content

Commit 2a4c8c3

Browse files
committed
Merge branch 'sb/submodule-module-list-pathspec-fix'
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
2 parents 7e4ba36 + 84ba959 commit 2a4c8c3

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

builtin/submodule--helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ static int module_list_compute(int argc, const char **argv,
3737
for (i = 0; i < active_nr; i++) {
3838
const struct cache_entry *ce = active_cache[i];
3939

40-
if (!S_ISGITLINK(ce->ce_mode) ||
41-
!match_pathspec(pathspec, ce->name, ce_namelen(ce),
42-
0, ps_matched, 1))
40+
if (!match_pathspec(pathspec, ce->name, ce_namelen(ce),
41+
0, ps_matched, 1) ||
42+
!S_ISGITLINK(ce->ce_mode))
4343
continue;
4444

4545
ALLOC_GROW(list->entries, list->nr + 1, list->alloc);

t/t7400-submodule-basic.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,19 @@ test_expect_success 'set up a second submodule' '
849849
git commit -m "submodule example2 added"
850850
'
851851

852+
test_expect_success 'submodule deinit works on repository without submodules' '
853+
test_when_finished "rm -rf newdirectory" &&
854+
mkdir newdirectory &&
855+
(
856+
cd newdirectory &&
857+
git init &&
858+
>file &&
859+
git add file &&
860+
git commit -m "repo should not be empty"
861+
git submodule deinit .
862+
)
863+
'
864+
852865
test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '
853866
git config submodule.example.foo bar &&
854867
git config submodule.example2.frotz nitfol &&

0 commit comments

Comments
 (0)