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

Re: [ANNOUNCE] Git 1.7.4.3

From
Arnaud Lacombe <lacombar@gmail.com>
Date
Apr 6, 2011, 18:40 UTC
Message-ID
<BANLkTimh+--iRNEpr2XOFf4jXoVhmHUnoA@mail.gmail.com>
In-Reply-To
<7v4o6fg29j.fsf@alter.siamese.dyndns.org>
Hi Julio,,
On Sun, Apr 3, 2011 at 4:36 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano (9):
>      apply: do not patch lines that were already patched
>

This commit introduces a regression when editing splithunks using "git add -p". Reverting the patch fix the regression.

Considering the following checked-in code:
int
main(int argc, char **argv)
{
        int a;
        return 0;
}
modified the following way:
int
main(int argc, char **argv)
{
        int c;
        int a;
        int d;
        int e;
        int f;
        return 0;
}
if you 'git add -p' on the file, you'll get:
diff --git a/main.c b/main.c
index f9f4197..7fb483f 100644
--- a/main.c
+++ b/main.c
@@ -9,7 +9,11 @@
 int
 main(int argc, char **argv)
 {
+       int c;
        int a;
+       int d;
+       int e;
+       int f;

        return 0;
 }

Now, I only want the first part, so I reduce the context by typing
's', which lead to:

Split into 2 hunks.
@@ -9,4 +9,5 @@
 int
 main(int argc, char **argv)
 {
+       int c;
        int a;

If I edit this hunk and make _no_modification_, "git apply" fails with:

error: patch failed: main.c:12
error: main.c: patch does not apply
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]?

This hunk does _apply_, as it could be staged and committed as-is if I
did not edit it.

This was just a way to reproduce the regression. If you change the
code in a way that would still apply, git-apply would still fails to
apply the hunk. Editing the whole original hunk (ie. not split) works
fine.

 - Arnaud
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 6 in “[ANNOUNCE] Git 1.7.4.3”
  1. Junio C HamanoApr 3, 2011
  2. Arnaud LacombeApr 6, 2011
  3. Junio C HamanoApr 6, 2011
  4. "add -p" breakageJunio C Hamano, Apr 6, 2011
  5. add--interactive.perl: factor out repeated --recount optionJunio C Hamano, Apr 6, 2011
  6. "add -p": work-around an old laziness that does not coalesce hunksJunio C Hamano, Apr 6, 2011

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.