Skip to content

Commit 93d0892

Browse files
committed
Merge branch 'dt/submodule-rm-with-stale-cache' into maint
Running "git rm" on a submodule failed unnecessarily when .gitmodules is only cache-dirty, which has been corrected. * dt/submodule-rm-with-stale-cache: git rm submodule: succeed if .gitmodules index stat info is zero
2 parents dae4777 + 7edee32 commit 93d0892

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int is_staging_gitmodules_ok(struct index_state *istate)
8282
if ((pos >= 0) && (pos < istate->cache_nr)) {
8383
struct stat st;
8484
if (lstat(GITMODULES_FILE, &st) == 0 &&
85-
ie_match_stat(istate, istate->cache[pos], &st, 0) & DATA_CHANGED)
85+
ie_modified(istate, istate->cache[pos], &st, 0) & DATA_CHANGED)
8686
return 0;
8787
}
8888

t/t3600-rm.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta
425425
git status -s -uno >actual &&
426426
test_cmp expect actual
427427
'
428+
test_expect_success 'rm will not error out on .gitmodules file with zero stat data' '
429+
git reset --hard &&
430+
git submodule update &&
431+
git read-tree HEAD &&
432+
git rm submod &&
433+
test_path_is_missing submod
434+
'
428435

429436
test_expect_success 'rm issues a warning when section is not found in .gitmodules' '
430437
git reset --hard &&

0 commit comments

Comments
 (0)