Fix branch -m @{-1} newname
The command is supposed to rename the branch we were on before switched from to a new name, but was not aware of the short-hand notation we added recently. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 21, 2009 at 13:23 UTC
03d3aada5a2a68a7acdb6286fd72155f01626e41
1 file changed
+7
-7
builtin-branch.c
+7
-7
@@ -468,18 +468,18 @@ static void rename_branch(const char *oldname, const char *newname, int force)
468
if (!oldname)
469
die("cannot rename the current branch while not on any.");
470
471
- strbuf_addf(&oldref, "refs/heads/%s", oldname);
472
-
471
+ strbuf_branchname(&oldref, oldname);
472
+ strbuf_splice(&oldref, 0, 0, "refs/heads/", 11);
473
if (check_ref_format(oldref.buf))
474
- die("Invalid branch name: %s", oldref.buf);
475
-
476
- strbuf_addf(&newref, "refs/heads/%s", newname);
474
+ die("Invalid branch name: '%s'", oldname);
475
476
+ strbuf_branchname(&newref, newname);
477
+ strbuf_splice(&newref, 0, 0, "refs/heads/", 11);
478
if (check_ref_format(newref.buf))
479
- die("Invalid branch name: %s", newref.buf);
479
+ die("Invalid branch name: '%s'", newname);
480
481
if (resolve_ref(newref.buf, sha1, 1, NULL) && !force)
482
- die("A branch named '%s' already exists.", newname);
482
+ die("A branch named '%s' already exists.", newref.buf + 11);
483
484
strbuf_addf(&logmsg, "Branch: renamed %s to %s",
485
oldref.buf, newref.buf);