Re: [RFC PATCH 1/9] rebase -i: only write fixup-message when it's needed
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 15, 2021, 17:22 UTC
- Message-ID
- <xmqqbldqt8rm.fsf@gitster.c.googlers.com>
- In-Reply-To
- <CAPSFM5eBCVD9sx-AkA6Zr-PAq3JgTftcf2UhZBcBmK_00ff1+Q@mail.gmail.com>
Charvi Mendiratta <charvi077@gmail.com> writes:
Show 5 quoted lines
> Okay, I looked into the write_message(...) and agree that it does not return > a positive value and only returns non-zero for error case and zero for > success. So, for this patch maybe we can ignore checking '< 0' here and > later add another patch to make this function follow the convention of > "negative is error".
Please don't. There is a higher cognitive cost to readers when you write
if (write_message(...)) {The reader is forced to look at its implementation to see if it returns positive in a non-error situation.
If you write it like so from the beginning
if (write_message(...) < 0) {the reader can trust that the code follows "negative is an error" convention. One fewer thing readers have to worry about.