summaryrefslogtreecommitdiff
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorLibravatar Brandon Williams <bmwill@google.com>2017-08-03 11:19:49 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-08-03 13:11:01 -0700
commit177257ccc733c1a363bfbb5de630a057804cefc3 (patch)
treeb2b3cd8efee24351c0d45c7ec841c00aa7325c26 /builtin/submodule--helper.c
parentadd, reset: ensure submodules can be added or reset (diff)
downloadtgif-177257ccc733c1a363bfbb5de630a057804cefc3.tar.xz
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>
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1e49ce580e..f71f4270d9 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1066,17 +1066,24 @@ static int resolve_relative_path(int argc, const char **argv, const char *prefix
static const char *remote_submodule_branch(const char *path)
{
const struct submodule *sub;
+ const char *branch = NULL;
+ char *key;
+
gitmodules_config();
- git_config(submodule_config, NULL);
sub = submodule_from_path(&null_oid, path);
if (!sub)
return NULL;
- if (!sub->branch)
+ key = xstrfmt("submodule.%s.branch", sub->name);
+ if (repo_config_get_string_const(the_repository, key, &branch))
+ branch = sub->branch;
+ free(key);
+
+ if (!branch)
return "master";
- if (!strcmp(sub->branch, ".")) {
+ if (!strcmp(branch, ".")) {
unsigned char sha1[20];
const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
@@ -1094,7 +1101,7 @@ static const char *remote_submodule_branch(const char *path)
return refname;
}
- return sub->branch;
+ return branch;
}
static int resolve_remote_submodule_branch(int argc, const char **argv,