diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-06-01 15:06:39 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-01 15:06:39 +0900 |
commit | 7cb4a974d339d774cb439b3d8c8f41f1ca584e6f (patch) | |
tree | 08f696973a82098d0a63e6cc1153e5560e7d81e9 /builtin/rev-parse.c | |
parent | caf0c98c63ac4b79a3a2e3952863b68740face10 (diff) | |
parent | 0ed556d38f90f940fdd2d9e6360b4a7544cd34e8 (diff) | |
download | git-7cb4a974d339d774cb439b3d8c8f41f1ca584e6f.tar.gz |
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
Diffstat (limited to 'builtin/rev-parse.c')
-rw-r--r-- | builtin/rev-parse.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 55c0b90441..4f49e96bfd 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -282,6 +282,10 @@ static int try_difference(const char *arg) struct commit *a, *b; a = lookup_commit_reference(&start_oid); b = lookup_commit_reference(&end_oid); + if (!a || !b) { + *dotdot = '.'; + return 0; + } exclude = get_merge_bases(a, b); while (exclude) { struct commit *commit = pop_commit(&exclude); @@ -328,12 +332,12 @@ static int try_parent_shorthands(const char *arg) return 0; *dotdot = 0; - if (get_oid_committish(arg, &oid)) { + if (get_oid_committish(arg, &oid) || + !(commit = lookup_commit_reference(&oid))) { *dotdot = '^'; return 0; } - commit = lookup_commit_reference(&oid); if (exclude_parent && exclude_parent > commit_list_count(commit->parents)) { *dotdot = '^'; |