Thread (4 messages) flat view 4 messages, 2 authors, 2016-06-15

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

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:44:36

Possibly related (same subject, not in this thread)


On Tue, 13 May 2008, Junio C Hamano wrote:
Linus Torvalds [off-list ref] writes:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help