diff options
Diffstat (limited to '')
-rw-r--r-- | builtin/grep.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index fe78d4c..5777ba8 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -9,15 +9,11 @@ #include "hex.h" #include "repository.h" #include "config.h" -#include "blob.h" -#include "tree.h" -#include "commit.h" #include "tag.h" #include "tree-walk.h" #include "parse-options.h" #include "string-list.h" #include "run-command.h" -#include "userdiff.h" #include "grep.h" #include "quote.h" #include "dir.h" @@ -531,7 +527,7 @@ static int grep_submodule(struct grep_opt *opt, strbuf_addstr(&base, filename); strbuf_addch(&base, '/'); - init_tree_desc(&tree, data, size); + init_tree_desc(&tree, oid, data, size); hit = grep_tree(&subopt, pathspec, &tree, &base, base.len, object_type == OBJ_COMMIT); strbuf_release(&base); @@ -575,7 +571,9 @@ static int grep_cache(struct grep_opt *opt, data = repo_read_object_file(the_repository, &ce->oid, &type, &size); - init_tree_desc(&tree, data, size); + if (!data) + die(_("unable to read tree %s"), oid_to_hex(&ce->oid)); + init_tree_desc(&tree, &ce->oid, data, size); hit |= grep_tree(opt, pathspec, &tree, &name, 0, 0); strbuf_setlen(&name, name_base_len); @@ -671,7 +669,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec, oid_to_hex(&entry.oid)); strbuf_addch(base, '/'); - init_tree_desc(&sub, data, size); + init_tree_desc(&sub, &entry.oid, data, size); hit |= grep_tree(opt, pathspec, &sub, base, tn_len, check_attr); free(data); @@ -715,7 +713,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec, strbuf_add(&base, name, len); strbuf_addch(&base, ':'); } - init_tree_desc(&tree, data, size); + init_tree_desc(&tree, &obj->oid, data, size); hit = grep_tree(opt, pathspec, &tree, &base, base.len, obj->type == OBJ_COMMIT); strbuf_release(&base); |