summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2016-03-24 12:27:12 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-03-24 12:27:13 -0700
commit2a4c8c36a7f6ad3520c0702f31dc7cff5176f1be (patch)
tree880686fbe5731690e0e81400c2be8fd5c418a4f4
parentMerge branch 'master' of git://github.com/git-l10n/git-po (diff)
parentsubmodule: fix regression for deinit without submodules (diff)
downloadtgif-2a4c8c36a7f6ad3520c0702f31dc7cff5176f1be.tar.xz
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
-rw-r--r--builtin/submodule--helper.c6
-rwxr-xr-xt/t7400-submodule-basic.sh13
2 files changed, 16 insertions, 3 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index ed764c9f0e..5295b727d4 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -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);
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index be82a75e54..e1abd19230 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -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 &&