git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH v2 4/7] Fix branch -m @{-1} newname
Date: Mon, 23 Mar 2009 00:58:37 -0700	[thread overview]
Message-ID: <03d3aada5a2a68a7acdb6286fd72155f01626e41.1237791716.git.gitster@pobox.com> (raw)
In-Reply-To: <a31dca0393fefae894b7a155ae24000107bcc383.1237791716.git.gitster@pobox.com>
In-Reply-To: <cover.1237791716.git.gitster@pobox.com>

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>
---
 builtin-branch.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index 7452db1..0df82bf 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -468,18 +468,18 @@ static void rename_branch(const char *oldname, const char *newname, int force)
 	if (!oldname)
 		die("cannot rename the current branch while not on any.");
 
-	strbuf_addf(&oldref, "refs/heads/%s", oldname);
-
+	strbuf_branchname(&oldref, oldname);
+	strbuf_splice(&oldref, 0, 0, "refs/heads/", 11);
 	if (check_ref_format(oldref.buf))
-		die("Invalid branch name: %s", oldref.buf);
-
-	strbuf_addf(&newref, "refs/heads/%s", newname);
+		die("Invalid branch name: '%s'", oldname);
 
+	strbuf_branchname(&newref, newname);
+	strbuf_splice(&newref, 0, 0, "refs/heads/", 11);
 	if (check_ref_format(newref.buf))
-		die("Invalid branch name: %s", newref.buf);
+		die("Invalid branch name: '%s'", newname);
 
 	if (resolve_ref(newref.buf, sha1, 1, NULL) && !force)
-		die("A branch named '%s' already exists.", newname);
+		die("A branch named '%s' already exists.", newref.buf + 11);
 
 	strbuf_addf(&logmsg, "Branch: renamed %s to %s",
 		 oldref.buf, newref.buf);
-- 
1.6.2.1.349.ga64c

  reply	other threads:[~2009-03-23  8:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-23  7:58 [PATCH v2 0/7] Clean up interpret_nth_last_branch feature Junio C Hamano
2009-03-23  7:58 ` [PATCH v2 1/7] Rename interpret/substitute nth_last_branch functions Junio C Hamano
2009-03-23  7:58   ` [PATCH v2 2/7] strbuf_branchname(): a wrapper for branch name shorthands Junio C Hamano
2009-03-23  7:58     ` [PATCH v2 3/7] check-ref-format --branch: give Porcelain a way to grok branch shorthand Junio C Hamano
2009-03-23  7:58       ` Junio C Hamano [this message]
2009-03-23  7:58         ` [PATCH v2 5/7] strbuf_check_branch_ref(): a helper to check a refname for a branch Junio C Hamano
2009-03-23  7:58           ` [PATCH v2 6/7] check_ref_format(): tighten refname rules Junio C Hamano
2009-03-23  7:58             ` [PATCH v2 7/7] checkout -: make "-" to mean "previous branch" everywhere Junio C Hamano
2009-03-23 13:59             ` [PATCH v2 6/7] check_ref_format(): tighten refname rules Shawn O. Pearce
2009-03-23 16:03               ` Junio C Hamano
2009-03-23  8:10 ` [PATCH v2 0/7] Clean up interpret_nth_last_branch feature Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=03d3aada5a2a68a7acdb6286fd72155f01626e41.1237791716.git.gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).