From patchwork Tue Nov 26 01:30:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11261331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5999112B for ; Tue, 26 Nov 2019 01:32:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A681A20835 for ; Tue, 26 Nov 2019 01:32:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kiowghsA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbfKZBbJ (ORCPT ); Mon, 25 Nov 2019 20:31:09 -0500 Received: from mail-pg1-f202.google.com ([209.85.215.202]:49183 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfKZBbJ (ORCPT ); Mon, 25 Nov 2019 20:31:09 -0500 Received: by mail-pg1-f202.google.com with SMTP id 14so9817320pgv.16 for ; Mon, 25 Nov 2019 17:31:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=eQNDez1mOSd2R3G90VGNMqKOdhiI0ECZgbVvcZVWfl8=; b=kiowghsAqMVZNFZjK56XvRKTGFh2SoUtBd6EWHon9A0aYHgOJ0ehl2h9xIO2oncMBt PbITeM5sBoZuAdKs+PVUK14Llgba+7Mul+cvh9+k781uX9Bs1iufZef2EaV5tusY/SYF a4Y/A7HbIrB6GVRn0tEilZMlMaHwsKg0JzaIbmdUhjtK8sZcKw56RVI0wU+DIxchets9 PU5JhfO32D/4tI2WPNvFIHQW/co78m60kFWVuOZchdtLMuhq2FuVDZLJlOc+lLO6E30W SmQGsHTNDoSt6k1BB1fW7uJV9Ng6mhc6+LoTa1PztukQwRZJKPbshyhiV3MdIMNpAXLM fT1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=eQNDez1mOSd2R3G90VGNMqKOdhiI0ECZgbVvcZVWfl8=; b=I6dHHQJMT4GbXD4J++gZtl9SeO0EUZanMvFOCGuPeoH5ewycMWZT9vfCj9Vufhx4kF iB9C1csxQ9HXJvfKL3rrdhiOoidiOV0SqCMm2G2gapP5XBehamXPzLBeV4NmXr1Vuagu CnRuXsSOkuufQ5sNMGn3QIRlnURijxYVEtgOYqoRHWbjmq1HTI7EwfFHl4G+B6E3Jt8+ MlJMs4KfxvIJpeiahYm6JFb5L5u3UP7gFq3C6b508cF2KPQu7dh0Zt3/3h4Qo9dCd3kC 1NDG9WNKAuOvl0LSrIF5wCrO8G/xzpEh4tvTAXs+SEwo40GYpUjyiUC3XHzujexnev7o qJ+w== X-Gm-Message-State: APjAAAUW8H46Ml3YAbN/8FOkqCj559czw+g87P96qP4up0n0I0k05IdP 3kl3oC7/rF6+MmFZzfqQC0NHLzToli/NLlZiS7+equTDVTryBXa3ApXLiknwtvGM9YploBbB7i5 s5RtAdA/7bhUkd5wTgMBMWBCvNAkXIX6/pGnFKZ5nnKsggpWORUBensmfG26U2bNi96kpberCQ6 zW X-Google-Smtp-Source: APXvYqxVUz/NuUNsRvI130kJuQuhWtlbGmGeIfHhmVIZVR7mvPqiqgSR462DHFZfm9zXlQgI+hE4iz8aVDa3zvXt/f/z X-Received: by 2002:a63:e54f:: with SMTP id z15mr36719518pgj.453.1574731866906; Mon, 25 Nov 2019 17:31:06 -0800 (PST) Date: Mon, 25 Nov 2019 17:30:59 -0800 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH 1/2] Doc: explain submodule.alternateErrorStrategy From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Commit 31224cbdc7 ("clone: recursive and reference option triggers submodule alternates", 2016-08-17) taught Git to support the configuration options "submodule.alternateLocation" and "submodule.alternateErrorStrategy" on a superproject. If "submodule.alternateLocation" is configured to "superproject" on a superproject, whenever a submodule of that superproject is cloned, it instead computes the analogous alternate path for that submodule from $GIT_DIR/objects/info/alternates of the superproject, and references it. The "submodule.alternateErrorStrategy" option determines what happens if that alternate cannot be referenced. However, it is not clear that the clone proceeds as if no alternate was specified when that option is not set to "die" (as can be seen in the tests in 31224cbdc7). Therefore, document it accordingly. Signed-off-by: Jonathan Tan --- When I said "not clear" above, I mean that it is not clear *to me*, and I assume that others will feel the same way. Feel free to drop this from the patch set if the existing documentation is clear to most people. --- Documentation/config/submodule.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt index 0a1293b051..b33177151c 100644 --- a/Documentation/config/submodule.txt +++ b/Documentation/config/submodule.txt @@ -79,4 +79,6 @@ submodule.alternateLocation:: submodule.alternateErrorStrategy:: Specifies how to treat errors with the alternates for a submodule as computed via `submodule.alternateLocation`. Possible values are - `ignore`, `info`, `die`. Default is `die`. + `ignore`, `info`, `die`. Default is `die`. Note that if set to `ignore` + or `info`, and if there is an error with the computed alternate, the + clone proceeds as if no alternate was specified. From patchwork Tue Nov 26 01:31:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11261333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F12C317F0 for ; Tue, 26 Nov 2019 01:32:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEE8C2082F for ; Tue, 26 Nov 2019 01:32:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TJhOu+KS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726980AbfKZBbL (ORCPT ); Mon, 25 Nov 2019 20:31:11 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:53371 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfKZBbL (ORCPT ); Mon, 25 Nov 2019 20:31:11 -0500 Received: by mail-pf1-f202.google.com with SMTP id h2so10891005pfr.20 for ; Mon, 25 Nov 2019 17:31:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=aG3hoyBPa5gqigAjXPDQq8Bb6NO//R6ASZ/lLq8yukA=; b=TJhOu+KSUPVvkpCbTXJLhewsauswYCxQ0YF+Hr1uys6ZYnd7bD3Aupi7TzGynqZi87 djlo6vS4mmirCkaDkavHnIi8sErN1zb5OYZXiQmoqWqFSM+HMGlpAFymuPrw825CA0HX N5DhCvzo+WDYzsgDo9q3A1o/z/snnlXi3kNsN7g8V50VcFl7L950HAHS/awlyVhgY/ch nwkfYuXziDnLdLBijhv2u34StzKs/b0MhtE3pUDyGQiaE/KD8avbZDL9WMeW7uQ/DbaM NV3LigmD0UrGLBT3xGiBwrF0BwM0tqGKOUuAC6lT4+a8ALYZ5CWywb86F2l3SGEvQmMs EkXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=aG3hoyBPa5gqigAjXPDQq8Bb6NO//R6ASZ/lLq8yukA=; b=sJP2LrDftfwnV/7K/hxCr5aSwJg3vnbEL8K1lXuQrsA+0VoPghIIx1yaI/I522t10g XxpdElrRglYimOk+XrcwfY6M0P38QydUm94Qaemr9zUbWVngEv6lhs8L42szeRHbZS92 5LY6WLQhW/J4zDzWodaosGn4EZGQotabhNeY8eBM0HegpNifyTpD8OB1ggvToDH2Le4C ok7J13wwxEiKS2zNJY1stm9FSoIjPDTLuqSb8bC8FgV9dT4BFXZ3nu3eTrD7b21MMwT6 99p12+tUw3tpfDgOdG0ohEth9YSw3sK4b3U8ZcPkP1Q9tXi9RyqaqsygPg3e/RhtAdAD f6Dw== X-Gm-Message-State: APjAAAVZ5fiirht4sSIPqxkazLBX0wGcqTryQ98xDCtuBgeuOMDP0GKz 5kvLbtxic2ptFoDWP08qgnoD0L+Jp1KpUn6xlRbg7juz8+UAv2HwZU/vBJYtci13vKGKbL0gs2f SlNnBxPGjDapt5P1shIgnFs2JX7mvXICbo6XeU3as+VcH9/fogRQx3Kol/L+sCJjYSEifIJ9rfQ 83 X-Google-Smtp-Source: APXvYqyP+dC+k2RqrrSB1zyUAcF77DKW/QdOjEQ5qQPt+u8sb8FJ9HDbW9G5crhlxuGy2n78+GemFUorkpWFxvfId3D/ X-Received: by 2002:a63:4b03:: with SMTP id y3mr34950752pga.155.1574731869433; Mon, 25 Nov 2019 17:31:09 -0800 (PST) Date: Mon, 25 Nov 2019 17:31:00 -0800 In-Reply-To: Message-Id: <26c3b388a24eef7f03eb423c10e21430bc3f019e.1574731649.git.jonathantanmy@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.24.0.432.g9d3f5f5b63-goog Subject: [PATCH 2/2] submodule--helper: advise on fatal alternate error From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When recursively cloning a superproject with some shallow modules defined in its .gitmodules, then recloning with "--reference=", 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 '' cannot add alternate: reference repository '' 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 --- Documentation/config/advice.txt | 3 +++ advice.c | 2 ++ advice.h | 1 + builtin/submodule--helper.c | 10 ++++++++++ 4 files changed, 16 insertions(+) diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt index 6aaa360202..d4e698cd3f 100644 --- a/Documentation/config/advice.txt +++ b/Documentation/config/advice.txt @@ -107,4 +107,7 @@ advice.*:: editor input from the user. nestedTag:: Advice shown if a user attempts to recursively tag a tag object. + submoduleAlternateErrorStrategyDie: + Advice shown when a submodule.alternateErrorStrategy option + configured to "die" causes a fatal error. -- diff --git a/advice.c b/advice.c index 3ee0ee2d8f..249c60dcf3 100644 --- a/advice.c +++ b/advice.c @@ -30,6 +30,7 @@ int advice_waiting_for_editor = 1; int advice_graft_file_deprecated = 1; int advice_checkout_ambiguous_remote_branch_name = 1; int advice_nested_tag = 1; +int advice_submodule_alternate_error_strategy_die = 1; static int advice_use_color = -1; static char advice_colors[][COLOR_MAXLEN] = { @@ -89,6 +90,7 @@ static struct { { "graftFileDeprecated", &advice_graft_file_deprecated }, { "checkoutAmbiguousRemoteBranchName", &advice_checkout_ambiguous_remote_branch_name }, { "nestedTag", &advice_nested_tag }, + { "submoduleAlternateErrorStrategyDie", &advice_submodule_alternate_error_strategy_die }, /* make this an alias for backward compatibility */ { "pushNonFastForward", &advice_push_update_rejected } diff --git a/advice.h b/advice.h index d015404843..b706780614 100644 --- a/advice.h +++ b/advice.h @@ -30,6 +30,7 @@ extern int advice_waiting_for_editor; extern int advice_graft_file_deprecated; extern int advice_checkout_ambiguous_remote_branch_name; extern int advice_nested_tag; +extern int advice_submodule_alternate_error_strategy_die; int git_default_advice_config(const char *var, const char *value); __attribute__((format (printf, 1, 2))) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 2c2395a620..bdfc46fdea 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -19,6 +19,7 @@ #include "diffcore.h" #include "diff.h" #include "object-store.h" +#include "advice.h" #define OPT_QUIET (1 << 0) #define OPT_CACHED (1 << 1) @@ -1268,6 +1269,14 @@ struct submodule_alternate_setup { #define SUBMODULE_ALTERNATE_SETUP_INIT { NULL, \ SUBMODULE_ALTERNATE_ERROR_IGNORE, NULL } +static void advise_submodule_alternate_error_die(void) +{ + if (!advice_submodule_alternate_error_strategy_die) + return; + advise(_("An alternate computed from a superproject's alternate is invalid.")); + advise(_("To allow Git to clone without an alternate in such a case, set submodule.alternateErrorStrategy to 'info' or, equivalently, clone with '--reference-if-able' instead of '--reference'.")); +} + static int add_possible_reference_from_superproject( struct object_directory *odb, void *sas_cb) { @@ -1299,6 +1308,7 @@ static int add_possible_reference_from_superproject( } else { switch (sas->error_mode) { case SUBMODULE_ALTERNATE_ERROR_DIE: + advise_submodule_alternate_error_die(); die(_("submodule '%s' cannot add alternate: %s"), sas->submodule_name, err.buf); case SUBMODULE_ALTERNATE_ERROR_INFO: