oid_object_info(): drop type_name strbuf
We provide a mechanism for callers to get the object type as a raw string, rather than an object_type enum. This was in theory useful for returning types that are not representable in the enum, but we consider any such type to be an error, and there are no callers that use the strbuf anymore. Let's drop support to simplify the code a bit. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
May 16, 2025 at 00:49 UTC
d2956385a9319155928e2d7bc5f9d90eeac5d0a5
4 files changed
+2
-12
object-file.c
+1
-3
@@ -403,8 +403,6 @@ int parse_loose_header(const char *hdr, struct object_info *oi)
403
}
404
405
type = type_from_string_gently(type_buf, type_len, 1);
406
- if (oi->type_name)
407
- strbuf_add(oi->type_name, type_buf, type_len);
406
if (oi->typep)
407
*oi->typep = type;
408
@@ -466,7 +464,7 @@ int loose_object_info(struct repository *r,
464
* return value implicitly indicates whether the
465
* object even exists.
466
*/
469
- if (!oi->typep && !oi->type_name && !oi->sizep && !oi->contentp) {
467
+ if (!oi->typep && !oi->sizep && !oi->contentp) {
468
struct stat st;
469
if (!oi->disk_sizep && (flags & OBJECT_INFO_QUICK))
470
return quick_has_loose(r, oid) ? 0 : -1;
object-store.c
-2
@@ -646,8 +646,6 @@ static int do_oid_object_info_extended(struct repository *r,
646
*(oi->disk_sizep) = 0;
647
if (oi->delta_base_oid)
648
oidclr(oi->delta_base_oid, the_repository->hash_algo);
649
- if (oi->type_name)
650
- strbuf_addstr(oi->type_name, type_name(co->type));
649
if (oi->contentp)
650
*oi->contentp = xmemdupz(co->buf, co->size);
651
oi->whence = OI_CACHED;
object-store.h
-1
@@ -205,7 +205,6 @@ struct object_info {
205
unsigned long *sizep;
206
off_t *disk_sizep;
207
struct object_id *delta_base_oid;
208
- struct strbuf *type_name;
208
void **contentp;
209
210
/* Response */
packfile.c
+1
-6
@@ -1598,17 +1598,12 @@ int packed_object_info(struct repository *r, struct packed_git *p,
1598
*oi->disk_sizep = pack_pos_to_offset(p, pos + 1) - obj_offset;
1599
}
1600
1601
- if (oi->typep || oi->type_name) {
1601
+ if (oi->typep) {
1602
enum object_type ptot;
1603
ptot = packed_to_object_type(r, p, obj_offset,
1604
type, &w_curs, curpos);
1605
if (oi->typep)
1606
*oi->typep = ptot;
1607
- if (oi->type_name) {
1608
- const char *tn = type_name(ptot);
1609
- if (tn)
1610
- strbuf_addstr(oi->type_name, tn);
1611
- }
1607
if (ptot < 0) {
1608
type = OBJ_BAD;
1609
goto out;