From patchwork Mon Dec 2 19:57:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11269867 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 E3FC06C1 for ; Mon, 2 Dec 2019 19:58:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C274E20833 for ; Mon, 2 Dec 2019 19:58:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oOiVGN1Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbfLBT6B (ORCPT ); Mon, 2 Dec 2019 14:58:01 -0500 Received: from mail-pf1-f202.google.com ([209.85.210.202]:41378 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727927AbfLBT6A (ORCPT ); Mon, 2 Dec 2019 14:58:00 -0500 Received: by mail-pf1-f202.google.com with SMTP id x6so510316pfx.8 for ; Mon, 02 Dec 2019 11:58:00 -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=oH0BzhA4j3deiaqXsxtU9TOc1dj4ztjW0UuPMW1CofY=; b=oOiVGN1ZxVvL+4db1aRbj8cBN4Fc37yf0uOMeTVXQfR5+H0EV8lGm7EqaJyJuXSWJa e1uAEhE0Qd170DAG6u4QUIbiSgRGQnaMcGD3Ylx6IdNYBRrM21TTdqE8Vn0GBPWdPARK hSFyR/W4mAdLqCW4uD2j+GC8AyL0n99MDXoeghv+pN+PUgGPp5ROnARhMsK8OgZHND/l Mdtc2//R7L15ZwoqbmQJXj2M0gxeegrMv4MzIIoXferJ/nM/RS9GL+qN00Rtc/m3NHxS A/9tsYMFxuKgM+zuZUnFCQocZpB1bpPA0lYtrQfp4ku6lK/J6RkPDJQo79Cct/IW3aCn eIGQ== 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=oH0BzhA4j3deiaqXsxtU9TOc1dj4ztjW0UuPMW1CofY=; b=jadwQ89n5tDFaJkoCTLgk83SN2dEFWqM3LPXAZLdID8x4Nv9Tsda8b3JP1p54HZHI/ kXKHyQaOREc6UUwf9E2qKzyY8ez5oZS5Y+RJazOE2zAEV3i3qhKmmNUaI2IRUHTCpXxN TKTsAqAFCH8+pOkI3AXH5sOLfyqcsBKao2CDsRssVsvqogVqIHYS3ndQmBSYbdjR9DU1 VmwQ0DdXgNZIuA9mtklwcGeZ6nL1YOr8NP2VXtj3hScj0svnWRYVHQfUCW3avqD7A7+U 0uBje9jY6yIIRNyou/ULGS58IDrXb7Xwa16FVVkQc2JY2SLdvxJQ9j19X6WFJMRMWCfs WCEw== X-Gm-Message-State: APjAAAUuNiq38Cj3fU9gixumG133pkgO7cOrbZNKiwAs7b5ChYfkQVkJ hC0gEEpTSj6vtOasIViNKZcl2qDtlgXukhytiNfdHQbdGbA6KuXxGJcKLXELL4H39HS8TmUqBB3 ilGNU5wQInS+BWmkXZQSPX9GyUGxradQtAfSlns/mwk9S1BQRTE+GXPZPArMec9RtRbLBB57lYF rH X-Google-Smtp-Source: APXvYqxLk4KmFNuq1oRoOfxaCo7HnQEaUsy82yo+lDsZYI3mG88YepBzctDlrSESxmU9fBICcqr+n4eptEFpC+2rqGb9 X-Received: by 2002:a63:1013:: with SMTP id f19mr834629pgl.289.1575316679707; Mon, 02 Dec 2019 11:57:59 -0800 (PST) Date: Mon, 2 Dec 2019 11:57:51 -0800 In-Reply-To: Message-Id: <6de0eeac4ca2a3b5c35ad1ffaaa436ebbef3a27c.1575316490.git.jonathantanmy@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog Subject: [PATCH v2 1/2] Doc: explain submodule.alternateErrorStrategy From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , peff@peff.net, gitster@pobox.com 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 --- 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 Mon Dec 2 19:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Tan X-Patchwork-Id: 11269871 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 39604921 for ; Mon, 2 Dec 2019 19:58:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 176E7206E4 for ; Mon, 2 Dec 2019 19:58:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="A5tA9yGb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728081AbfLBT6F (ORCPT ); Mon, 2 Dec 2019 14:58:05 -0500 Received: from mail-pf1-f201.google.com ([209.85.210.201]:53087 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727927AbfLBT6E (ORCPT ); Mon, 2 Dec 2019 14:58:04 -0500 Received: by mail-pf1-f201.google.com with SMTP id f20so495587pfn.19 for ; Mon, 02 Dec 2019 11:58:02 -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=8sFz/JY51jyqsOn2Eqwxq77LNldC4AQN/WSY8Seax5Q=; b=A5tA9yGbD1vpDIKC/Wl1cum/ecwCF2+oxqktMa366Fnis8Ts6tm0aDXBlHH9eakeej aKGz/gY90k7RzOZwRsgEZGdP4mKTl3iGES/8nHIxNxNw+2qN9Ir58YMuLgahxB9ETacd +JZFt3a0XjpIFAY87SIe4HDB0K6zdhSf3yNJeY3Eg8s+kIjj0hwRaYDRIb4pibLHzPNJ k3oKfRJy4zdAsjPPHlLPtwIG/8cNqmcEkYEvOhHx2i0SqMteLRTjSTv9wDmUnarHXppY jtL3AYskby75Go/kBOFpkaV2I9OpbEt7RP9Xj3HG79nxus01LJ9fZo33kMw+fYC0cl/Z 5kPw== 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=8sFz/JY51jyqsOn2Eqwxq77LNldC4AQN/WSY8Seax5Q=; b=oIepKy6gGAbFPLwb2PB623C88B13auxEFIPp7VvYI2UuW8jzCOder7Qu+Y7/7AMJS1 MZEFtuOD8lZwS1iK+thPer6ACtPV7wGunwzTL6ROdE33dBGbq/8wRXNvj/LJNYpmYyb4 Ax8pEW7ioUBncWMECy3dVgDU02gZWDBZZRv7frVlyOIM2xEX3EHCyRIgg1vjjgnMGkw0 LaetP53AgUSG5XHXAiliHr/a14+lBp3qwutUzOv6sveSgqszF3aa6+0J93enNqv69eXc Xn5wtSQuf8FjRHQ5l9sfNG1XJ4ur7W7Yem/aZxf/yFO1DAIwIyRxKt7JZI3T0F02xsOn UG6g== X-Gm-Message-State: APjAAAX/LTcVuS6YO0pJ67w1+Ooh2gpCbORoJc6g0I6BZPNevYMgMWPX P42qQspw8owvDI5sDqJS5UtylW+ETdQ8HSHaDfkpg0jQi+s84v9urrwGIB6fIx6DFR3sVc9dU9F T7CQe9Ms6W/2M1bkgOvBULo2Sd2a3eCDZ89u1BKhfjuBChU1PTfxegU4mWne2aqqIA4hfx99aDM BF X-Google-Smtp-Source: APXvYqwog7P9BPWsTN2QeCFjwy4UPLdgWRKmePTn92EGOeCY8s0csITdHOwoarvoX71eUH18FuEHSANoXYDqDfd5MI9F X-Received: by 2002:a63:b22:: with SMTP id 34mr917485pgl.90.1575316682360; Mon, 02 Dec 2019 11:58:02 -0800 (PST) Date: Mon, 2 Dec 2019 11:57:52 -0800 In-Reply-To: Message-Id: <4f2182aa26b3da1fb80700e67f81e721778ea046.1575316490.git.jonathantanmy@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog Subject: [PATCH v2 2/2] submodule--helper: advise on fatal alternate error From: Jonathan Tan To: git@vger.kernel.org Cc: Jonathan Tan , peff@peff.net, gitster@pobox.com 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..12d546dfbb 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,13 @@ struct submodule_alternate_setup { #define SUBMODULE_ALTERNATE_SETUP_INIT { NULL, \ SUBMODULE_ALTERNATE_ERROR_IGNORE, NULL } +static const char alternate_error_advice[] = N_( +"An alternate computed from a superproject's alternate is invalid.\n" +"To allow Git to clone without an alternate in such a case, set\n" +"submodule.alternateErrorStrategy to 'info' or, equivalently, clone with\n" +"'--reference-if-able' instead of '--reference'." +); + static int add_possible_reference_from_superproject( struct object_directory *odb, void *sas_cb) { @@ -1299,6 +1307,8 @@ static int add_possible_reference_from_superproject( } else { switch (sas->error_mode) { case SUBMODULE_ALTERNATE_ERROR_DIE: + if (advice_submodule_alternate_error_strategy_die) + advise(_(alternate_error_advice)); die(_("submodule '%s' cannot add alternate: %s"), sas->submodule_name, err.buf); case SUBMODULE_ALTERNATE_ERROR_INFO: