submodule.c: submodule_move_head works with broken submodules
commitf2d48994dc11ba367e92c38c8025c3354418145a
authorStefan Beller <sbeller@google.com>
Tue, 18 Apr 2017 21:37:24 +0000 (18 14:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 19 Apr 2017 04:18:29 +0000 (18 21:18 -0700)
tree79932f90bd20e02046b0a881b92604a55573ff3b
parent823bab09c68b4048e433ab48b9185302c2f4b63a
submodule.c: submodule_move_head works with broken submodules

Early on in submodule_move_head just after the check if the submodule is
initialized, we need to check if the submodule is populated correctly.

If the submodule is initialized but doesn't look like it is populated,
this is a red flag and can indicate multiple sorts of failures:
(1) The submodule may be recorded at an object name, that is missing.
(2) The submodule '.git' file link may be broken and it is not pointing
    at a repository.

In both cases we want to complain to the user in the non-forced mode,
and in the forced mode ignoring the old state and just moving the
submodule into its new state with a fixed '.git' file link.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
submodule.c
t/lib-submodule-update.sh