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

Re: [PATCH] builtin-apply: check for empty files when detecting creation patch

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
May 13, 2008, 22:58 UTC
Message-ID
<alpine.LFD.1.10.0805131552410.3019@woody.linux-foundation.org>
In-Reply-To
<7vlk2dsujm.fsf@gitster.siamese.dyndns.org>
On Tue, 13 May 2008, Junio C Hamano wrote:
Show 7 quoted lines
> Linus Torvalds <torvalds@linux-foundation.org> writes:
> >
> > So non-/dev/null'ness means absolutely nothing. It means "don't know", and 
> > we should leave is_new and is_delete as -1.
> 
> Ok, then what's the judgement for the original issue?  Is it a user error
> to have a tracked absolutely empty file in the index?
I think this is the fundamental problem:
	..
	if (patch->is_new < 0 && !oldlines) {
		patch->is_new = 1;
	..

because that logic simply isn't right. (is_new < 0 && !oldlines) does *not* mean that it must be new.

We can say it the other way around, of course:
	if (patch->is_new < 0 && oldlines)
		patch->is_new = 0;

and that's a valid rule, but I think we already would never set "is_new" to -1 if we had old lines, so that would probably be a pointless thing to do.

So: remove the check for (is_new < 0 && !oldlines) because it doesn't 
actually add any information, and leave "is_new" as unknown until later 
when we actually *see* that file or not. Hmm?
		Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 12 in “builtin-apply: check for empty files when detecting creation patch”
  1. builtin-apply: check for empty files when detecting creation patchImre Deak, May 8, 2008
  2. Junio C HamanoMay 11, 2008
  3. Imre DeakMay 13, 2008
  4. Junio C HamanoMay 13, 2008
  5. Linus TorvaldsMay 13, 2008
  6. Junio C HamanoMay 13, 2008
  7. Linus TorvaldsMay 13, 2008
  8. Junio C HamanoMay 14, 2008
  9. Linus TorvaldsMay 14, 2008
  10. Junio C HamanoMay 17, 2008
  11. 1/2 builtin-apply: accept patch to an empty fileJunio C Hamano, May 17, 2008
  12. 2/2 builtin-apply: do not declare patch is creation when we do not know itJunio C Hamano, May 17, 2008

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.