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

Re: [RFC] solving a bug with hunks starting at line 1 in git apply

From
Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>
Date
Jun 1, 2015, 21:37 UTC
Message-ID
<864699446.258590.1433194659960.JavaMail.zimbra@ensimag.grenoble-inp.fr>
In-Reply-To
<xmqqeglv5kg1.fsf@gitster.dls.corp.google.com>
Ok, Thanks for all the informations
Show 8 quoted lines
> Notice that the pre-context lines in this second example is only one
> line.  Is it giving the same degree of safety if we rejected an
> attempt to apply this patch only when the original does not have 10,
> 20, 30 and 40 in this order?
> 
> No.  Because we are doing two-line context patch, the patch is not
> just saying "this change applies to a place where the first line is
> 10".  It also is saying "there is no line before that line".

Yes, It's obvious that "patch" has not the same degree of safety as the git apply command. But I thought that any patch working with git apply should work with the "patch" command and give the same output, It seems that this is not true, regarding

file:

10 10 10 10 20

diff:
@@ -1,2 +1,3 @@
+10
 10
 10
@@ -1,4 +2,5 @@
 10
 10
+cc
 10
 10

(I changed it to have 2 line context).  Of course these are
hand-written patches, which can't be obtained with a diff (except with
the non coalescing git add -p as you said yourself). Wouldn't it 
be a problem?

> In other words, isn't the right fix to coalesce that input, so that
> the second hunk does *not* require fuzzy application in the first
> place?

Yes, you're right, that will be fixed if we restore coalescing, I
didn't thought of this possibility. This will cause fewer split but
we have the edit option anyway.


Thanks
Previous: Junio C HamanoNext: Matthieu Moy
Message 8 of 9 in “[RFC] solving a bug with hunks starting at line 1 in git apply”
  1. Remi LESPINETJun 1, 2015
  2. Junio C HamanoJun 1, 2015
  3. Junio C HamanoJun 1, 2015
  4. Matthieu MoyJun 1, 2015
  5. Junio C HamanoJun 1, 2015
  6. Matthieu MoyJun 1, 2015
  7. Junio C HamanoJun 1, 2015
  8. Remi LespinetJun 1, 2015
  9. Matthieu MoyJun 1, 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.