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@viscovery.net>
Date
Dec 13, 2007, 07:35 UTC
Message-ID
<4760E0CF.1030805@viscovery.net>
In-Reply-To
<Pine.LNX.4.64.0712121931050.27959@racer.site>
Johannes Schindelin schrieb:
Show 6 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.
NACK! --unidiff-zero eats your data.
1. Prepare a modification that adds 2 lines that are *not* adjacent, like this:
	@@ -6,6 +6,8 @@ git-checkout [options] [<branch>] [<paths>...]
	 --
	 b=          create a new branch started at <branch>
	+first
	 l           create the new branch's reflog
	 track       arrange that the new branch tracks the remote branch
	+after track
	 f           proceed even if the index or working tree is not HEAD
	 m           merge local modifications into the new branch
2. Reduce context to zero.
3. Stage *second* hunk.
Result: It is staged at the wrong place:
	@@ -9,4 +9,5 @@ l           create the new branch's reflog
	 track       arrange that the new branch tracks the remote branch
	 f           proceed even if the index or working tree is not HEAD
	+after track
	 m           merge local modifications into the new branch
	 q,quiet     be quiet
Reason: --unidiff-zero can only look at the line numbers. And those are
wrong because it doesn't account for the shift in line numbers caused by the
first hunk.
-- Hannes
Previous: Wincent ColaiutaNext: Shawn O. Pearce
Message 19 of 31 in “[ANNOUNCE] ugit: a pyqt-based git gui // was: Re: If you would write git from scratch now, what would you change?”
  1. DavidDec 11, 2007
  2. Marco CostalbaDec 11, 2007
  3. Jason SewallDec 11, 2007
  4. Marco CostalbaDec 11, 2007
  5. DavidDec 11, 2007
  6. Jason SewallDec 11, 2007
  7. Shawn O. PearceDec 12, 2007
  8. Jason SewallDec 12, 2007
  9. Shawn O. PearceDec 12, 2007
  10. Jason SewallDec 12, 2007
  11. Johannes SchindelinDec 12, 2007
  12. Jason SewallDec 12, 2007
  13. Teach git-gui to split hunksJohannes Schindelin, Dec 12, 2007
  14. Junio C HamanoDec 12, 2007
  15. Johannes SchindelinDec 12, 2007
  16. Jean-François VeilletteDec 12, 2007
  17. Junio C HamanoDec 12, 2007
  18. Wincent ColaiutaDec 12, 2007
  19. Johannes SixtDec 13, 2007
  20. Shawn O. PearceDec 13, 2007
  21. Johannes SchindelinDec 13, 2007
  22. Junio C HamanoDec 13, 2007
  23. Johannes SixtDec 13, 2007
  24. Johannes SchindelinDec 13, 2007
  25. Johannes SixtDec 13, 2007
  26. Johannes SchindelinDec 13, 2007
  27. git-gui: Move frequently used commands to the top of the context menu.Johannes Sixt, Dec 13, 2007
  28. Shawn O. PearceDec 14, 2007
  29. Alex RiesenDec 11, 2007
  30. Steffen ProhaskaDec 11, 2007
  31. Jakub NarebskiDec 12, 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.