From: Linus Torvalds <torvalds@linux-foundation.org>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Francis Moreau <francis.moro@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org
Subject: Re: Why doesn't git-apply remove empty file
Date: Wed, 13 Aug 2008 16:09:46 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.1.10.0808131602200.3462@nehalem.linux-foundation.org> (raw)
In-Reply-To: <48A357BA.8060003@lsrfire.ath.cx>
On Wed, 13 Aug 2008, René Scharfe wrote:
>
> I bet you are using GNU patch. It removes files that are empty after
> patching and you need to specify --posix to make it keep empty files.
GNU patch' behavior wrt empty files is a bit more complex than that. It's
true that you can disable it all with the POSIX mode (not that anybody
ever does), but it's not an unconditional removal, I think.
It does look at the date of the destination if there is one, ie according
to the man-page:
"You can create a file by sending out a diff that compares /dev/null or
an empty file dated the Epoch (1970-01-01 00:00:00 UTC) to the file you
want to create. This only works if the file you want to create doesn’t
exist already in the target directory. Conversely, you can remove a
file by sending out a context diff that compares the file to be deleted
with an empty file dated the Epoch. The file will be removed unless
patch is conforming to POSIX and the -E or --remove-empty-files option
is not given. An easy way to generate patches that create and remove
files is to use GNU diff’s -N or --new-file option."
and no, git never did that file date thing, so git acts differently from
GNU patch in this thing (as in so many others, for that matter).
I don't think it would necessarily be wrong to try to emulate GNU patch
for the case where git is guessing at removal, though (ie for the
"traditional diff" case - for a "git diff", the removal question is
unambiguous thanks to the git extensions, of course).
That said, I'm also not personally very motivated to add yet another odd
GNU patch behavior quirk. Especially as we very much try to avoid parsing
that insane and not-well-specified date format anyway, and just ignore it.
But if somebody sends out a tested patch to add such logic, I wouldn't
think it _wrong_ either.
Linus
next prev parent reply other threads:[~2008-08-13 23:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-12 16:17 Why doesn't git-apply remove empty file Francis Moreau
2008-08-13 0:25 ` Junio C Hamano
2008-08-13 7:48 ` Francis Moreau
2008-08-13 21:52 ` René Scharfe
2008-08-13 23:09 ` Linus Torvalds [this message]
2008-08-14 19:42 ` Francis Moreau
2008-08-14 19:57 ` Linus Torvalds
2008-08-14 20:02 ` Linus Torvalds
2008-08-14 20:21 ` Stephan Beyer
2008-08-14 20:54 ` Jeff King
2008-08-14 21:10 ` Stephan Beyer
2008-08-15 4:08 ` Jeff King
2008-08-15 15:53 ` Linus Torvalds
2008-08-14 20:17 ` Francis Moreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.1.10.0808131602200.3462@nehalem.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=francis.moro@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=rene.scharfe@lsrfire.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).