threads / discuss / 39816

Different result with `git apply` and `patch`

Subject: Different result with `git apply` and `patch`

## tl;dr

One message between Jul 8, 2015 and Jul 8, 2015.

replies: 0people: 1as markdown or json

Benjamin Poirier· Jul 8, 2015, 17:50 UTC · lore
Hi,

Is it expected that `git apply` and `patch` produce a different result when given a patch that applies cleanly but with offsets?

Specifically, using the source file and patch file found here: https://gist.github.com/benthaman/d4e80e1e2e5e0273f874 https://gist.github.com/benthaman/d48d017179a8292c3f75

ben@f1:/tmp/report$ mkdir p g ben@f1:/tmp/report$ cp ib_isert.c p ben@f1:/tmp/report$ cp ib_isert.c g ben@f1:/tmp/report$ cd p/ ben@f1:/tmp/report/p$ patch -p5 < ../0123-IB-isert-pass-scatterlist-instead-of-cmd-to-fast_reg.patch patching file ib_isert.c Hunk #1 succeeded at 2322 (offset 131 lines). Hunk #2 succeeded at 2408 (offset 131 lines). Hunk #3 succeeded at 2474 (offset 131 lines). ben@f1:/tmp/report/p$ cd ../g ben@f1:/tmp/report/g$ git apply -p5 -v < ../0123-IB-isert-pass-scatterlist-instead-of-cmd-to-fast_reg.patch Checking patch ib_isert.c... Hunk #1 succeeded at 2322 (offset 131 lines). Hunk #2 succeeded at 2199 (offset -78 lines). Hunk #3 succeeded at 2474 (offset 131 lines). Applied patch ib_isert.c cleanly.

ben@f1:/tmp/report$ git --version git version 2.4.3 ben@f1:/tmp/report$ patch --version GNU patch 2.7.1 [...]

I see why it happens, but I'd like the two tools to produce the same result!

Thanks, -Benjamin

← back to recent threads