{"thread":{"id":"49286","subject":"[PATCH] submodule.sh update --remote: default to oid instead of master","startedAt":"2018-09-05T22:48:37Z","lastAt":"2018-10-02T00:17:23Z","messageCount":5,"participants":["Stefan Beller","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"357489","messageId":"20180905224825.13564-1-sbeller@google.com","threadId":"49286","inReplyTo":null,"subject":"[PATCH] submodule.sh update --remote: default to oid instead of master","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-09-05T22:48:25Z","receivedAt":"2018-09-05T22:48:37Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"gitmodules(5) sayeth:\n\n   submodule.<name>.branch\n       A remote branch name for tracking updates in the upstream\n       submodule. If the option is not specified, it defaults to master.\n\nThis doesn't allow having a \"pinned\" submodule that should not be updated\nfrom upstream. We should change this to have no default --- if branch is\nnot specified, don't update that submodule, just like in Gerrit's\ncorresponding feature[1].\n\n[1] https://gerrit-review.googlesource.com/Documentation/user-submodules.html#_defining_the_submodule_branch\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n Documentation/gitmodules.txt | 11 ++++++-----\n git-submodule.sh             | 19 +++++++++++--------\n t/t7406-submodule-update.sh  | 22 ++++++++++++++++++++++\n 3 files changed, 39 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt\nindex 4d63def2069..3b8739f8294 100644\n--- a/Documentation/gitmodules.txt\n+++ b/Documentation/gitmodules.txt\n@@ -50,11 +50,12 @@ submodule.<name>.update::\n \n submodule.<name>.branch::\n \tA remote branch name for tracking updates in the upstream submodule.\n-\tIf the option is not specified, it defaults to 'master'.  A special\n-\tvalue of `.` is used to indicate that the name of the branch in the\n-\tsubmodule should be the same name as the current branch in the\n-\tcurrent repository.  See the `--remote` documentation in\n-\tlinkgit:git-submodule[1] for details.\n+\tA special value of `.` is used to indicate that the name of the\n+\tbranch in the submodule should be the same name as the current\n+\tbranch in the current repository.  See the `--remote` documentation\n+\tin linkgit:git-submodule[1] for details.\n+\tIf the option is not specified, do not update to any branch but\n+\tthe object id of the remote.\n \n submodule.<name>.fetchRecurseSubmodules::\n \tThis option can be used to control recursive fetching of this\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex f7fd80345cd..342050ae934 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -568,16 +568,19 @@ cmd_update()\n \t\tif test -n \"$remote\"\n \t\tthen\n \t\t\tbranch=$(git submodule--helper remote-branch \"$sm_path\")\n-\t\t\tif test -z \"$nofetch\"\n+\t\t\tif test -n \"$branch\"\n \t\t\tthen\n-\t\t\t\t# Fetch remote before determining tracking $sha1\n-\t\t\t\tfetch_in_submodule \"$sm_path\" $depth ||\n-\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n+\t\t\t\tif test -z \"$nofetch\"\n+\t\t\t\tthen\n+\t\t\t\t\t# Fetch remote before determining tracking $sha1\n+\t\t\t\t\tfetch_in_submodule \"$sm_path\" $depth ||\n+\t\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n+\t\t\t\tfi\n+\t\t\t\tremote_name=$(sanitize_submodule_env; cd \"$sm_path\" && get_default_remote)\n+\t\t\t\tsha1=$(sanitize_submodule_env; cd \"$sm_path\" &&\n+\t\t\t\t\tgit rev-parse --verify \"${remote_name}/${branch}\") ||\n+\t\t\t\tdie \"$(eval_gettext \"Unable to find current \\${remote_name}/\\${branch} revision in submodule path '\\$sm_path'\")\"\n \t\t\tfi\n-\t\t\tremote_name=$(sanitize_submodule_env; cd \"$sm_path\" && get_default_remote)\n-\t\t\tsha1=$(sanitize_submodule_env; cd \"$sm_path\" &&\n-\t\t\t\tgit rev-parse --verify \"${remote_name}/${branch}\") ||\n-\t\t\tdie \"$(eval_gettext \"Unable to find current \\${remote_name}/\\${branch} revision in submodule path '\\$sm_path'\")\"\n \t\tfi\n \n \t\tif ! $(git config -f \"$(git rev-parse --git-common-dir)/modules/$name/config\" core.worktree) 2>/dev/null\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 10dc91620a6..f04884743fd 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -260,6 +260,28 @@ test_expect_success 'submodule update --remote should fetch upstream changes wit\n \t)\n '\n \n+test_expect_success 'submodule update --remote should not fetch upstream when no branch is set' '\n+\t(\n+\t\tcd super &&\n+\t\ttest_might_fail git config --unset -f .gitmodules submodule.\"submodule\".branch &&\n+\t\tgit add .gitmodules &&\n+\t\tgit commit --allow-empty -m \"submodules: pin in superproject branch\"\n+\t) &&\n+\t(\n+\t\tcd submodule &&\n+\t\techo line4b >>file &&\n+\t\tgit add file &&\n+\t\ttest_tick &&\n+\t\tgit commit -m \"upstream line4b\"\n+\t) &&\n+\t(\n+\t\tcd super &&\n+\t\tgit submodule update --remote --force submodule &&\n+\t\tgit -C submodule log -1 --oneline >actual &&\n+\t\t! grep line4b actual\n+\t)\n+'\n+\n test_expect_success 'local config should override .gitmodules branch' '\n \t(cd submodule &&\n \t git checkout test-branch &&\n-- \n2.19.0.rc2.392.g5ba43deb5a-goog\n\n"},{"id":"357492","messageId":"20180905231006.GC120842@aiede.svl.corp.google.com","threadId":"49286","inReplyTo":"20180905224825.13564-1-sbeller@google.com","subject":"Re: [PATCH] submodule.sh update --remote: default to oid instead of master","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-09-05T23:10:06Z","receivedAt":"2018-09-05T23:10:11Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Stefan Beller wrote:\n\n> Subject: submodule.sh update --remote: default to oid instead of master\n\nYay!\n\nNit: it wasn't clear to me at first what default this subject line was\nreferring to.  Perhaps:\n\n\tsubmodule update --remote: skip GITLINK update when no branch is set\n\n[...]\n> --- a/Documentation/gitmodules.txt\n> +++ b/Documentation/gitmodules.txt\n> @@ -50,11 +50,12 @@ submodule.<name>.update::\n>  \n>  submodule.<name>.branch::\n[...]\n> +\tIf the option is not specified, do not update to any branch but\n> +\tthe object id of the remote.\n\nLikewise: how about something like\n\n\tIf not set, the default is for `git submodule update --remote`\n\tto update the submodule to the superproject's recorded SHA-1.\n\n[...]\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -568,16 +568,19 @@ cmd_update()\n>  \t\tif test -n \"$remote\"\n>  \t\tthen\n>  \t\t\tbranch=$(git submodule--helper remote-branch \"$sm_path\")\n> -\t\t\tif test -z \"$nofetch\"\n> +\t\t\tif test -n \"$branch\"\n>  \t\t\tthen\n> -\t\t\t\t# Fetch remote before determining tracking $sha1\n> -\t\t\t\tfetch_in_submodule \"$sm_path\" $depth ||\n> -\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n> +\t\t\t\tif test -z \"$nofetch\"\n> +\t\t\t\tthen\n> +\t\t\t\t\t# Fetch remote before determining tracking $sha1\n> +\t\t\t\t\tfetch_in_submodule \"$sm_path\" $depth ||\n\nMakes sense.  If $sha1 isn't available in the submodule, it will fetch\nagain later.\n\n[...]\n> --- a/t/t7406-submodule-update.sh\n> +++ b/t/t7406-submodule-update.sh\n> @@ -260,6 +260,28 @@ test_expect_success 'submodule update --remote should fetch upstream changes wit\n>  \t)\n>  '\n>  \n> +test_expect_success 'submodule update --remote should not fetch upstream when no branch is set' '\n> +\t(\n> +\t\tcd super &&\n> +\t\ttest_might_fail git config --unset -f .gitmodules submodule.\"submodule\".branch &&\n\nNot about this patch: the quoting here is strange.\n\n> +\t\tgit add .gitmodules &&\n> +\t\tgit commit --allow-empty -m \"submodules: pin in superproject branch\"\n> +\t) &&\n\nI wonder if we can do simpler by using -C + some helpers: something like\n\n\tgit config --unset -f super/.gitmodules ... &&\n\ttest_commit -C submodule ... &&\n\tgit -C super submodule update ... &&\n\ttest_cmp_rev ...\n\nUnfortunately test_cmp_rev doesn't accept a -C argument.\n\nBroader comment: do you think people will be surprised by this new\nbehavior?  Is there anything special we'd need to do to call it out\n(e.g., print a warning or put something in release notes)?\n\nThanks,\nJonathan\n"},{"id":"357556","messageId":"CAGZ79kY_O+y0=1qMr2tw2cw3ULhhjTPQ-G5swa+KNXKLKSOSYw@mail.gmail.com","threadId":"49286","inReplyTo":"20180905231006.GC120842@aiede.svl.corp.google.com","subject":"Re: [PATCH] submodule.sh update --remote: default to oid instead of master","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-09-06T18:06:15Z","receivedAt":"2018-09-06T18:06:30Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Sep 5, 2018 at 4:10 PM Jonathan Nieder <jrnieder@gmail.com> wrote:\n>\n> Stefan Beller wrote:\n>\n> > Subject: submodule.sh update --remote: default to oid instead of master\n>\n> Yay!\n>\n> Nit: it wasn't clear to me at first what default this subject line was\n> referring to.  Perhaps:\n>\n>         submodule update --remote: skip GITLINK update when no branch is set\n>\n> [...]\n> > --- a/Documentation/gitmodules.txt\n> > +++ b/Documentation/gitmodules.txt\n> > @@ -50,11 +50,12 @@ submodule.<name>.update::\n> >\n> >  submodule.<name>.branch::\n> [...]\n> > +     If the option is not specified, do not update to any branch but\n> > +     the object id of the remote.\n>\n> Likewise: how about something like\n>\n>         If not set, the default is for `git submodule update --remote`\n>         to update the submodule to the superproject's recorded SHA-1.\n\n... recorded object id.\n\nsounds good.\n\n> > +             git add .gitmodules &&\n> > +             git commit --allow-empty -m \"submodules: pin in superproject branch\"\n> > +     ) &&\n>\n> I wonder if we can do simpler by using -C + some helpers: something like\n>\n>         git config --unset -f super/.gitmodules ... &&\n>         test_commit -C submodule ... &&\n>         git -C super submodule update ... &&\n>         test_cmp_rev ...\n>\n> Unfortunately test_cmp_rev doesn't accept a -C argument.\n\nand the lack of fortune goes further, as test_cmp_rev needs to have\n2 revisions in the same repository, i.e. both need to exist,\nwhich is not the case.\n\n> Broader comment: do you think people will be surprised by this new\n> behavior?  Is there anything special we'd need to do to call it out\n> (e.g., print a warning or put something in release notes)?\n\nI guess. Not sure how to approach this best. Maybe we can\nextend the output of 'submodule update' to print that branch names\ninstead of hashes for the configured case and keep printing hashes\nonly for this case. Although that would not help someone who relies\non the default solely.\n"},{"id":"357591","messageId":"20180906225423.GB81412@aiede.svl.corp.google.com","threadId":"49286","inReplyTo":"CAGZ79kY_O+y0=1qMr2tw2cw3ULhhjTPQ-G5swa+KNXKLKSOSYw@mail.gmail.com","subject":"Re: [PATCH] submodule.sh update --remote: default to oid instead of master","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2018-09-06T22:54:23Z","receivedAt":"2018-09-06T22:54:28Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Stefan Beller wrote:\n> On Wed, Sep 5, 2018 at 4:10 PM Jonathan Nieder <jrnieder@gmail.com> wrote:\n\n>> Broader comment: do you think people will be surprised by this new\n>> behavior?  Is there anything special we'd need to do to call it out\n>> (e.g., print a warning or put something in release notes)?\n>\n> I guess. Not sure how to approach this best. Maybe we can\n> extend the output of 'submodule update' to print that branch names\n> instead of hashes for the configured case and keep printing hashes\n> only for this case. Although that would not help someone who relies\n> on the default solely.\n\nThinking more out loud: often the simplest migration path involves\nmultiple steps:\n\n 1. Warn in the case that is going to change, with no behavior change\n    yet.\n\n 2. Treat the case that will change as an error.  This should\n    help flush out cases where people were relying on the old behavior.\n\n 3. Introduce the new behavior.  Warn that old versions of Git don't\n    support it yet.\n\n 4. Eliminate the warning.  You're all clear now.\n\nSometimes some of these steps can be combined.\n\nAnother possible approach is to measure.  For example, is there some\nway to find out how many people are relying in this \"git submodule\nupdate --remote\" defaulting behavior?  One example of this approach is\nto make the change (all in one step) in \"next\" and deploy to some\nrelevant subpopulation and see if anyone screams.  By making the\nchange in \"next\" instead of something with more stability guarantees,\nyou get the ability to roll back quickly.\n\nThere are other tools at our disposal --- e.g. command-line flags,\nconfig, other kinds of research.\n\nHere my first instinct would be to say this should be a command-line\nflag.  To start out, we can keep the historical behavior as a default,\nbut introduce a command-line option for the new behavior.  This way,\npeople can pass the negation of that command-line option if they want\nthe older behavior, throughout the transition.\n\nFor example (please ignore names):\n\n Step 0: introduce\n\n\tgit submodule update --remote --default-to-master; # current behavior\n\tgit submodule update --remote --no-default-to-master; # new behavior\n\n and treat plain \"git submodule update --remote\" as --default-to-master.\n\n Step 1: when neither --default-to-master nor --no-default-to-master\n has been passed, warn when encountering a submodule with no branch\n and treat it as \"master\".\n\n Step 2: when neither --default-to-master nor --no-default-to-master\n has been passed, error out when encountering a submodule with no\n branch.\n\n Step 3: when neither --default-to-master nor --no-default-to-master\n has been passed, warn when encountering a submodule with no branch\n and treat it as pinned.\n\n Step 4: eliminate the warning.\n\nWhat do you think?\n\nThanks,\nJonathan\n"},{"id":"359394","messageId":"20181002001713.137087-1-sbeller@google.com","threadId":"49286","inReplyTo":"20180906225423.GB81412@aiede.svl.corp.google.com","subject":"[PATCH] submodule update --remote: introduce pinning","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-10-02T00:17:13Z","receivedAt":"2018-10-02T00:17:23Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"gitmodules(5) sayeth:\n\n   submodule.<name>.branch\n       A remote branch name for tracking updates in the upstream\n       submodule. If the option is not specified, it defaults to master.\n\nThis doesn't allow having a \"pinned\" submodule that should not be updated\nfrom upstream. We should change this to have no default --- if branch is\nnot specified, don't update that submodule, just like in Gerrit's\ncorresponding feature[1].\n\n[1] https://gerrit-review.googlesource.com/Documentation/user-submodules.html#_defining_the_submodule_branch\n\n\nHowever changing defaults is difficult as it may surprise the user,\nJonathan came up with a 4 step plan:\nStep 0: introduce\n\n\t# current behavior:\n        git submodule update --remote --remote-default-to-master\n\n\t# new behavior:\n        git submodule update --remote --remote-pinned\n\nand treat plain \"git submodule update --remote\" as --default-to-master.\n\nStep 1: when neither --default-to-master nor --no-default-to-master\nhas been passed, warn when encountering a submodule with no branch\nand treat it as \"master\".\n\nStep 2: when neither --default-to-master nor --no-default-to-master\nhas been passed, error out when encountering a submodule with no\nbranch.\n\nStep 3: when neither --default-to-master nor --no-default-to-master\nhas been passed, warn when encountering a submodule with no branch\nand treat it as pinned.\n\nStep 4: eliminate the warning.\n\nThis implements step 0 and 1.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\nSorry that this took so long, this is a rough patch for steps 0 & 1,\nI'd still need to update docs.\n\nStefan\n\n\n Documentation/gitmodules.txt | 11 ++++++-----\n builtin/submodule--helper.c  | 36 +++++++++++++++++++++++++++++-------\n git-submodule.sh             | 34 +++++++++++++++++++++++++---------\n t/t7406-submodule-update.sh  | 29 +++++++++++++++++++++++++++++\n 4 files changed, 89 insertions(+), 21 deletions(-)\n\ndiff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt\nindex 4d63def206..fe42dbdb3e 100644\n--- a/Documentation/gitmodules.txt\n+++ b/Documentation/gitmodules.txt\n@@ -50,11 +50,12 @@ submodule.<name>.update::\n \n submodule.<name>.branch::\n \tA remote branch name for tracking updates in the upstream submodule.\n-\tIf the option is not specified, it defaults to 'master'.  A special\n-\tvalue of `.` is used to indicate that the name of the branch in the\n-\tsubmodule should be the same name as the current branch in the\n-\tcurrent repository.  See the `--remote` documentation in\n-\tlinkgit:git-submodule[1] for details.\n+\tA special value of `.` is used to indicate that the name of the\n+\tbranch in the submodule should be the same name as the current\n+\tbranch in the current repository.  See the `--remote` documentation\n+\tin linkgit:git-submodule[1] for details.\n+\tIf not set, the default for `git submodule update --remote` is\n+\tto update the submodule to the superproject's recorded object id.\n \n submodule.<name>.fetchRecurseSubmodules::\n \tThis option can be used to control recursive fetching of this\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex 40844870cf..6413f2b410 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -1889,7 +1889,7 @@ static int resolve_relative_path(int argc, const char **argv, const char *prefix\n \treturn 0;\n }\n \n-static const char *remote_submodule_branch(const char *path)\n+static const char *remote_submodule_branch(const char *path, int default_pinned)\n {\n \tconst struct submodule *sub;\n \tconst char *branch = NULL;\n@@ -1904,8 +1904,12 @@ static const char *remote_submodule_branch(const char *path)\n \t\tbranch = sub->branch;\n \tfree(key);\n \n-\tif (!branch)\n-\t\treturn \"master\";\n+\tif (!branch) {\n+\t\tif (default_pinned)\n+\t\t\treturn \"\";\n+\t\telse\n+\t\t\treturn \"master\";\n+\t}\n \n \tif (!strcmp(branch, \".\")) {\n \t\tconst char *refname = resolve_ref_unsafe(\"HEAD\", 0, NULL, NULL);\n@@ -1932,12 +1936,30 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,\n {\n \tconst char *ret;\n \tstruct strbuf sb = STRBUF_INIT;\n-\tif (argc != 2)\n-\t\tdie(\"submodule--helper remote-branch takes exactly one arguments, got %d\", argc);\n+\tint default_pinned = 0;\n+\n+\tstruct option remote_options[] = {\n+\t\tOPT_SET_INT(0, \"default-master\", &default_pinned,\n+\t\t\t\tN_(\"unconfigured submodules default to master branch\"), 0),\n+\t\tOPT_SET_INT(0, \"default-pinned\", &default_pinned,\n+\t\t\t\tN_(\"unconfigured submodules default to superproject object id\"), 1),\n+\t\tOPT_END()\n+\t};\n+\n+\tconst char *const git_submodule_helper_usage[] = {\n+\t\tN_(\"git submodule--helper remote-branch [--default-{master, pinned}]  -- <path>\"),\n+\t\tNULL\n+\t};\n+\n+\targc = parse_options(argc, argv, prefix, remote_options,\n+\t\t\t     git_submodule_helper_usage, 0);\n+\n+\tif (argc != 1)\n+\t\tdie(\"submodule--helper remote-branch takes exactly one path, got %d\", argc);\n \n-\tret = remote_submodule_branch(argv[1]);\n+\tret = remote_submodule_branch(argv[0], default_pinned);\n \tif (!ret)\n-\t\tdie(\"submodule %s doesn't exist\", argv[1]);\n+\t\tdie(\"submodule %s doesn't exist\", argv[0]);\n \n \tprintf(\"%s\", ret);\n \tstrbuf_release(&sb);\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1b568e29b9..829b90ea97 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -431,6 +431,7 @@ fetch_in_submodule () (\n #\n cmd_update()\n {\n+\tremote_default_option=\n \t# parse $args after \"submodule ... update\".\n \twhile test $# -ne 0\n \tdo\n@@ -450,6 +451,12 @@ cmd_update()\n \t\t--remote)\n \t\t\tremote=1\n \t\t\t;;\n+\t\t--remote-default-to-master)\n+\t\t\tremote_default_option=--default-master\n+\t\t\t;;\n+\t\t--remote-pinned)\n+\t\t\tremote_default_option=--default-pinned\n+\t\t\t;;\n \t\t-N|--no-fetch)\n \t\t\tnofetch=1\n \t\t\t;;\n@@ -555,17 +562,26 @@ cmd_update()\n \n \t\tif test -n \"$remote\"\n \t\tthen\n-\t\t\tbranch=$(git submodule--helper remote-branch \"$sm_path\")\n-\t\t\tif test -z \"$nofetch\"\n+\t\t\tif test -z $remote_default_option\n \t\t\tthen\n-\t\t\t\t# Fetch remote before determining tracking $sha1\n-\t\t\t\tfetch_in_submodule \"$sm_path\" $depth ||\n-\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n+\t\t\t\tsay \"--remote needs clarification: --remote-pinned or --remote-default-to-master?\"\n+\t\t\t\tsay \"assuming --remote-default-to-master for now\"\n+\t\t\t\tremote_default_option=--default-master\n+\t\t\tfi\n+\t\t\tbranch=$(git submodule--helper remote-branch ${remote_default_option} -- \"$sm_path\")\n+\t\t\tif test -n \"$branch\"\n+\t\t\tthen\n+\t\t\t\tif test -z \"$nofetch\"\n+\t\t\t\tthen\n+\t\t\t\t\t# Fetch remote before determining tracking $sha1\n+\t\t\t\t\tfetch_in_submodule \"$sm_path\" $depth ||\n+\t\t\t\t\tdie \"$(eval_gettext \"Unable to fetch in submodule path '\\$sm_path'\")\"\n+\t\t\t\tfi\n+\t\t\t\tremote_name=$(sanitize_submodule_env; cd \"$sm_path\" && get_default_remote)\n+\t\t\t\tsha1=$(sanitize_submodule_env; cd \"$sm_path\" &&\n+\t\t\t\t\tgit rev-parse --verify \"${remote_name}/${branch}\") ||\n+\t\t\t\tdie \"$(eval_gettext \"Unable to find current \\${remote_name}/\\${branch} revision in submodule path '\\$sm_path'\")\"\n \t\t\tfi\n-\t\t\tremote_name=$(sanitize_submodule_env; cd \"$sm_path\" && get_default_remote)\n-\t\t\tsha1=$(sanitize_submodule_env; cd \"$sm_path\" &&\n-\t\t\t\tgit rev-parse --verify \"${remote_name}/${branch}\") ||\n-\t\t\tdie \"$(eval_gettext \"Unable to find current \\${remote_name}/\\${branch} revision in submodule path '\\$sm_path'\")\"\n \t\tfi\n \n \t\tif test \"$subsha1\" != \"$sha1\" || test -n \"$force\"\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 10dc91620a..3019978211 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -260,6 +260,35 @@ test_expect_success 'submodule update --remote should fetch upstream changes wit\n \t)\n '\n \n+test_expect_success 'submodule update --remote should not fetch upstream when no branch is set' '\n+\t(\n+\t\tcd super &&\n+\t\ttest_might_fail git config --unset -f .gitmodules submodule.submodule.branch &&\n+\t\tgit add .gitmodules &&\n+\t\tgit commit --allow-empty -m \"submodules: pin in superproject branch\" &&\n+\t\tgit -C ../submodule checkout -f master\n+\t) &&\n+\t(\n+\t\tcd submodule &&\n+\t\techo line4b >>file &&\n+\t\tgit add file &&\n+\t\ttest_tick &&\n+\t\tgit commit -m \"upstream line4b\"\n+\t) &&\n+\t(\n+\t\tcd super &&\n+\n+\t\tgit submodule update --remote-pinned --remote --force submodule &&\n+\t\tgit status --porcelain --untracked=no --ignore-submodules=none >actual &&\n+\t\ttest_must_be_empty actual &&\n+\n+\t\tgit submodule update --remote-default-to-master --remote --force submodule &&\n+\t\tgit -C submodule log -1 --oneline >actual &&\n+\t\tgit -C ../submodule log -1 --oneline >expect &&\n+\t\ttest_cmp expect actual\n+\t)\n+'\n+\n test_expect_success 'local config should override .gitmodules branch' '\n \t(cd submodule &&\n \t git checkout test-branch &&\n-- \n2.19.0\n\n"}]}