summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-10-27 15:09:46 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-10-27 15:09:46 -0700
commitae84e924dafbaf1eb907065e9fc9c246acb2c265 (patch)
treef1772106851cabdd043098b30250c62a1c712d6d /builtin
parentMerge branch 'rs/dist-doc-with-git-archive' (diff)
parentline-log: handle deref_tag() returning NULL (diff)
downloadtgif-ae84e924dafbaf1eb907065e9fc9c246acb2c265.tar.xz
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')
-rw-r--r--builtin/blame.c2
-rw-r--r--builtin/grep.c11
2 files changed, 13 insertions, 0 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index bb0f29300e..b5036ab327 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -820,6 +820,8 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
if (kind != OBJ_TAG)
return -1;
obj = deref_tag(r, parse_object(r, &oid), NULL, 0);
+ if (!obj)
+ return -1;
oidcpy(&oid, &obj->oid);
}
}
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);