git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Different result with `git apply` and `patch`

From
BPBenjamin Poirier <bpoirier@suse.com>
Date
Jul 8, 2015, 17:50 UTC
Message-ID
<20150708175034.GA16759@f1.synalogic.ca>
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

Message 1 of 1 in “Different result with `git apply` and `patch`”
  1. Benjamin PoirierJul 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.