git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Francis Moreau" <francis.moro@gmail.com>
To: "Junio C Hamano" <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: Why doesn't git-apply remove empty file
Date: Wed, 13 Aug 2008 09:48:11 +0200	[thread overview]
Message-ID: <38b2ab8a0808130048t506dbb7ah1d6fcd6bd4f3c90c@mail.gmail.com> (raw)
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:
> 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

  reply	other threads:[~2008-08-13  7:49 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 [this message]
2008-08-13 21:52     ` René Scharfe
2008-08-13 23:09       ` Linus Torvalds
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=38b2ab8a0808130048t506dbb7ah1d6fcd6bd4f3c90c@mail.gmail.com \
    --to=francis.moro@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).