aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-10-27 15:09:46 -0700
committerJunio C Hamano <gitster@pobox.com>2020-10-27 15:09:46 -0700
commitae84e924dafbaf1eb907065e9fc9c246acb2c265 (patch)
treef1772106851cabdd043098b30250c62a1c712d6d /builtin/grep.c
parent63e52739d272278d89dc9f2a78d1f9887ef28732 (diff)
parent5eb2ed691b809a55b024b8c10739254ea2ac48b7 (diff)
downloadgit-ae84e924dafbaf1eb907065e9fc9c246acb2c265.tar.gz
Merge branch 'rs/tighten-callers-of-deref-tag'
Code clean-up. * rs/tighten-callers-of-deref-tag: line-log: handle deref_tag() returning NULL blame: handle deref_tag() returning NULL grep: handle deref_tag() returning NULL
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index c8037388c6..e58e57504c 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -670,6 +670,17 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
NULL, 0);
obj_read_unlock();
+ if (!real_obj) {
+ char hex[GIT_MAX_HEXSZ + 1];
+ const char *name = list->objects[i].name;
+
+ if (!name) {
+ oid_to_hex_r(hex, &list->objects[i].item->oid);
+ name = hex;
+ }
+ die(_("invalid object '%s' given."), name);
+ }
+
/* load the gitmodules file for this rev */
if (recurse_submodules) {
submodule_free(opt->repo);