提交 872f5bfb 编写于 作者: J Junio C Hamano

Merge branch 'jc/strbuf-branchname-fix' into maint

* jc/strbuf-branchname-fix:
  strbuf_branchname(): do not double-expand @{-1}~22
......@@ -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;
}
......
......@@ -27,6 +27,7 @@ test_expect_success 'merge @{-1}' '
test_commit B &&
git checkout A &&
test_commit C &&
test_commit D &&
git branch -f master B &&
git branch -f other &&
git checkout other &&
......@@ -35,14 +36,24 @@ test_expect_success 'merge @{-1}' '
git cat-file commit HEAD | grep "Merge branch '\''other'\''"
'
test_expect_success 'merge @{-1} when there is not enough switches yet' '
test_expect_success 'merge @{-1}~1' '
git checkout master &&
git reset --hard B &&
git checkout other &&
git checkout master &&
git merge @{-1}~1 &&
git cat-file commit HEAD >actual &&
grep "Merge branch '\''other'\''" actual
'
test_expect_success 'merge @{-100} before checking out that many branches yet' '
git reflog expire --expire=now &&
git checkout -f master &&
git reset --hard B &&
git branch -f other C &&
git checkout other &&
git checkout master &&
test_must_fail git merge @{-12}
test_must_fail git merge @{-100}
'
test_done
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册