From 177257ccc733c1a363bfbb5de630a057804cefc3 Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Thu, 3 Aug 2017 11:19:49 -0700 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- builtin/submodule--helper.c | 15 +++++++++++---- 1 file 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, -- 2.11.4.GIT