Merge branch 'jk/rev-parse-symbolic-parents-fix'
"git rev-parse --symbolic" failed with a more recent notation like "HEAD^-1" and "HEAD^!". * jk/rev-parse-symbolic-parents-fix: rev-parse: fix parent shorthands with --symbolic
This commit is contained in:
commit
598119d3cd
@ -342,11 +342,16 @@ static int try_parent_shorthands(const char *arg)
|
||||
for (parents = commit->parents, parent_number = 1;
|
||||
parents;
|
||||
parents = parents->next, parent_number++) {
|
||||
char *name = NULL;
|
||||
|
||||
if (exclude_parent && parent_number != exclude_parent)
|
||||
continue;
|
||||
|
||||
if (symbolic)
|
||||
name = xstrfmt("%s^%d", arg, parent_number);
|
||||
show_rev(include_parents ? NORMAL : REVERSED,
|
||||
parents->item->object.oid.hash, arg);
|
||||
parents->item->object.oid.hash, name);
|
||||
free(name);
|
||||
}
|
||||
|
||||
*dotdot = '^';
|
||||
|
@ -83,12 +83,24 @@ test_expect_success 'final^1^@ = final^1^1 final^1^2' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'symbolic final^1^@ = final^1^1 final^1^2' '
|
||||
git rev-parse --symbolic final^1^1 final^1^2 >expect &&
|
||||
git rev-parse --symbolic final^1^@ >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'final^1^! = final^1 ^final^1^1 ^final^1^2' '
|
||||
git rev-parse final^1 ^final^1^1 ^final^1^2 >expect &&
|
||||
git rev-parse final^1^! >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'symbolic final^1^! = final^1 ^final^1^1 ^final^1^2' '
|
||||
git rev-parse --symbolic final^1 ^final^1^1 ^final^1^2 >expect &&
|
||||
git rev-parse --symbolic final^1^! >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'large graft octopus' '
|
||||
test_cmp_rev_output b31 "git rev-parse --verify b1^30"
|
||||
'
|
||||
@ -143,6 +155,12 @@ test_expect_success 'rev-parse merge^-2 = merge^2..merge' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'symbolic merge^-1 = merge^1..merge' '
|
||||
git rev-parse --symbolic merge^1..merge >expect &&
|
||||
git rev-parse --symbolic merge^-1 >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'rev-parse merge^-0 (invalid parent)' '
|
||||
test_must_fail git rev-parse merge^-0
|
||||
'
|
||||
|
Loading…
Reference in New Issue
Block a user