Imported Upstream version 2.30.0
[platform/upstream/git.git] / builtin / branch.c
index efb30b8..9b68591 100644 (file)
@@ -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"));
@@ -829,10 +831,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                        die(_("Branch '%s' has no upstream information"), branch->name);
 
                strbuf_addf(&buf, "branch.%s.remote", branch->name);
-               git_config_set_multivar(buf.buf, NULL, NULL, 1);
+               git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
                strbuf_reset(&buf);
                strbuf_addf(&buf, "branch.%s.merge", branch->name);
-               git_config_set_multivar(buf.buf, NULL, NULL, 1);
+               git_config_set_multivar(buf.buf, NULL, NULL, CONFIG_FLAGS_MULTI_REPLACE);
                strbuf_release(&buf);
        } else if (argc > 0 && argc <= 2) {
                if (filter.kind != FILTER_REFS_BRANCHES)