]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'en/rev-parse-invalid-range'
authorJunio C Hamano <gitster@pobox.com>
Fri, 1 Jun 2018 06:06:39 +0000 (15:06 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jun 2018 06:06:39 +0000 (15:06 +0900)
"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

1  2 
builtin/rev-parse.c

index 55c0b904410dd4bc12420ff0cb95042d697940fe,da5748bdaef376f35fdb49125e959474913c6ad9..4f49e96bfd0166aeb6f9875a688ff0dd83d631b5
@@@ -280,8 -280,12 +280,12 @@@ static int try_difference(const char *a
                if (symmetric) {
                        struct commit_list *exclude;
                        struct commit *a, *b;
 -                      a = lookup_commit_reference(&oid);
 -                      b = lookup_commit_reference(&end);
 +                      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);