list-objects.c: don't segfault for missing cmdline objects
[gitweb.git] / revision.c
index b5108b75abc9ff0ef0438f4cba2e932e935ff94f..07dc0e28b60ce0072a53fcfd86061016f5708bdd 100644 (file)
@@ -1717,6 +1717,8 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
        if (!cant_be_filename)
                verify_non_filename(revs->prefix, arg);
        object = get_reference(revs, arg, &oid, flags ^ local_flags);
+       if (!object)
+               return revs->ignore_missing ? 0 : -1;
        add_rev_cmdline(revs, object, arg_, REV_CMD_REV, flags ^ local_flags);
        add_pending_object_with_path(revs, object, arg, oc.mode, oc.path);
        free(oc.path);