aboutsummaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-21 13:17:30 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-22 23:44:08 -0700
commita552de75eb01f78046feaf7dc88e5e4833624ad5 (patch)
treed069272f15dc3876743f24ed75c43f4209c004b4 /builtin-checkout.c
parent431b1969fcde69959a23355fba6894fb69c8fa0c (diff)
downloadgit-a552de75eb01f78046feaf7dc88e5e4833624ad5.tar.gz
git-a552de75eb01f78046feaf7dc88e5e4833624ad5.tar.xz
strbuf_branchname(): a wrapper for branch name shorthands
The function takes a user-supplied string that is supposed to be a branch name, and puts it in a strbuf after expanding possible shorthand notation. A handful of open coded sequence to do this in the existing code have been changed to use this helper function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index a8d9d97da..b2680466d 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -353,16 +353,11 @@ struct branch_info {
static void setup_branch_path(struct branch_info *branch)
{
struct strbuf buf = STRBUF_INIT;
- int ret;
- if ((ret = interpret_branch_name(branch->name, &buf))
- && ret == strlen(branch->name)) {
+ strbuf_branchname(&buf, branch->name);
+ if (strcmp(buf.buf, branch->name))
branch->name = xstrdup(buf.buf);
- strbuf_splice(&buf, 0, 0, "refs/heads/", 11);
- } else {
- strbuf_addstr(&buf, "refs/heads/");
- strbuf_addstr(&buf, branch->name);
- }
+ strbuf_splice(&buf, 0, 0, "refs/heads/", 11);
branch->path = strbuf_detach(&buf, NULL);
}