]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/grep.c
Merge branch 'rs/grep-no-no-or' into maint-2.42
[thirdparty/git.git] / builtin / grep.c
index 3486cb924496eae45b8947eaf0e19d09b12a9148..2a261074f16c4be5c9c8e3e3ec11a8e1aecebfa3 100644 (file)
@@ -3,7 +3,9 @@
  *
  * Copyright (c) 2006 Junio C Hamano
  */
-#include "cache.h"
+#include "builtin.h"
+#include "gettext.h"
+#include "hex.h"
 #include "repository.h"
 #include "config.h"
 #include "blob.h"
@@ -11,7 +13,6 @@
 #include "commit.h"
 #include "tag.h"
 #include "tree-walk.h"
-#include "builtin.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "quote.h"
 #include "dir.h"
 #include "pathspec.h"
+#include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
-#include "object-store.h"
+#include "object-file.h"
+#include "object-name.h"
+#include "object-store-ll.h"
 #include "packfile.h"
+#include "pager.h"
+#include "path.h"
+#include "read-cache-ll.h"
+#include "write-or-die.h"
 
 static const char *grep_prefix;
 
@@ -282,14 +290,18 @@ static int wait_all(void)
        return hit;
 }
 
-static int grep_cmd_config(const char *var, const char *value, void *cb)
+static int grep_cmd_config(const char *var, const char *value,
+                          const struct config_context *ctx, void *cb)
 {
-       int st = grep_config(var, value, cb);
-       if (git_color_default_config(var, value, NULL) < 0)
+       int st = grep_config(var, value, ctx, cb);
+
+       if (git_color_config(var, value, cb) < 0)
+               st = -1;
+       else if (git_default_config(var, value, ctx, cb) < 0)
                st = -1;
 
        if (!strcmp(var, "grep.threads")) {
-               num_threads = git_config_int(var, value);
+               num_threads = git_config_int(var, value, ctx->kvi);
                if (num_threads < 0)
                        die(_("invalid number of threads specified (%d) for %s"),
                            num_threads, var);
@@ -560,7 +572,8 @@ static int grep_cache(struct grep_opt *opt,
                        void *data;
                        unsigned long size;
 
-                       data = read_object_file(&ce->oid, &type, &size);
+                       data = repo_read_object_file(the_repository, &ce->oid,
+                                                    &type, &size);
                        init_tree_desc(&tree, data, size);
 
                        hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0);
@@ -630,7 +643,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
                        strbuf_addstr(&name, base->buf + tn_len);
                        match = tree_entry_interesting(repo->index,
                                                       &entry, &name,
-                                                      0, pathspec);
+                                                      pathspec);
                        strbuf_setlen(&name, name_base_len);
 
                        if (match == all_entries_not_interesting)
@@ -650,7 +663,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
                        void *data;
                        unsigned long size;
 
-                       data = read_object_file(&entry.oid, &type, &size);
+                       data = repo_read_object_file(the_repository,
+                                                    &entry.oid, &type, &size);
                        if (!data)
                                die(_("unable to read tree (%s)"),
                                    oid_to_hex(&entry.oid));