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 <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Aug 3, 2017 at 11:19 UTC
177257ccc733c1a363bfbb5de630a057804cefc3
1 file changed
+11
-4
builtin/submodule--helper.c
+11
-4
@@ -1066,17 +1066,24 @@ static int resolve_relative_path(int argc, const char **argv, const char *prefix
1066
static const char *remote_submodule_branch(const char *path)
1067
{
1068
const struct submodule *sub;
1069
+ const char *branch = NULL;
1070
+ char *key;
1071
+
1072
gitmodules_config();
1070
- git_config(submodule_config, NULL);
1073
1074
sub = submodule_from_path(&null_oid, path);
1075
if (!sub)
1076
return NULL;
1077
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)
1084
return "master";
1085
1079
- if (!strcmp(sub->branch, ".")) {
1086
+ if (!strcmp(branch, ".")) {
1087
unsigned char sha1[20];
1088
const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
1089
@@ -1094,7 +1101,7 @@ static const char *remote_submodule_branch(const char *path)
1101
return refname;
1102
}
1103
1097
- return sub->branch;
1104
+ return branch;
1105
}
1106
1107
static int resolve_remote_submodule_branch(int argc, const char **argv,