From: Junio C Hamano <gitster@pobox.com>
To: Jon Forrest <nobozo@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Minor Bug in git cat-file (git 2.50)?
Date: Mon, 11 Aug 2025 08:09:28 -0700 [thread overview]
Message-ID: <xmqqtt2d51zr.fsf@gitster.g> (raw)
In-Reply-To: <b37629c6-b730-45ce-b839-e782aafe238d@gmail.com> (Jon Forrest's message of "Sun, 10 Aug 2025 07:52:42 -0700")
Jon Forrest <nobozo@gmail.com> writes:
> % ls
> 981922613b2afb6025042ff6bd878ac1994e85
> 981922613b2afb6025042ff6bd878ac1994e86
> % popd
> # use an ambiguous SHA1 prefix
> # why does the next command produce two identical hints, both of which
> # are incorrect?
> % git cat-file -t 78981922613b2afb6025042ff6bd878ac1994e8
> error: short object ID 78981922613b2afb6025042ff6bd878ac1994e8 is
> ambiguous # this is correct
> hint: The candidates are:
> hint: 7898192 blob
> hint: 7898192 blob
> fatal: Not a valid object name 78981922613b2afb6025042ff6bd878ac1994e8
> # I would have expected:
> hint: 78981922613b2afb6025042ff6bd878ac1994e85 blob
> hint: 78981922613b2afb6025042ff6bd878ac1994e86 blob
> # using the supplied hint doesn't work, which is no surprise
> % git cat-file -t 7898192
> fatal: Not a valid object name 7898192
Fun.
I do not think disambiguation code inspects object validity to
filter out invalid one when computing the shortened object name when
giving hints, so one of these two being a corrupt object should not
have anything to do with this outcome.
Perhaps something like this would help?
object-name.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git c/object-name.c w/object-name.c
index 11aa0e6afc..13e8a4e47d 100644
--- c/object-name.c
+++ w/object-name.c
@@ -704,7 +704,7 @@ static int extend_abbrev_len(const struct object_id *oid, void *cb_data)
while (mad->hex[i] && mad->hex[i] == get_hex_char_from_oid(oid, i))
i++;
- if (i < GIT_MAX_RAWSZ && i >= mad->cur_len)
+ if (i < GIT_MAX_HEXSZ && i >= mad->cur_len)
mad->cur_len = i + 1;
return 0;
prev parent reply other threads:[~2025-08-11 15:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 14:52 Minor Bug in git cat-file (git 2.50)? Jon Forrest
2025-08-11 8:54 ` Patrick Steinhardt
2025-08-11 19:10 ` Jon Forrest
2025-08-11 15:09 ` Junio C Hamano [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqtt2d51zr.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=nobozo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).