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

Antw: [EXT] Re: git add --interactive patch improvement for split hunks

From
UWUlrich Windl <ulrich.windl@rz.uni-regensburg.de>
Date
Jun 28, 2021, 10:10 UTC
Message-ID
<60D9A01C020000A100042099@gwsmtp.uni-regensburg.de>
In-Reply-To
<YNSnlhbE30xDfVMY@coredump.intra.peff.net>
>>> Jeff King <peff@peff.net> schrieb am 24.06.2021 um 17:41 in Nachricht
<YNSnlhbE30xDfVMY@coredump.intra.peff.net>:
[...]
Show 32 quoted lines
> One thing you may not like, though: both the builtin version and that
> patch only put the funcname context in the _first_ hunk of the split.
> Doing it for subsequent hunks is much trickier, since there can be a
> funcname in the split context itself. E.g.:
> 
>   @@ ... @@ void foo()
>            int x;
>   -        int y = 1;
>   +        int y = 2;
>    
>   -        x = 3;
>   +        x = 4;
>    }
> 
> could split into two hunks, both annotated with "void foo()". But:
> 
>   @@ ... @@ void foo()
>            int x;
>   -        x = 3;
>   +        x = 4;
>    }
>    void bar()
>    {
>   -        int y = 1;
>   +        int y = 2;
>    }
> 
> would be wrong to say "void foo()" for the second hunk. We'd have to
> re-scan the interior context lines for a funcname to find it. That's
> all-but-impossible in the perl version, but might be do-able in the C
> version (since it has easy access to the funcname-matching patterns and
> machinery).

There always was a related bug (IMHO) that showed the context of the previous function even though the actual change was within a new function (that starts within the context lines). So if that bug were fixed, my guess is that the other would be as well. However I don't know how easy or hard the fix will be. Maybe the "definition" of function context is just different; I don't really know.

Show 8 quoted lines
> 
> -Peff
> 
> [0] I'm not sure what the timetable is for switching to the C version of
>     add--interactive. If it's going to be a while, I don't mind moving
>     forward the other patch I showed. But maybe the time is here to
>     think about switching the default of add.interactive.useBuiltin, and
>     ironing out any final bugs?
Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 3 of 9 in “git add --interactive patch improvement for split hunks”
  1. Ulrich WindlJun 24, 2021
  2. Jeff KingJun 24, 2021
  3. Antw: [EXT] Re: git add --interactive patch improvement for split hunksUlrich Windl, Jun 28, 2021
  4. Ævar Arnfjörð BjarmasonJun 28, 2021
  5. Jeff KingJun 30, 2021
  6. Junio C HamanoJun 30, 2021
  7. Jeff KingJun 30, 2021
  8. Ævar Arnfjörð BjarmasonJun 30, 2021
  9. Jeff KingJun 30, 2021

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.