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

Re: [PATCH] Teach git-gui to split hunks

From
Johannes Sixt <j.sixt@eudaptics.com>
Date
Jul 26, 2007, 07:32 UTC
Message-ID
<46A84E06.2ED4CFBC@eudaptics.com>
In-Reply-To
<Pine.LNX.4.64.0707260630570.14781@racer.site>
Johannes Schindelin wrote:
Show 7 quoted lines
> 
> When you select the context menu item "Split Hunk" in the diff area,
> git-gui will now split the current hunk so that a new hunk starts at
> the current position.
> 
> For this to work, apply has to be called with --unidiff-zero, since
> the new hunks can start or stop with a "-" or "+" line.
For chrissake, NO!
I tried this already, and it immediately corrupted my data.

The problem case is when the hunk you want to apply is not the first one and the first one does not add and remove the same number of lines. In this case, all that git-apply can do is to rely on line numbers. But they are WRONG and apply the patch at the WRONG spot.

First, I didn't believe Linus when he preached that --unidiff-zero is bad; it took only a day to become a follower. ;)

-- Hannes
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 5 of 6 in “Teach git-gui to split hunks”
  1. Teach git-gui to split hunksJohannes Schindelin, Jul 26, 2007
  2. David KastrupJul 26, 2007
  3. Shawn O. PearceJul 26, 2007
  4. Johannes SchindelinJul 26, 2007
  5. Johannes SixtJul 26, 2007
  6. Johannes SchindelinJul 26, 2007

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.