Merge branch 'en/rev-parse-invalid-range'
"git rev-parse Y..." etc. misbehaved when given endpoints were not committishes. * en/rev-parse-invalid-range: rev-parse: check lookup'ed commit references for NULL
This commit is contained in:
@ -282,6 +282,10 @@ static int try_difference(const char *arg)
|
|||||||
struct commit *a, *b;
|
struct commit *a, *b;
|
||||||
a = lookup_commit_reference(&start_oid);
|
a = lookup_commit_reference(&start_oid);
|
||||||
b = lookup_commit_reference(&end_oid);
|
b = lookup_commit_reference(&end_oid);
|
||||||
|
if (!a || !b) {
|
||||||
|
*dotdot = '.';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
exclude = get_merge_bases(a, b);
|
exclude = get_merge_bases(a, b);
|
||||||
while (exclude) {
|
while (exclude) {
|
||||||
struct commit *commit = pop_commit(&exclude);
|
struct commit *commit = pop_commit(&exclude);
|
||||||
@ -328,12 +332,12 @@ static int try_parent_shorthands(const char *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*dotdot = 0;
|
*dotdot = 0;
|
||||||
if (get_oid_committish(arg, &oid)) {
|
if (get_oid_committish(arg, &oid) ||
|
||||||
|
!(commit = lookup_commit_reference(&oid))) {
|
||||||
*dotdot = '^';
|
*dotdot = '^';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
commit = lookup_commit_reference(&oid);
|
|
||||||
if (exclude_parent &&
|
if (exclude_parent &&
|
||||||
exclude_parent > commit_list_count(commit->parents)) {
|
exclude_parent > commit_list_count(commit->parents)) {
|
||||||
*dotdot = '^';
|
*dotdot = '^';
|
||||||
|
@ -214,4 +214,12 @@ test_expect_success 'rev-list merge^-1x (garbage after ^-1)' '
|
|||||||
test_must_fail git rev-list merge^-1x
|
test_must_fail git rev-list merge^-1x
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rev-parse $garbage^@ does not segfault' '
|
||||||
|
test_must_fail git rev-parse $EMPTY_TREE^@
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'rev-parse $garbage...$garbage does not segfault' '
|
||||||
|
test_must_fail git rev-parse $EMPTY_TREE...$EMPTY_BLOB
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user