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

Re: git-gui: more issues with diff parsing

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 12, 2008, 15:23 UTC
Message-ID
<20080912152345.GE22960@spearce.org>
In-Reply-To
<200809091030.04507.barra_cuda@katamail.com>
Michele Ballabio <barra_cuda@katamail.com> wrote:
> The patch
> 	git-gui: Fix diff parsing for lines starting with "--" or "++"
> seems to have introduced some glitches. With this sequence:
Oy.
 
Show 12 quoted lines
> git init
> touch g
> git add g
> git commit -m"g is a file"
> rm g
> echo "vvvv" > file
> ln -s file g
> git add g file
> git gui
> 
> Now clicking on "g" in the staged changes, git-gui gives this line:
> 	error: Unhandled 2 way diff marker: {d}
The diff is weird:
  $ git-diff-index --cached -p --no-color -U5 d6e02aa06c91c711d98ae06e6e69c5de5841a5e5 -- g
  diff --git a/g b/g
  deleted file mode 100644
  index e69de29..1a010b1
  diff --git a/g b/g
  new file mode 120000
  index e69de29..1a010b1
  --- /dev/null
  +++ b/g
  @@ -0,0 +1 @@
  +file
  \ No newline at end of file

Notice how we get two diffs for the same file? That's why git-gui is choking on this particular change. It expected only one diff for the path it gave to Git. It got two back. In cases like this we may not be able to support line or hunk application as the patch is really two different patches against that path. :-|

> The following patch seems to fix this particular issue, but I don't think
> it's the right fix...

I don't think that is the right fix, but the one that I just tried to write to do clear_diff when we see the second diff --git line didn't work either. Plus we probably need to disable the hunk apply code.

I'll look at it again when I can get more time.
-- 
Shawn.
Previous: Michele BallabioNext: Junio C Hamano
Message 2 of 4 in “git-gui: more issues with diff parsing”
  1. Michele BallabioSep 9, 2008
  2. Shawn O. PearceSep 12, 2008
  3. Junio C HamanoSep 12, 2008
  4. Jakub NarebskiSep 12, 2008

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.