Re: [RFC][PATCH] object.c: use has_object() instead of repo_has_object_file()
- From
- Jonathan Tan <jonathantanmy@google.com>
- Date
- Nov 16, 2022, 21:14 UTC
- Message-ID
- <20221116211419.439356-1-jonathantanmy@google.com>
- In-Reply-To
- <Y3Up5Vi75Up8LaGQ@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 23 quoted lines
> I.e., I'd suggest this patch to remove both calls entirely:
>
> diff --git a/object.c b/object.c
> index 248530ba7b..a370545405 100644
> --- a/object.c
> +++ b/object.c
> @@ -285,9 +285,8 @@ struct object *parse_object_with_flags(struct repository *r,
> return &commit->object;
> }
>
> - if ((obj && obj->type == OBJ_BLOB && repo_has_object_file(r, oid)) ||
> - (!obj && repo_has_object_file(r, oid) &&
> - oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
> + if ((obj && obj->type == OBJ_BLOB) ||
> + (!obj && oid_object_info(r, oid, NULL) == OBJ_BLOB)) {
> if (!skip_hash && stream_object_signature(r, repl) < 0) {
> error(_("hash mismatch %s"), oid_to_hex(oid));
> return NULL;
>
> But there may be some subtlety I'm missing. I'm cc-ing Jonathan Tan, who
> added has_object(), and who added the top call to repo_has_object_file()
> via df11e19648 (rev-list: support termination at promisor objects,
> 2017-12-08).Thanks for CC-ing me on this. Looking at that commit and the code at that time, I'm not sure why I added that call either. My best guess is that I was worried that the streaming interface wouldn't support missing objects, but both then and now, a call to istream_source() is made before any streaming occurs (which does perform the lazy fetch).
So yes, I also think that you can remove these calls.