Merge branch 'ps/grep-help-all-callback-arg'
authorJunio C Hamano <gitster@pobox.com>
Mon, 20 Apr 2015 22:28:34 +0000 (15:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Apr 2015 22:28:34 +0000 (15:28 -0700)
Code clean-up.

* ps/grep-help-all-callback-arg:
grep: correctly initialize help-all option

1  2 
builtin/grep.c
diff --combined builtin/grep.c
index abc440023ff98e354a92f002419b52836e4155c0,709d20eb9e510ee0724a22b4212373f48dfc2fff..d04f4400d9db8ef9f0b0dde0c8be46a11bd0e2f7
@@@ -20,7 -20,7 +20,7 @@@
  #include "pathspec.h"
  
  static char const * const grep_usage[] = {
 -      N_("git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]"),
 +      N_("git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]"),
        NULL
  };
  
@@@ -361,7 -361,9 +361,7 @@@ static void run_pager(struct grep_opt *
                argv[i] = path_list->items[i].string;
        argv[path_list->nr] = NULL;
  
 -      if (prefix && chdir(prefix))
 -              die(_("Failed to chdir: %s"), prefix);
 -      status = run_command_v_opt(argv, RUN_USING_SHELL);
 +      status = run_command_v_opt_cd_env(argv, RUN_USING_SHELL, prefix, NULL);
        if (status)
                exit(status);
        free(argv);
@@@ -456,10 -458,10 +456,10 @@@ static int grep_tree(struct grep_opt *o
  }
  
  static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
 -                     struct object *obj, const char *name, struct object_context *oc)
 +                     struct object *obj, const char *name, const char *path)
  {
        if (obj->type == OBJ_BLOB)
 -              return grep_sha1(opt, obj->sha1, name, 0, oc ? oc->path : NULL);
 +              return grep_sha1(opt, obj->sha1, name, 0, path);
        if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {
                struct tree_desc tree;
                void *data;
@@@ -501,7 -503,7 +501,7 @@@ static int grep_objects(struct grep_op
        for (i = 0; i < nr; i++) {
                struct object *real_obj;
                real_obj = deref_tag(list->objects[i].item, NULL, 0);
 -              if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].context)) {
 +              if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path)) {
                        hit = 1;
                        if (opt->status_only)
                                break;
@@@ -641,7 -643,7 +641,7 @@@ int cmd_grep(int argc, const char **arg
                OPT_BOOL(0, "untracked", &untracked,
                        N_("search in both tracked and untracked files")),
                OPT_SET_INT(0, "exclude-standard", &opt_exclude,
 -                          N_("search also in ignored files"), 1),
 +                          N_("ignore files specified via '.gitignore'"), 1),
                OPT_GROUP(""),
                OPT_BOOL('v', "invert-match", &opt.invert,
                        N_("show non-matching lines")),
                        PARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },
                OPT_BOOL(0, "ext-grep", &external_grep_allowed__ignored,
                         N_("allow calling of grep(1) (ignored by this build)")),
-               { OPTION_CALLBACK, 0, "help-all", &options, NULL, N_("show usage"),
+               { OPTION_CALLBACK, 0, "help-all", NULL, NULL, N_("show usage"),
                  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, help_callback },
                OPT_END()
        };
                        struct object *object = parse_object_or_die(sha1, arg);
                        if (!seen_dashdash)
                                verify_non_filename(prefix, arg);
 -                      add_object_array_with_context(object, arg, &list, xmemdupz(&oc, sizeof(struct object_context)));
 +                      add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
                        continue;
                }
                if (!strcmp(arg, "--")) {
                }
        }
  
 -      if (!show_in_pager)
 +      if (!show_in_pager && !opt.status_only)
                setup_pager();
  
        if (!use_index && (untracked || cached))