diff options
author | René Scharfe <l.s.r@web.de> | 2019-09-05 19:59:42 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-09-05 21:11:34 (GMT) |
commit | c77722b3ea42a87381915f1203648a5f5d86c1ff (patch) | |
tree | 44b3e742d69e5e3334b5865ae1237cc9c045f258 /builtin | |
parent | dad3f0607bf1c864f80723ab20b39527260f2c4f (diff) | |
download | git-c77722b3ea42a87381915f1203648a5f5d86c1ff.zip git-c77722b3ea42a87381915f1203648a5f5d86c1ff.tar.gz git-c77722b3ea42a87381915f1203648a5f5d86c1ff.tar.bz2 |
use get_tagged_oid()
Avoid derefencing ->tagged without checking for NULL by using the
convenience wrapper for getting the ID of the tagged object. It die()s
when encountering a broken tag instead of segfaulting.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/describe.c | 2 | ||||
-rw-r--r-- | builtin/log.c | 5 | ||||
-rw-r--r-- | builtin/replace.c | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/builtin/describe.c b/builtin/describe.c index 2001542..e048f85 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -313,7 +313,7 @@ static void describe_commit(struct object_id *oid, struct strbuf *dst) */ append_name(n, dst); if (longformat) - append_suffix(0, n->tag ? &n->tag->tagged->oid : oid, dst); + append_suffix(0, n->tag ? get_tagged_oid(n->tag) : oid, dst); if (suffix) strbuf_addstr(dst, suffix); return; diff --git a/builtin/log.c b/builtin/log.c index 44b10b3..c4b35fd 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -627,6 +627,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) break; case OBJ_TAG: { struct tag *t = (struct tag *)o; + struct object_id *oid = get_tagged_oid(t); if (rev.shown_one) putchar('\n'); @@ -638,10 +639,10 @@ int cmd_show(int argc, const char **argv, const char *prefix) rev.shown_one = 1; if (ret) break; - o = parse_object(the_repository, &t->tagged->oid); + o = parse_object(the_repository, oid); if (!o) ret = error(_("could not read object %s"), - oid_to_hex(&t->tagged->oid)); + oid_to_hex(oid)); objects[i].item = o; i--; break; diff --git a/builtin/replace.c b/builtin/replace.c index 644b21c..2a4afb3 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -421,7 +421,7 @@ static int check_one_mergetag(struct commit *commit, if (get_oid(mergetag_data->argv[i], &oid) < 0) return error(_("not a valid object name: '%s'"), mergetag_data->argv[i]); - if (oideq(&tag->tagged->oid, &oid)) + if (oideq(get_tagged_oid(tag), &oid)) return 0; /* found */ } |