diff options
Diffstat (limited to 'src/libgit2/odb.c')
-rw-r--r-- | src/libgit2/odb.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/libgit2/odb.c b/src/libgit2/odb.c index 68872e1a1..fec1e45b9 100644 --- a/src/libgit2/odb.c +++ b/src/libgit2/odb.c @@ -1494,11 +1494,16 @@ static int read_prefix_1(git_odb_object **out, git_odb *db, if (found && git_oid__cmp(&full_oid, &found_full_oid)) { git_str buf = GIT_STR_INIT; + const char *idstr; - git_str_printf(&buf, "multiple matches for prefix: %s", - git_oid_tostr_s(&full_oid)); - git_str_printf(&buf, " %s", - git_oid_tostr_s(&found_full_oid)); + if ((idstr = git_oid_tostr_s(&full_oid)) == NULL) { + git_str_puts(&buf, "failed to parse object id"); + } else { + git_str_printf(&buf, "multiple matches for prefix: %s", idstr); + + if ((idstr = git_oid_tostr_s(&found_full_oid)) != NULL) + git_str_printf(&buf, " %s", idstr); + } error = git_odb__error_ambiguous(buf.ptr); git_str_dispose(&buf); |