submodule--helper: advise on fatal alternate error
commit4f3e57ef13d0ad4c00d0a87f0858cde81456a2e0
authorJonathan Tan <jonathantanmy@google.com>
Mon, 2 Dec 2019 19:57:52 +0000 (2 11:57 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Dec 2019 16:49:45 +0000 (3 08:49 -0800)
treecb86a3bd9dcb28f554950037e5f8f10acac393bf
parent10c64a0b3c15391180c31d1217ba01d687558757
submodule--helper: advise on fatal alternate error

When recursively cloning a superproject with some shallow modules
defined in its .gitmodules, then recloning with "--reference=<path>", an
error occurs. For example:

  git clone --recurse-submodules --branch=master -j8 \
    https://android.googlesource.com/platform/superproject \
    master
  git clone --recurse-submodules --branch=master -j8 \
    https://android.googlesource.com/platform/superproject \
    --reference master master2

fails with:

  fatal: submodule '<snip>' cannot add alternate: reference repository
  '<snip>' is shallow

When a alternate computed from the superproject's alternate cannot be
added, whether in this case or another, advise about configuring the
"submodule.alternateErrorStrategy" configuration option and using
"--reference-if-able" instead of "--reference" when cloning.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/advice.txt
advice.c
advice.h
builtin/submodule--helper.c