format-patch: add --interdiff option to embed diff in cover letter
[gitweb.git] / builtin / rev-parse.c
index 55c0b904410dd4bc12420ff0cb95042d697940fe..2a6cb298bdab7961a73df16c4984ff9eefef7795 100644 (file)
@@ -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 = '^';
@@ -879,7 +883,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
                                continue;
                        }
                        if (!strcmp(arg, "--is-shallow-repository")) {
-                               printf("%s\n", is_repository_shallow() ? "true"
+                               printf("%s\n",
+                                               is_repository_shallow(the_repository) ? "true"
                                                : "false");
                                continue;
                        }