Re: Why doesn't git-apply remove empty file
- From
- Francis Moreau <francis.moro@gmail.com>
- Date
- Aug 13, 2008, 07:48 UTC
- Message-ID
- <38b2ab8a0808130048t506dbb7ah1d6fcd6bd4f3c90c@mail.gmail.com>
- In-Reply-To
- <7vod3xpxq2.fsf@gitster.siamese.dyndns.org>
Hello,
On Wed, Aug 13, 2008 at 2:25 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
> On the other hand, if you want to remove an empty file, the patch would > look like this: > > diff --git a/bar b/bar > deleted file mode 100644 > index 257cc56..0000000 > --- a/bar > +++ /dev/null > @@ -1 +0,0 @@ > -foo > > A patch generated by non-git tools would lack "index" and "deleted" lines, > but they will still have difference between "bar" and "/dev/null" on the > postimage filename (i.e. "+++" line), and git-apply leaves an empty file > for the former, and removes the file for the latter patch. >
Hm this is somehow wrong, please see:
$ mkdir a b
$ date > a/f
$ diff -Nurp a/f b/f
--- a/f 2008-08-13 09:27:29.000000000 +0200
+++ b/f 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-Wed Aug 13 09:27:29 CEST 2008So '/dev/null' doesn't appear here. I think patch(1) uses the date of b/f for removing the file.
If we keep going on:
$ diff -Nurp a b > test.patch
$ ( cd a && git apply ../test.patch )
$ ls a
f
$ cat a/f
$of course patch(1) does remove the file.
Thanks
-- Francis