sparse-checkout: reuse --stdin buffer when reading patterns
commitc3324649ed5af972c9e91740b46a6e2a063050d4
authorJeff King <peff@peff.net>
Tue, 4 Jun 2024 10:13:25 +0000 (4 06:13 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Jun 2024 16:51:42 +0000 (5 09:51 -0700)
tree65814ae833e9738054bf45f21aa993ab4da54199
parenteed1fbe73b46e5c7f87d724f97fba6d8a4391fc9
sparse-checkout: reuse --stdin buffer when reading patterns

When we read patterns from --stdin, we loop on strbuf_getline(), and
detach each line we read to pass into add_pattern(). This used to be
necessary because add_pattern() required that the pattern strings remain
valid while the pattern_list was in use. But it also created a leak,
since we didn't record the detached buffers anywhere else.

Now that add_pattern() has been modified to make its own copy of the
strings, we can stop detaching and fix the leak. This fixes 4 leaks
detected in t1091.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/sparse-checkout.c