branch: fix "copy" to never touch HEAD
[gitweb.git] / builtin / branch.c
index 89f64f4123a5ef609a20324606f23157b901d4e8..e2e3692838e305b7ab8e569fecf6ae8b3a73e6ac 100644 (file)
@@ -506,12 +506,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
                                oldref.buf + 11);
        }
 
-       if (replace_each_worktree_head_symref(oldref.buf, newref.buf, logmsg.buf)) {
-               if (copy)
-                       die(_("Branch copied to %s, but HEAD is not updated!"), newname);
-               else
-                       die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
-       }
+       if (!copy &&
+           replace_each_worktree_head_symref(oldref.buf, newref.buf, logmsg.buf))
+               die(_("Branch renamed to %s, but HEAD is not updated!"), newname);
 
        strbuf_release(&logmsg);