summaryrefslogtreecommitdiff
path: root/builtin/rev-parse.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-06-01 06:06:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-06-01 06:06:39 (GMT)
commit7cb4a974d339d774cb439b3d8c8f41f1ca584e6f (patch)
tree08f696973a82098d0a63e6cc1153e5560e7d81e9 /builtin/rev-parse.c
parentcaf0c98c63ac4b79a3a2e3952863b68740face10 (diff)
parent0ed556d38f90f940fdd2d9e6360b4a7544cd34e8 (diff)
downloadgit-7cb4a974d339d774cb439b3d8c8f41f1ca584e6f.zip
git-7cb4a974d339d774cb439b3d8c8f41f1ca584e6f.tar.gz
git-7cb4a974d339d774cb439b3d8c8f41f1ca584e6f.tar.bz2
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.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 55c0b90..4f49e96 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 = '^';