summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index f17d46a06e..283d64cab8 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -3,7 +3,10 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
+
#include "builtin.h"
#include "abspath.h"
#include "gettext.h"
@@ -450,7 +453,7 @@ static int grep_submodule(struct grep_opt *opt,
return 0;
subrepo = xmalloc(sizeof(*subrepo));
- if (repo_submodule_init(subrepo, superproject, path, null_oid())) {
+ if (repo_submodule_init(subrepo, superproject, path, null_oid(opt->repo->hash_algo))) {
free(subrepo);
return 0;
}
@@ -906,6 +909,7 @@ int cmd_grep(int argc,
int dummy;
int use_index = 1;
int allow_revs;
+ int ret;
struct option options[] = {
OPT_BOOL(0, "cached", &cached,
@@ -1080,7 +1084,7 @@ int cmd_grep(int argc,
}
if (show_in_pager == default_pager)
- show_in_pager = git_pager(1);
+ show_in_pager = git_pager(the_repository, 1);
if (show_in_pager) {
opt.color = 0;
opt.name_only = 1;
@@ -1140,7 +1144,7 @@ int cmd_grep(int argc,
break;
}
- object = parse_object_or_die(&oid, arg);
+ object = parse_object_or_die(the_repository, &oid, arg);
if (!seen_dashdash)
verify_non_filename(prefix, arg);
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
@@ -1172,8 +1176,10 @@ int cmd_grep(int argc,
* Optimize out the case where the amount of matches is limited to zero.
* We do this to keep results consistent with GNU grep(1).
*/
- if (opt.max_count == 0)
- return 1;
+ if (opt.max_count == 0) {
+ ret = 1;
+ goto out;
+ }
if (show_in_pager) {
if (num_threads > 1)
@@ -1240,7 +1246,7 @@ int cmd_grep(int argc,
}
if (!show_in_pager && !opt.status_only)
- setup_pager();
+ setup_pager(the_repository);
die_for_incompatible_opt3(!use_index, "--no-index",
untracked, "--untracked",
@@ -1267,10 +1273,14 @@ int cmd_grep(int argc,
hit |= wait_all();
if (hit && show_in_pager)
run_pager(&opt, prefix);
+
+ ret = !hit;
+
+out:
clear_pathspec(&pathspec);
string_list_clear(&path_list, 0);
free_grep_patterns(&opt);
object_array_clear(&list);
free_repos();
- return !hit;
+ return ret;
}