From: Johannes Schindelin via GitGitGadget Date: Wed, 10 Jun 2020 21:19:26 GMT Subject: [PATCH 5/9] submodule: use the (possibly overridden) default branch name Message-ID: <06ef42052d534a668bf5227e79f1ca3b5c6aa2c1.1591823971.git.gitgitgadget@gmail.com> In-Reply-To: From: Johannes Schindelin To allow for overriding the default branch name, we have introduced a config setting. With this patch, the `git submodule` command learns about this, too. Signed-off-by: Johannes Schindelin --- builtin/submodule--helper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 46c03d2a126..0b4abb5a64b 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1980,8 +1980,14 @@ static const char *remote_submodule_branch(const char *path) branch = sub->branch; free(key); - if (!branch) - return "master"; + if (!branch) { + static char *default_branch; + + if (!default_branch) + default_branch = git_default_branch_name(1); + + return default_branch; + } if (!strcmp(branch, ".")) { const char *refname = resolve_ref_unsafe("HEAD", 0, NULL, NULL); -- gitgitgadget