]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/pack-objects.c: remove unnecessary strbuf_reset()
authorTaylor Blau <me@ttaylorr.com>
Mon, 28 Aug 2023 22:49:04 +0000 (18:49 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Aug 2023 17:26:44 +0000 (10:26 -0700)
When reading input with the `--cruft` option, `git pack-objects` reads
each line into a strbuf, and then moves it to either the list of
discarded or fresh packs, depending on whether or not the input line
starts with a '-' character.

At the beginning of each loop iteration, the next line of input is read
with `strbuf_getline()`, which calls `strbuf_reset()` (as a part of
`strbuf_getwholeline()`) before reading the next line of input.

Thus, the call to `strbuf_reset()` (added back in b757353676
(builtin/pack-objects.c: --cruft without expiration, 2022-05-20)) at the
end of the loop is unnecessary, so let's remove it accordingly.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c

index d2a162d52804cf7fdf1fd1a11303f2380c24c9e3..868efe7e0f477ec640c24a957fee977c70e20abd 100644 (file)
@@ -3603,7 +3603,6 @@ static void read_cruft_objects(void)
                        string_list_append(&discard_packs, buf.buf + 1);
                else
                        string_list_append(&fresh_packs, buf.buf);
-               strbuf_reset(&buf);
        }
 
        string_list_sort(&discard_packs);