All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zander <zander@kde.org>
To: git@vger.kernel.org
Subject: git apply behaves differently from patch(1)
Date: Wed, 16 Jan 2008 23:58:48 +0100	[thread overview]
Message-ID: <200801162358.48723.zander@kde.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

In the following usecase git apply (git version 1.5.4.rc3.15.g785f9) 
doesn't do what I expect it should do. I expect it to do the same as 
patch does in the same situation.

To reproduce;
Create a file 'test' with a number on each line.  Numbers 1 though 10.
$ for i in 1 2 3 4 5 6 7 8 9 10; do echo $i >> test; done
$ git add test
$ git commit test

$ rm test
$ for i in 1 3 4 5 6 7 10; do echo $i >> test; done
$ git diff-index -p --unified=0 HEAD test | tee mypatch

Now use your editor to edit 'mypatch' and remove the first hunk; the end 
result (after your editing) should be something like this;
$ cat mypatch
diff --git a/test b/test
index f00c965..319869c 100644
--- a/test
+++ b/test
@@ -8,2 +6,0 @@
-8
-9

apply revert this patch;
$ git apply -R --unidiff-zero --apply mypatch
$ git diff

What I expect (and what I get if I replace git apply with a 'patch -R -p1 
< mypatch') is that the diff shows line "2" is still missing.

What I get instead is that "2" is missing but also that "10" moved 2 lines 
up.
I conclude that git somehow doesn't like the patch to be removed, while 
patch(1) has no problem with that.

I hope you agree its a bug and fix it in an upcoming version, it would be 
great if I can avoid using patch(1) or worse.
If you have any questions feel free to ask; but please cc me as I am not 
subscribed.
-- 
Thomas Zander

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2008-01-16 22:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-16 22:58 Thomas Zander [this message]
2008-01-17  8:11 ` git apply behaves differently from patch(1) Johannes Sixt
2008-01-17 19:58 ` Linus Torvalds

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=200801162358.48723.zander@kde.org \
    --to=zander@kde.org \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.