Re: [PATCH 0/6] getwholeline should clear the buffer upon EOF
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 23, 2026, 15:37 UTC
- Message-ID
- <xmqq4id7d0ep.fsf@gitster.g>
- In-Reply-To
- <20261122140347.41990-1-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> time. Because the code that caused the existing bugs does not appear in > any of these steps, the log messages of patches 2-4 instead give > detailed walkthroughs and are rather long, which is another reason why > the nature of this series discourages following the usual pattern and > doing everything in one step.
By the way, I _could_ have instead called strbuf_reset() at strategic places in patches 2-4 to "fix" the bug without touching the root cause, i.e., strbuf_getwholeline(), and added test_expect_success tests. That way, the commit log messages for these steps did not have to be such a detailed walkthrough of how the bugs happen, simply because the code that make problematic decisions based on a wrong assumption can be read in the context of these changes. Which requires patch 5 that fixes the root cause to revert these tentative "fixes" to call strbuf_reset() which becomes unnecessary when strbuf_getwholeline() stops leaving the stale contents in the buffer upon feof().
I chose not to do so, as a series that adds some code in an early step and immediately removes the same code in a later step is awkward and wasteful.