X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin%2Fgrep.c;h=3d5f6ace97b806fd7dba9f8c5d62abcdbd903681;hb=385cc9d8c44eb5be9d57e630129752a72c0a08c8;hp=597f76bc42f51e0fc1906c287981e3d37dc0f536;hpb=165dc789d5e201a06e0de5a984e4529ae62027fc;p=git.git diff --git a/builtin/grep.c b/builtin/grep.c index 597f76bc4..3d5f6ace9 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -24,7 +24,7 @@ #endif static char const * const grep_usage[] = { - "git grep [options] [-e] [...] [[--] path...]", + "git grep [options] [-e] [...] [[--] ...]", NULL }; @@ -834,12 +834,12 @@ int cmd_grep(int argc, const char **argv, const char *prefix) int external_grep_allowed__ignored; const char *show_in_pager = NULL, *default_pager = "dummy"; struct grep_opt opt; - struct object_array list = { 0, 0, NULL }; + struct object_array list = OBJECT_ARRAY_INIT; const char **paths = NULL; - struct string_list path_list = { NULL, 0, 0, 0 }; + struct string_list path_list = STRING_LIST_INIT_NODUP; int i; int dummy; - int nongit = 0, use_index = 1; + int use_index = 1; struct option options[] = { OPT_BOOLEAN(0, "cached", &cached, "search in index instead of in the work tree"), @@ -930,8 +930,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) OPT_END() }; - prefix = setup_git_directory_gently(&nongit); - /* * 'git grep -h', unlike 'git grep -h ', is a request * to show usage information and exit. @@ -976,7 +974,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) PARSE_OPT_STOP_AT_NON_OPTION | PARSE_OPT_NO_INTERNAL_HELP); - if (use_index && nongit) + if (use_index && !startup_info->have_repository) /* die the same way as if we did it at the beginning */ setup_git_directory();