]> git.99rst.org Git - git.git/commitdiff
pack-objects: drop unused return value from add_object_entry()
authorJeff King <redacted>
Wed, 15 Jul 2026 06:22:33 +0000 (08:22 +0200)
committerJunio C Hamano <redacted>
Wed, 15 Jul 2026 14:19:16 +0000 (07:19 -0700)
This function returns 0/1 to its caller to tell them whether we actually
added a new entry (or if we considered it redundant). But nobody has
relied on that behavior since 5379a5c5ee (Thin pack generation:
optimization., 2006-04-05).

The extra return does not hurt much, but it is a bit confusing. We have
a sister function, add_object_entry_from_bitmap(), which has the same
return value semantics. That function is about to change to always return
0 (not void, because it must conform to a callback function interface).
So with that change, we'd have two related functions which both return
an "int" but with different semantics.

Let's drop the unused "int" return from add_object_entry() entirely,
which makes it more clear that the two functions have diverged.

Signed-off-by: Jeff King <redacted>
[ps: slightly massaged the commit message]
Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
builtin/pack-objects.c

index ea5eab4cf841bfc33c7d181d05c7e3a1c268b4ec..188c4f6d4bd7568590f58c2b3abb31897da1c720 100644 (file)
@@ -1867,8 +1867,8 @@ static const char no_closure_warning[] = N_(
 "disabling bitmap writing, as some objects are not being packed"
 );
 
-static int add_object_entry(const struct object_id *oid, enum object_type type,
-                           const char *name, int exclude)
+static void add_object_entry(const struct object_id *oid, enum object_type type,
+                            const char *name, int exclude)
 {
        struct packed_git *found_pack = NULL;
        off_t found_offset = 0;
@@ -1876,7 +1876,7 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
        display_progress(progress_state, ++nr_seen);
 
        if (have_duplicate_entry(oid, exclude))
-               return 0;
+               return;
 
        if (!want_object_in_pack(oid, exclude, &found_pack, &found_offset)) {
                /* The pack is missing an object, so it will not have closure */
@@ -1885,13 +1885,12 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
                                warning(_(no_closure_warning));
                        write_bitmap_index = 0;
                }
-               return 0;
+               return;
        }
 
        create_object_entry(oid, type, pack_name_hash_fn(name),
                            exclude, name && no_try_delta(name),
                            found_pack, found_offset);
-       return 1;
 }
 
 static int add_object_entry_from_bitmap(const struct object_id *oid,
git clone https://git.99rst.org/PROJECT