summaryrefslogtreecommitdiff
path: root/builtin/branch.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-12-18 15:15:17 -0800
committerJunio C Hamano <gitster@pobox.com>2020-12-18 15:15:17 -0800
commit772bdcd4296b259d52aafb0badd79872e9db3bb3 (patch)
treedac15d162ac6aae28d0e3cfdd287d66767621c21 /builtin/branch.c
parentf4d8e191230b3d233005720085092b97e9bf32f1 (diff)
parent675704c74dd4476f455bfa91e72eb9e163317c10 (diff)
downloadgit-772bdcd4296b259d52aafb0badd79872e9db3bb3.tar.gz
Merge branch 'js/init-defaultbranch-advice'
Our users are going to be trained to prepare for future change of init.defaultBranch configuration variable. * js/init-defaultbranch-advice: init: provide useful advice about init.defaultBranch get_default_branch_name(): prepare for showing some advice branch -m: allow renaming a yet-unborn branch init: document `init.defaultBranch` better
Diffstat (limited to 'builtin/branch.c')
-rw-r--r--builtin/branch.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index 173b736dff..9b68591add 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -538,7 +538,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
strbuf_addf(&logmsg, "Branch: renamed %s to %s",
oldref.buf, newref.buf);
- if (!copy && rename_ref(oldref.buf, newref.buf, logmsg.buf))
+ if (!copy &&
+ (!head || strcmp(oldname, head) || !is_null_oid(&head_oid)) &&
+ rename_ref(oldref.buf, newref.buf, logmsg.buf))
die(_("Branch rename failed"));
if (copy && copy_existing_ref(oldref.buf, newref.buf, logmsg.buf))
die(_("Branch copy failed"));