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

Re: git-apply fails to apply some patches

From
Junio C Hamano <junkio@cox.net>
Date
Sep 17, 2006, 06:16 UTC
Message-ID
<7vzmcz6mrq.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060915132225.12040.qmail@a0896f98af57b2.315fe32.mid.smarden.org>
Gerrit Pape <pape@smarden.org> writes:
Show 15 quoted lines
>...
> On top of that, I try to apply this interdiff generated patch:
>
> diff -u pciutils-2.1.11/debian/dirs pciutils-2.1.11/debian/dirs
> --- pciutils-2.1.11/debian/dirs
> +++ pciutils-2.1.11/debian/dirs
> @@ -6,0 +7 @@
> +var/lib/pciutils
>
> and git-apply says:
>
> error: debian/dirs: already exists in working directory
>
> I suspect it's confused by the '-x,0' thinking that means "file does not
> exist" rather than "we have 0 context for this diff".

There are a few safety checks we perform assuming that the patch has a few lines of context, and this is falsely triggering one of them. It incorrectly thinks that seeing _no_ context nor old lines in the patch means this is a file creation patch, and complains because it knows the file being patched already exists.

I am looking into a way to handle a context-less patch line the one quoted, without breaking the sanity check we have.

In the meantime you should be able to work things around by not feeding --unified=0 diff output.

Previous: Gerrit PapeNext: Junio C Hamano
Message 2 of 8 in “git-apply fails to apply some patches”
  1. Gerrit PapeSep 15, 2006
  2. Junio C HamanoSep 17, 2006
  3. apply --unidiff-zero: loosen sanity checks for --unidiff=0 patchesJunio C Hamano, Sep 17, 2006
  4. Jakub NarebskiSep 17, 2006
  5. Junio C HamanoSep 17, 2006
  6. Jakub NarebskiSep 17, 2006
  7. Junio C HamanoSep 17, 2006
  8. git-apply(1): document --unidiff-zeroJonas Fonseca, Sep 17, 2006

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.