Browse Source

Merge branch 'rs/status-with-removed-submodule'

"git submodule status" misbehaved on a submodule that has been
removed from the working tree.

* rs/status-with-removed-submodule:
  submodule: check for NULL return of get_submodule_ref_store()
maint
Junio C Hamano 7 years ago
parent
commit
103251a318
  1. 8
      builtin/submodule--helper.c
  2. 15
      t/t7400-submodule-basic.sh

8
builtin/submodule--helper.c

@ -655,9 +655,13 @@ static void status_submodule(const char *path, const struct object_id *ce_oid, @@ -655,9 +655,13 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
displaypath);
} else if (!(flags & OPT_CACHED)) {
struct object_id oid;
struct ref_store *refs = get_submodule_ref_store(path);

if (refs_head_ref(get_submodule_ref_store(path),
handle_submodule_head_ref, &oid))
if (!refs) {
print_status(flags, '-', path, ce_oid, displaypath);
goto cleanup;
}
if (refs_head_ref(refs, handle_submodule_head_ref, &oid))
die(_("could not resolve HEAD ref inside the "
"submodule '%s'"), path);


15
t/t7400-submodule-basic.sh

@ -821,6 +821,21 @@ test_expect_success 'moving the superproject does not break submodules' ' @@ -821,6 +821,21 @@ test_expect_success 'moving the superproject does not break submodules' '
)
'

test_expect_success 'moving the submodule does not break the superproject' '
(
cd addtest2 &&
git submodule status
) >actual &&
sed -e "s/^ \([^ ]* repo\) .*/-\1/" <actual >expect &&
mv addtest2/repo addtest2/repo.bak &&
test_when_finished "mv addtest2/repo.bak addtest2/repo" &&
(
cd addtest2 &&
git submodule status
) >actual &&
test_cmp expect actual
'

test_expect_success 'submodule add --name allows to replace a submodule with another at the same path' '
(
cd addtest2 &&

Loading…
Cancel
Save