[PATCH 3/9] send-pack/transport-helper: respect `core.defaultBranchName`
- From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Jun 10, 2020, 21:19 UTC
- Message-ID
- <c9c9c81068e24972e084956aa3b09a3ec0eb98c1.1591823971.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.656.git.1591823971.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>
When mentioning the default branch name in an error message, we want to go with the preference specified by the user.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> --- send-pack.c | 6 +++++- transport-helper.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/send-pack.c b/send-pack.c index 0abee22283d..f7747bed1c9 100644 --- a/send-pack.c +++ b/send-pack.c @@ -405,8 +405,12 @@ int send_pack(struct send_pack_args *args, } if (!remote_refs) { + char *branch_name = git_default_branch_name(1); + fprintf(stderr, "No refs in common and none specified; doing nothing.\n" - "Perhaps you should specify a branch such as 'master'.\n"); + "Perhaps you should specify a branch such as '%s'.\n", + branch_name); + free(branch_name); return 0; } if (args->atomic && !atomic_supported) diff --git a/transport-helper.c b/transport-helper.c index a46afcb69db..cc8ae5c67ca 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -1044,9 +1044,13 @@ static int push_refs(struct transport *transport, } if (!remote_refs) { + char *branch_name = git_default_branch_name(1); + fprintf(stderr, _("No refs in common and none specified; doing nothing.\n" - "Perhaps you should specify a branch such as 'master'.\n")); + "Perhaps you should specify a branch such as '%s'.\n"), + branch_name); + free(branch_name); return 0; }
-- gitgitgadget