Re: Why doesn't git-apply remove empty file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

On Wed, Aug 13, 2008 at 2:25 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> 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 2008

So '/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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux