submodule: check for NULL return of get_submodule_ref_store()
If we can't find a ref store for a submodule then assume the latter is not initialized (or was removed). Print a status line accordingly instead of causing a segmentation fault by passing NULL as the first parameter of refs_head_ref(). Reported-by: Jeremy Feusi <jeremy@feusi.co> Reviewed-by: Stefan Beller <sbeller@google.com> Initial-Test-By: Stefan Beller <sbeller@google.com> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
d32eb83c1d
commit
74b6bda32f
@ -620,9 +620,13 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
|
|||||||
displaypath);
|
displaypath);
|
||||||
} else if (!(flags & OPT_CACHED)) {
|
} else if (!(flags & OPT_CACHED)) {
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
|
struct ref_store *refs = get_submodule_ref_store(path);
|
||||||
|
|
||||||
if (refs_head_ref(get_submodule_ref_store(path),
|
if (!refs) {
|
||||||
handle_submodule_head_ref, &oid))
|
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 "
|
die(_("could not resolve HEAD ref inside the "
|
||||||
"submodule '%s'"), path);
|
"submodule '%s'"), path);
|
||||||
|
|
||||||
|
@ -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' '
|
test_expect_success 'submodule add --name allows to replace a submodule with another at the same path' '
|
||||||
(
|
(
|
||||||
cd addtest2 &&
|
cd addtest2 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user