Skip to content

Commit 177257c

Browse files
bmwillgitster
authored andcommitted
submodule--helper: don't overlay config in remote_submodule_branch
Don't rely on overlaying the repository's config on top of the submodule-config, instead query the repository's config directly for the branch field. Signed-off-by: Brandon Williams <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5556808 commit 177257c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

builtin/submodule--helper.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,17 +1066,24 @@ static int resolve_relative_path(int argc, const char **argv, const char *prefix
10661066
static const char *remote_submodule_branch(const char *path)
10671067
{
10681068
const struct submodule *sub;
1069+
const char *branch = NULL;
1070+
char *key;
1071+
10691072
gitmodules_config();
1070-
git_config(submodule_config, NULL);
10711073

10721074
sub = submodule_from_path(&null_oid, path);
10731075
if (!sub)
10741076
return NULL;
10751077

1076-
if (!sub->branch)
1078+
key = xstrfmt("submodule.%s.branch", sub->name);
1079+
if (repo_config_get_string_const(the_repository, key, &branch))
1080+
branch = sub->branch;
1081+
free(key);
1082+
1083+
if (!branch)
10771084
return "master";
10781085

1079-
if (!strcmp(sub->branch, ".")) {
1086+
if (!strcmp(branch, ".")) {
10801087
unsigned char sha1[20];
10811088
const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
10821089

@@ -1094,7 +1101,7 @@ static const char *remote_submodule_branch(const char *path)
10941101
return refname;
10951102
}
10961103

1097-
return sub->branch;
1104+
return branch;
10981105
}
10991106

11001107
static int resolve_remote_submodule_branch(int argc, const char **argv,

0 commit comments

Comments
 (0)