{"thread":{"id":"52339","subject":"[PATCH 0/2] Advice upon clone --recurse-submodules --reference","startedAt":"2019-11-26T01:31:19Z","lastAt":"2019-12-03T16:51:03Z","messageCount":11,"participants":["Jonathan Tan","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"387065","messageId":"cover.1574731649.git.jonathantanmy@google.com","threadId":"52339","inReplyTo":null,"subject":"[PATCH 0/2] Advice upon clone --recurse-submodules --reference","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-11-26T01:30:58Z","receivedAt":"2019-11-26T01:31:19Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"This patch set came about because of a situation in $DAY_JOB described\nin the commit message of patch 2. I found the existing documentation and\nerror messages unclear, so I have improved them.\n\nJonathan Tan (2):\n  Doc: explain submodule.alternateErrorStrategy\n  submodule--helper: advise on fatal alternate error\n\n Documentation/config/advice.txt    |  3 +++\n Documentation/config/submodule.txt |  4 +++-\n advice.c                           |  2 ++\n advice.h                           |  1 +\n builtin/submodule--helper.c        | 10 ++++++++++\n 5 files changed, 19 insertions(+), 1 deletion(-)\n\n-- \n2.24.0.432.g9d3f5f5b63-goog\n\n"},{"id":"387066","messageId":"a8125b946227d918865fde0dcbec516474b42386.1574731649.git.jonathantanmy@google.com","threadId":"52339","inReplyTo":"cover.1574731649.git.jonathantanmy@google.com","subject":"[PATCH 1/2] Doc: explain submodule.alternateErrorStrategy","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-11-26T01:30:59Z","receivedAt":"2019-11-26T01:31:19Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"Commit 31224cbdc7 (\"clone: recursive and reference option triggers\nsubmodule alternates\", 2016-08-17) taught Git to support the\nconfiguration options \"submodule.alternateLocation\" and\n\"submodule.alternateErrorStrategy\" on a superproject.\n\nIf \"submodule.alternateLocation\" is configured to \"superproject\" on a\nsuperproject, whenever a submodule of that superproject is cloned, it\ninstead computes the analogous alternate path for that submodule from\n$GIT_DIR/objects/info/alternates of the superproject, and references it.\n\nThe \"submodule.alternateErrorStrategy\" option determines what happens\nif that alternate cannot be referenced. However, it is not clear that\nthe clone proceeds as if no alternate was specified when that option is\nnot set to \"die\" (as can be seen in the tests in 31224cbdc7). Therefore,\ndocument it accordingly.\n\nSigned-off-by: Jonathan Tan <jonathantanmy@google.com>\n---\nWhen I said \"not clear\" above, I mean that it is not clear *to me*, and\nI assume that others will feel the same way. Feel free to drop this from\nthe patch set if the existing documentation is clear to most people.\n---\n Documentation/config/submodule.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt\nindex 0a1293b051..b33177151c 100644\n--- a/Documentation/config/submodule.txt\n+++ b/Documentation/config/submodule.txt\n@@ -79,4 +79,6 @@ submodule.alternateLocation::\n submodule.alternateErrorStrategy::\n \tSpecifies how to treat errors with the alternates for a submodule\n \tas computed via `submodule.alternateLocation`. Possible values are\n-\t`ignore`, `info`, `die`. Default is `die`.\n+\t`ignore`, `info`, `die`. Default is `die`. Note that if set to `ignore`\n+\tor `info`, and if there is an error with the computed alternate, the\n+\tclone proceeds as if no alternate was specified.\n-- \n2.24.0.432.g9d3f5f5b63-goog\n\n"},{"id":"387067","messageId":"26c3b388a24eef7f03eb423c10e21430bc3f019e.1574731649.git.jonathantanmy@google.com","threadId":"52339","inReplyTo":"cover.1574731649.git.jonathantanmy@google.com","subject":"[PATCH 2/2] submodule--helper: advise on fatal alternate error","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-11-26T01:31:00Z","receivedAt":"2019-11-26T01:31:19Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"When recursively cloning a superproject with some shallow modules\ndefined in its .gitmodules, then recloning with \"--reference=<path>\", an\nerror occurs. For example:\n\n  git clone --recurse-submodules --branch=master -j8 \\\n    https://android.googlesource.com/platform/superproject \\\n    master\n  git clone --recurse-submodules --branch=master -j8 \\\n    https://android.googlesource.com/platform/superproject \\\n    --reference master master2\n\nfails with:\n\n  fatal: submodule '<snip>' cannot add alternate: reference repository\n  '<snip>' is shallow\n\nWhen a alternate computed from the superproject's alternate cannot be\nadded, whether in this case or another, advise about configuring the\n\"submodule.alternateErrorStrategy\" configuration option and using\n\"--reference-if-able\" instead of \"--reference\" when cloning.\n\nSigned-off-by: Jonathan Tan <jonathantanmy@google.com>\n---\n Documentation/config/advice.txt |  3 +++\n advice.c                        |  2 ++\n advice.h                        |  1 +\n builtin/submodule--helper.c     | 10 ++++++++++\n 4 files changed, 16 insertions(+)\n\ndiff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt\nindex 6aaa360202..d4e698cd3f 100644\n--- a/Documentation/config/advice.txt\n+++ b/Documentation/config/advice.txt\n@@ -107,4 +107,7 @@ advice.*::\n \t\teditor input from the user.\n \tnestedTag::\n \t\tAdvice shown if a user attempts to recursively tag a tag object.\n+\tsubmoduleAlternateErrorStrategyDie:\n+\t\tAdvice shown when a submodule.alternateErrorStrategy option\n+\t\tconfigured to \"die\" causes a fatal error.\n --\ndiff --git a/advice.c b/advice.c\nindex 3ee0ee2d8f..249c60dcf3 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -30,6 +30,7 @@ int advice_waiting_for_editor = 1;\n int advice_graft_file_deprecated = 1;\n int advice_checkout_ambiguous_remote_branch_name = 1;\n int advice_nested_tag = 1;\n+int advice_submodule_alternate_error_strategy_die = 1;\n \n static int advice_use_color = -1;\n static char advice_colors[][COLOR_MAXLEN] = {\n@@ -89,6 +90,7 @@ static struct {\n \t{ \"graftFileDeprecated\", &advice_graft_file_deprecated },\n \t{ \"checkoutAmbiguousRemoteBranchName\", &advice_checkout_ambiguous_remote_branch_name },\n \t{ \"nestedTag\", &advice_nested_tag },\n+\t{ \"submoduleAlternateErrorStrategyDie\", &advice_submodule_alternate_error_strategy_die },\n \n \t/* make this an alias for backward compatibility */\n \t{ \"pushNonFastForward\", &advice_push_update_rejected }\ndiff --git a/advice.h b/advice.h\nindex d015404843..b706780614 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -30,6 +30,7 @@ extern int advice_waiting_for_editor;\n extern int advice_graft_file_deprecated;\n extern int advice_checkout_ambiguous_remote_branch_name;\n extern int advice_nested_tag;\n+extern int advice_submodule_alternate_error_strategy_die;\n \n int git_default_advice_config(const char *var, const char *value);\n __attribute__((format (printf, 1, 2)))\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 2c2395a620..bdfc46fdea 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -19,6 +19,7 @@\n #include \"diffcore.h\"\n #include \"diff.h\"\n #include \"object-store.h\"\n+#include \"advice.h\"\n \n #define OPT_QUIET (1 << 0)\n #define OPT_CACHED (1 << 1)\n@@ -1268,6 +1269,14 @@ struct submodule_alternate_setup {\n #define SUBMODULE_ALTERNATE_SETUP_INIT { NULL, \\\n \tSUBMODULE_ALTERNATE_ERROR_IGNORE, NULL }\n \n+static void advise_submodule_alternate_error_die(void)\n+{\n+\tif (!advice_submodule_alternate_error_strategy_die)\n+\t\treturn;\n+\tadvise(_(\"An alternate computed from a superproject's alternate is invalid.\"));\n+\tadvise(_(\"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'.\"));\n+}\n+\n static int add_possible_reference_from_superproject(\n \t\tstruct object_directory *odb, void *sas_cb)\n {\n@@ -1299,6 +1308,7 @@ static int add_possible_reference_from_superproject(\n \t\t} else {\n \t\t\tswitch (sas->error_mode) {\n \t\t\tcase SUBMODULE_ALTERNATE_ERROR_DIE:\n+\t\t\t\tadvise_submodule_alternate_error_die();\n \t\t\t\tdie(_(\"submodule '%s' cannot add alternate: %s\"),\n \t\t\t\t    sas->submodule_name, err.buf);\n \t\t\tcase SUBMODULE_ALTERNATE_ERROR_INFO:\n-- \n2.24.0.432.g9d3f5f5b63-goog\n\n"},{"id":"387141","messageId":"20191127113244.GC22221@sigill.intra.peff.net","threadId":"52339","inReplyTo":"a8125b946227d918865fde0dcbec516474b42386.1574731649.git.jonathantanmy@google.com","subject":"Re: [PATCH 1/2] Doc: explain submodule.alternateErrorStrategy","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-11-27T11:32:44Z","receivedAt":"2019-11-27T11:32:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 25, 2019 at 05:30:59PM -0800, Jonathan Tan wrote:\n\n> Commit 31224cbdc7 (\"clone: recursive and reference option triggers\n> submodule alternates\", 2016-08-17) taught Git to support the\n> configuration options \"submodule.alternateLocation\" and\n> \"submodule.alternateErrorStrategy\" on a superproject.\n> \n> If \"submodule.alternateLocation\" is configured to \"superproject\" on a\n> superproject, whenever a submodule of that superproject is cloned, it\n> instead computes the analogous alternate path for that submodule from\n> $GIT_DIR/objects/info/alternates of the superproject, and references it.\n> \n> The \"submodule.alternateErrorStrategy\" option determines what happens\n> if that alternate cannot be referenced. However, it is not clear that\n> the clone proceeds as if no alternate was specified when that option is\n> not set to \"die\" (as can be seen in the tests in 31224cbdc7). Therefore,\n> document it accordingly.\n> \n> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>\n> ---\n> When I said \"not clear\" above, I mean that it is not clear *to me*, and\n> I assume that others will feel the same way. Feel free to drop this from\n> the patch set if the existing documentation is clear to most people.\n\nFWIW, I learned about these options for the first time from your email,\nand I think the suggested change makes the behavior much more clear.\n\n-Peff\n"},{"id":"387142","messageId":"20191127114908.GD22221@sigill.intra.peff.net","threadId":"52339","inReplyTo":"26c3b388a24eef7f03eb423c10e21430bc3f019e.1574731649.git.jonathantanmy@google.com","subject":"Re: [PATCH 2/2] submodule--helper: advise on fatal alternate error","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-11-27T11:49:08Z","receivedAt":"2019-11-27T11:49:10Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Nov 25, 2019 at 05:31:00PM -0800, Jonathan Tan wrote:\n\n> When recursively cloning a superproject with some shallow modules\n> defined in its .gitmodules, then recloning with \"--reference=<path>\", an\n> error occurs. For example:\n> \n>   git clone --recurse-submodules --branch=master -j8 \\\n>     https://android.googlesource.com/platform/superproject \\\n>     master\n>   git clone --recurse-submodules --branch=master -j8 \\\n>     https://android.googlesource.com/platform/superproject \\\n>     --reference master master2\n> \n> fails with:\n> \n>   fatal: submodule '<snip>' cannot add alternate: reference repository\n>   '<snip>' is shallow\n> \n> When a alternate computed from the superproject's alternate cannot be\n> added, whether in this case or another, advise about configuring the\n> \"submodule.alternateErrorStrategy\" configuration option and using\n> \"--reference-if-able\" instead of \"--reference\" when cloning.\n\nIt sounds like that advice sends people in the right direction, which is\na good thing.\n\nI kind of wonder if the default for alternateErrorStrategy should be\nmore lenient, but I don't really know much about the feature in the\nfirst place. I'll let people who are more clueful ponder that, but\ncertainly your patch is an improvement in the meantime.\n\nOne minor suggestion:\n\n> +static void advise_submodule_alternate_error_die(void)\n> +{\n> +\tif (!advice_submodule_alternate_error_strategy_die)\n> +\t\treturn;\n> +\tadvise(_(\"An alternate computed from a superproject's alternate is invalid.\"));\n> +\tadvise(_(\"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'.\"));\n> +}\n\nThe advise() function handles newlines gracefully (putting a \"hint:\" at\nthe start of each line). So you can put both in a single call, and wrap\nthe second long line, which also lets translators see the whole message\nas a unit. Many of the existing calls define the message outside of any\nfunction (e.g., embedded_advice), which makes it easier to see how long\nthe lines will be when displayed.\n\nSo maybe:\n\n  static const alternate_error_advice[] = N_(\n  \"An alternate computed from a superproject's alternate is invalid.\\n\"\n  \"To allow Git to clone without an alternate in such a case, set\\n\"\n  \"submodule.alternateErrorStrategy to 'info' or, equivalently, clone with\\n\"\n  \"'--reference-if-able' instead of '--reference'.\"\n  );\n\n  ...\n\tswitch (sas->error_mode) {\n\tcase SUBMODULE_ALTERNATE_ERROR_DIE:\n\t\tif (advice_submodule_alternate_error_strategy_die)\n\t\t\tadvise(_(alternate_error_advice));\n\t\tdie(...);\n\n?\n\n-Peff\n"},{"id":"387146","messageId":"xmqqo8wxv6vk.fsf@gitster-ct.c.googlers.com","threadId":"52339","inReplyTo":"a8125b946227d918865fde0dcbec516474b42386.1574731649.git.jonathantanmy@google.com","subject":"Re: [PATCH 1/2] Doc: explain submodule.alternateErrorStrategy","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-27T12:30:39Z","receivedAt":"2019-11-27T12:30:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Tan <jonathantanmy@google.com> writes:\n\n> Commit 31224cbdc7 (\"clone: recursive and reference option triggers\n> submodule alternates\", 2016-08-17) taught Git to support the\n> configuration options \"submodule.alternateLocation\" and\n> \"submodule.alternateErrorStrategy\" on a superproject.\n> ...\n> The \"submodule.alternateErrorStrategy\" option determines what happens\n> if that alternate cannot be referenced. However, it is not clear that\n> the clone proceeds as if no alternate was specified when that option is\n> not set to \"die\" (as can be seen in the tests in 31224cbdc7). Therefore,\n> document it accordingly.\n\nGiven that for everyday use (cf. sha1-file.c::link_alt_odb_entry())\nof an alternate is best-effort basis, I have a feeling that it was a\ndesign mistake to have the \"error strategy\" configuration option in\nthe first place, and \"clone --reference-if-able\" was the result of\nthe same design mistake.  We would have been better off if we made\nthese the best-effort features as well.\n\nBut the ship has sailed long ago---so I think these two are the best\nwe can do at this point.  Perhaps flipping the default to warn may\nbe a longer term improvement, too.\n"},{"id":"387416","messageId":"cover.1575316490.git.jonathantanmy@google.com","threadId":"52339","inReplyTo":"cover.1574731649.git.jonathantanmy@google.com","subject":"[PATCH v2 0/2] Advice upon clone --recurse-submodules --reference","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-12-02T19:57:50Z","receivedAt":"2019-12-02T19:57:59Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"Thanks everyone! Here's an updated v2 following Peff's suggestions on\nhow to write the advice part.\n\nMaking submodule.alternateErrorStrategy default to 'info' is reasonable,\nbut I don't know how much it matters in practice - here,\nsubmodule.alternateLocation was set because of \"clone\n--recurse-submodules --reference\", which also sets\nsubmodule.alternateErrorStrategy. I don't know when\nsubmodule.alternateLocation would ever be set alone, but then again, I'm\nnot very familiar with this part. I've left that alone for now.\n\nJonathan Tan (2):\n  Doc: explain submodule.alternateErrorStrategy\n  submodule--helper: advise on fatal alternate error\n\n Documentation/config/advice.txt    |  3 +++\n Documentation/config/submodule.txt |  4 +++-\n advice.c                           |  2 ++\n advice.h                           |  1 +\n builtin/submodule--helper.c        | 10 ++++++++++\n 5 files changed, 19 insertions(+), 1 deletion(-)\n\n-- \n2.24.0.393.g34dc348eaf-goog\n\n"},{"id":"387417","messageId":"6de0eeac4ca2a3b5c35ad1ffaaa436ebbef3a27c.1575316490.git.jonathantanmy@google.com","threadId":"52339","inReplyTo":"cover.1575316490.git.jonathantanmy@google.com","subject":"[PATCH v2 1/2] Doc: explain submodule.alternateErrorStrategy","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-12-02T19:57:51Z","receivedAt":"2019-12-02T19:58:01Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"Commit 31224cbdc7 (\"clone: recursive and reference option triggers\nsubmodule alternates\", 2016-08-17) taught Git to support the\nconfiguration options \"submodule.alternateLocation\" and\n\"submodule.alternateErrorStrategy\" on a superproject.\n\nIf \"submodule.alternateLocation\" is configured to \"superproject\" on a\nsuperproject, whenever a submodule of that superproject is cloned, it\ninstead computes the analogous alternate path for that submodule from\n$GIT_DIR/objects/info/alternates of the superproject, and references it.\n\nThe \"submodule.alternateErrorStrategy\" option determines what happens\nif that alternate cannot be referenced. However, it is not clear that\nthe clone proceeds as if no alternate was specified when that option is\nnot set to \"die\" (as can be seen in the tests in 31224cbdc7). Therefore,\ndocument it accordingly.\n\nSigned-off-by: Jonathan Tan <jonathantanmy@google.com>\n---\n Documentation/config/submodule.txt | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt\nindex 0a1293b051..b33177151c 100644\n--- a/Documentation/config/submodule.txt\n+++ b/Documentation/config/submodule.txt\n@@ -79,4 +79,6 @@ submodule.alternateLocation::\n submodule.alternateErrorStrategy::\n \tSpecifies how to treat errors with the alternates for a submodule\n \tas computed via `submodule.alternateLocation`. Possible values are\n-\t`ignore`, `info`, `die`. Default is `die`.\n+\t`ignore`, `info`, `die`. Default is `die`. Note that if set to `ignore`\n+\tor `info`, and if there is an error with the computed alternate, the\n+\tclone proceeds as if no alternate was specified.\n-- \n2.24.0.393.g34dc348eaf-goog\n\n"},{"id":"387418","messageId":"4f2182aa26b3da1fb80700e67f81e721778ea046.1575316490.git.jonathantanmy@google.com","threadId":"52339","inReplyTo":"cover.1575316490.git.jonathantanmy@google.com","subject":"[PATCH v2 2/2] submodule--helper: advise on fatal alternate error","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-12-02T19:57:52Z","receivedAt":"2019-12-02T19:58:06Z","isPatch":true,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"When recursively cloning a superproject with some shallow modules\ndefined in its .gitmodules, then recloning with \"--reference=<path>\", an\nerror occurs. For example:\n\n  git clone --recurse-submodules --branch=master -j8 \\\n    https://android.googlesource.com/platform/superproject \\\n    master\n  git clone --recurse-submodules --branch=master -j8 \\\n    https://android.googlesource.com/platform/superproject \\\n    --reference master master2\n\nfails with:\n\n  fatal: submodule '<snip>' cannot add alternate: reference repository\n  '<snip>' is shallow\n\nWhen a alternate computed from the superproject's alternate cannot be\nadded, whether in this case or another, advise about configuring the\n\"submodule.alternateErrorStrategy\" configuration option and using\n\"--reference-if-able\" instead of \"--reference\" when cloning.\n\nSigned-off-by: Jonathan Tan <jonathantanmy@google.com>\n---\n Documentation/config/advice.txt |  3 +++\n advice.c                        |  2 ++\n advice.h                        |  1 +\n builtin/submodule--helper.c     | 10 ++++++++++\n 4 files changed, 16 insertions(+)\n\ndiff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt\nindex 6aaa360202..d4e698cd3f 100644\n--- a/Documentation/config/advice.txt\n+++ b/Documentation/config/advice.txt\n@@ -107,4 +107,7 @@ advice.*::\n \t\teditor input from the user.\n \tnestedTag::\n \t\tAdvice shown if a user attempts to recursively tag a tag object.\n+\tsubmoduleAlternateErrorStrategyDie:\n+\t\tAdvice shown when a submodule.alternateErrorStrategy option\n+\t\tconfigured to \"die\" causes a fatal error.\n --\ndiff --git a/advice.c b/advice.c\nindex 3ee0ee2d8f..249c60dcf3 100644\n--- a/advice.c\n+++ b/advice.c\n@@ -30,6 +30,7 @@ int advice_waiting_for_editor = 1;\n int advice_graft_file_deprecated = 1;\n int advice_checkout_ambiguous_remote_branch_name = 1;\n int advice_nested_tag = 1;\n+int advice_submodule_alternate_error_strategy_die = 1;\n \n static int advice_use_color = -1;\n static char advice_colors[][COLOR_MAXLEN] = {\n@@ -89,6 +90,7 @@ static struct {\n \t{ \"graftFileDeprecated\", &advice_graft_file_deprecated },\n \t{ \"checkoutAmbiguousRemoteBranchName\", &advice_checkout_ambiguous_remote_branch_name },\n \t{ \"nestedTag\", &advice_nested_tag },\n+\t{ \"submoduleAlternateErrorStrategyDie\", &advice_submodule_alternate_error_strategy_die },\n \n \t/* make this an alias for backward compatibility */\n \t{ \"pushNonFastForward\", &advice_push_update_rejected }\ndiff --git a/advice.h b/advice.h\nindex d015404843..b706780614 100644\n--- a/advice.h\n+++ b/advice.h\n@@ -30,6 +30,7 @@ extern int advice_waiting_for_editor;\n extern int advice_graft_file_deprecated;\n extern int advice_checkout_ambiguous_remote_branch_name;\n extern int advice_nested_tag;\n+extern int advice_submodule_alternate_error_strategy_die;\n \n int git_default_advice_config(const char *var, const char *value);\n __attribute__((format (printf, 1, 2)))\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 2c2395a620..12d546dfbb 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -19,6 +19,7 @@\n #include \"diffcore.h\"\n #include \"diff.h\"\n #include \"object-store.h\"\n+#include \"advice.h\"\n \n #define OPT_QUIET (1 << 0)\n #define OPT_CACHED (1 << 1)\n@@ -1268,6 +1269,13 @@ struct submodule_alternate_setup {\n #define SUBMODULE_ALTERNATE_SETUP_INIT { NULL, \\\n \tSUBMODULE_ALTERNATE_ERROR_IGNORE, NULL }\n \n+static const char alternate_error_advice[] = N_(\n+\"An alternate computed from a superproject's alternate is invalid.\\n\"\n+\"To allow Git to clone without an alternate in such a case, set\\n\"\n+\"submodule.alternateErrorStrategy to 'info' or, equivalently, clone with\\n\"\n+\"'--reference-if-able' instead of '--reference'.\"\n+);\n+\n static int add_possible_reference_from_superproject(\n \t\tstruct object_directory *odb, void *sas_cb)\n {\n@@ -1299,6 +1307,8 @@ static int add_possible_reference_from_superproject(\n \t\t} else {\n \t\t\tswitch (sas->error_mode) {\n \t\t\tcase SUBMODULE_ALTERNATE_ERROR_DIE:\n+\t\t\t\tif (advice_submodule_alternate_error_strategy_die)\n+\t\t\t\t\tadvise(_(alternate_error_advice));\n \t\t\t\tdie(_(\"submodule '%s' cannot add alternate: %s\"),\n \t\t\t\t    sas->submodule_name, err.buf);\n \t\t\tcase SUBMODULE_ALTERNATE_ERROR_INFO:\n-- \n2.24.0.393.g34dc348eaf-goog\n\n"},{"id":"387454","messageId":"20191203153910.GA6116@sigill.intra.peff.net","threadId":"52339","inReplyTo":"cover.1575316490.git.jonathantanmy@google.com","subject":"Re: [PATCH v2 0/2] Advice upon clone --recurse-submodules --reference","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-12-03T15:39:10Z","receivedAt":"2019-12-03T15:39:13Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Dec 02, 2019 at 11:57:50AM -0800, Jonathan Tan wrote:\n\n> Thanks everyone! Here's an updated v2 following Peff's suggestions on\n> how to write the advice part.\n\nThanks, this looks good to me.\n\nI think Junio and I both wondered if the default should be flipped to\n\"info\", but I don't feel strongly about it, and this seems like an\nimprovement in the meantime.\n\n-Peff\n"},{"id":"387461","messageId":"xmqqtv6h5p5c.fsf@gitster-ct.c.googlers.com","threadId":"52339","inReplyTo":"20191203153910.GA6116@sigill.intra.peff.net","subject":"Re: [PATCH v2 0/2] Advice upon clone --recurse-submodules --reference","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-12-03T16:50:55Z","receivedAt":"2019-12-03T16:51:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, Dec 02, 2019 at 11:57:50AM -0800, Jonathan Tan wrote:\n>\n>> Thanks everyone! Here's an updated v2 following Peff's suggestions on\n>> how to write the advice part.\n>\n> Thanks, this looks good to me.\n>\n> I think Junio and I both wondered if the default should be flipped to\n> \"info\", but I don't feel strongly about it, and this seems like an\n> improvement in the meantime.\n\nWe indeed did, and I agree this is a good step regardless.\n\nThanks, both.\n"}]}