1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 12:59:41 +01:00

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
This commit is contained in:
Junio C Hamano 2020-03-17 15:02:21 -07:00
commit 93d0892891
2 changed files with 8 additions and 1 deletions

View file

@ -82,7 +82,7 @@ int is_staging_gitmodules_ok(struct index_state *istate)
if ((pos >= 0) && (pos < istate->cache_nr)) {
struct stat st;
if (lstat(GITMODULES_FILE, &st) == 0 &&
ie_match_stat(istate, istate->cache[pos], &st, 0) & DATA_CHANGED)
ie_modified(istate, istate->cache[pos], &st, 0) & DATA_CHANGED)
return 0;
}

View file

@ -425,6 +425,13 @@ test_expect_success 'rm will error out on a modified .gitmodules file unless sta
git status -s -uno >actual &&
test_cmp expect actual
'
test_expect_success 'rm will not error out on .gitmodules file with zero stat data' '
git reset --hard &&
git submodule update &&
git read-tree HEAD &&
git rm submod &&
test_path_is_missing submod
'
test_expect_success 'rm issues a warning when section is not found in .gitmodules' '
git reset --hard &&