git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] apply: guard against renames of non-existant empty files

From
René Scharfe <l.s.r@web.de>
Date
Feb 27, 2017, 22:18 UTC
Message-ID
<ed46f675-559a-88a3-cf97-d0ba7cf3112f@web.de>
In-Reply-To
<xmqqinnvwg2d.fsf@gitster.mtv.corp.google.com>
Am 27.02.2017 um 21:10 schrieb Junio C Hamano:
Show 19 quoted lines
> René Scharfe <l.s.r@web.de> writes:
>
>> Would it make sense to mirror the previously existing condition and
>> check for is_new instead?  I.e.:
>>
>> 			if ((!patch->is_delete && !patch->new_name) ||
>> 			    (!patch->is_new    && !patch->old_name)) {
>>
>
> Yes, probably.
>
>> or
>>
>> 			if (!(patch->is_delete || patch->new_name) ||
>> 			    !(patch->is_new    || patch->old_name)) {
>
> This happens after calling parse_git_header() so we should know the
> actual value of is_delete and is_new by now (instead of mistaking
> -1 aka "unknown" as true), so this rewrite would also be OK.

The two variants are logically equivalent -- (!a && !b) == !(a || b). I wonder if the second one may be harder to read, though.

René
Previous: Junio C HamanoNext: René Scharfe
Message 18 of 19 in “apply: guard against renames of non-existant empty files”
  1. 1/2 apply: guard against renames of non-existant empty filesVegard Nossum, Feb 25, 2017
  2. 2/2 apply: handle assertion failure gracefullyVegard Nossum, Feb 25, 2017
  3. René ScharfeFeb 25, 2017
  4. Junio C HamanoFeb 27, 2017
  5. René ScharfeFeb 27, 2017
  6. Junio C HamanoFeb 27, 2017
  7. René ScharfeFeb 28, 2017
  8. René ScharfeJun 27, 2017
  9. Junio C HamanoJun 27, 2017
  10. René ScharfeJun 27, 2017
  11. Junio C HamanoJun 27, 2017
  12. René ScharfeJun 27, 2017
  13. Philip OakleyFeb 25, 2017
  14. Vegard NossumFeb 25, 2017
  15. Philip OakleyFeb 25, 2017
  16. René ScharfeFeb 25, 2017
  17. Junio C HamanoFeb 27, 2017
  18. René ScharfeFeb 27, 2017
  19. René ScharfeJun 27, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.