use parse_object_or_die instead of die("bad object")
[gitweb.git] / builtin / grep.c
index 29adb0ac9399002b07942711863fa3b353926468..08ea5fdec844604e6a48b9a5f6c7bbc74df651dc 100644 (file)
@@ -209,6 +209,7 @@ static void start_threads(struct grep_opt *opt)
                int err;
                struct grep_opt *o = grep_opt_dup(opt);
                o->output = strbuf_out;
+               o->debug = 0;
                compile_grep_patterns(o);
                err = pthread_create(&threads[i], NULL, run, o);
 
@@ -772,6 +773,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                           "indicate hit with exit status without output"),
                OPT_BOOLEAN(0, "all-match", &opt.all_match,
                        "show only matches from files that match all patterns"),
+               { OPTION_SET_INT, 0, "debug", &opt.debug, NULL,
+                 "show parse tree for grep expression",
+                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1 },
                OPT_GROUP(""),
                { OPTION_STRING, 'O', "open-files-in-pager", &show_in_pager,
                        "pager", "show matching files in the pager",
@@ -894,9 +898,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                unsigned char sha1[20];
                /* Is it a rev? */
                if (!get_sha1(arg, sha1)) {
-                       struct object *object = parse_object(sha1);
-                       if (!object)
-                               die(_("bad object %s"), arg);
+                       struct object *object = parse_object_or_die(sha1, arg);
                        add_object_array(object, arg, &list);
                        continue;
                }