summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 55c4a67)
raw | patch | inline | side by side (parent: 55c4a67)
author | Conrad Irwin <conrad.irwin@gmail.com> | |
Sat, 20 Aug 2011 21:49:49 +0000 (14:49 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 22 Aug 2011 23:03:43 +0000 (16:03 -0700) |
Change the error message when doing: "git branch @{-1}",
"git checkout -b @{-1}", or "git branch -m foo @{-1}"
* was: A branch named '@{-1}' already exists.
* now: A branch named 'bar' already exists.
Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
"git checkout -b @{-1}", or "git branch -m foo @{-1}"
* was: A branch named '@{-1}' already exists.
* now: A branch named 'bar' already exists.
Signed-off-by: Conrad Irwin <conrad.irwin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch.c | patch | blob | history | |
t/t2018-checkout-branch.sh | patch | blob | history |
diff --git a/branch.c b/branch.c
index ff84b5b9b70280123343c20db66424f7dee349c6..1fe3078a6cade3c34c5dcd65977b286840bec6ee 100644 (file)
--- a/branch.c
+++ b/branch.c
if (!ref_exists(ref->buf))
return 0;
else if (!force)
- die("A branch named '%s' already exists.", name);
+ die("A branch named '%s' already exists.", ref->buf + strlen("refs/heads/"));
head = resolve_ref("HEAD", sha1, 0, NULL);
if (!is_bare_repository() && head && !strcmp(head, ref->buf))
index b66db2b8818b7b084889ea1b2c7687fc59c12127..75874e85dfbcae8ea9634693a93524841b741559 100755 (executable)
test_must_fail do_checkout branch2 $HEAD2
'
+test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
+ git reset --hard HEAD &&
+ git checkout branch1 &&
+ git checkout branch2 &&
+ echo >expect "fatal: A branch named '\''branch1'\'' already exists." &&
+ test_must_fail git checkout -b @{-1} 2>actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
git checkout branch1 &&