summaryrefslogtreecommitdiff
path: root/builtin/branch.c
diff options
context:
space:
mode:
authorLibravatar Jiang Xin <worldhello.net@gmail.com>2020-12-21 07:10:19 +0800
committerLibravatar Jiang Xin <worldhello.net@gmail.com>2020-12-21 07:10:19 +0800
commit3104153d5ea3bd0e68166e02ec847a895f9a76e6 (patch)
tree8b65383c203c550fab3f6ffea51cd474168ac34b /builtin/branch.c
parentl10n: Update Catalan translation (diff)
parentGit 2.30-rc1 (diff)
downloadtgif-3104153d5ea3bd0e68166e02ec847a895f9a76e6.tar.xz
Merge remote-tracking branch 'github/master' into git-po-master
* github/master: (42 commits) Git 2.30-rc1 git-gui: use gray background for inactive text widgets Another batch before 2.30-rc1 git-gui: Fix selected text colors Makefile: conditionally include GIT-VERSION-FILE git-gui: fix colored label backgrounds when using themed widgets config.mak.uname: remove old NonStop compatibility settings diff: correct interaction between --exit-code and -I<pattern> t/perf: fix test_export() failure with BSD `sed` style: do not "break" in switch() after "return" compat-util: pretend that stub setitimer() always succeeds strmap: make callers of strmap_remove() to call it in void context doc: mention Python 3.x supports index-format.txt: document v2 format of file system monitor extension docs: multi-pack-index: remove note about future 'verify' work 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 t7900: use --fixed-value in git-maintenance tests ...
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"));