summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2013-06-02 15:58:53 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-06-02 15:58:53 -0700
commit9a92cd1ce60babd661080f2b6a54f57fbfe133ae (patch)
tree2bd4fb36fbc1fd793e287effc1cf7a45ad3c8ec2 /sha1_name.c
parentMerge branch 'jk/fetch-always-update-tracking' (diff)
parentstrbuf_branchname(): do not double-expand @{-1}~22 (diff)
downloadtgif-9a92cd1ce60babd661080f2b6a54f57fbfe133ae.tar.xz
Merge branch 'jc/strbuf-branchname-fix'
"git merge @{-1}~22" was rewritten to "git merge frotz@{1}~22" incorrectly when your previous branch was "frotz" (it should be rewritten to "git merge frotz~22" instead). * jc/strbuf-branchname-fix: strbuf_branchname(): do not double-expand @{-1}~22
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 3820f28ae7..371a49d98d 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1055,9 +1055,13 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
int strbuf_branchname(struct strbuf *sb, const char *name)
{
int len = strlen(name);
- if (interpret_branch_name(name, sb) == len)
+ int used = interpret_branch_name(name, sb);
+
+ if (used == len)
return 0;
- strbuf_add(sb, name, len);
+ if (used < 0)
+ used = 0;
+ strbuf_add(sb, name + used, len - used);
return len;
}