{"thread":{"id":"15443","subject":"git-gui: more issues with diff parsing","startedAt":"2008-09-09T08:30:04Z","lastAt":"2008-09-12T18:01:15Z","messageCount":4,"participants":["Michele Ballabio","Shawn O. Pearce","Junio C Hamano","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"90181","messageId":"200809091030.04507.barra_cuda@katamail.com","threadId":"15443","inReplyTo":null,"subject":"git-gui: more issues with diff parsing","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2008-09-09T08:30:04Z","receivedAt":"2008-09-09T08:30:04Z","isPatch":false,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"The patch\n\tgit-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\nseems to have introduced some glitches. With this sequence:\n\ngit init\ntouch g\ngit add g\ngit commit -m\"g is a file\"\nrm g\necho \"vvvv\" > file\nln -s file g\ngit add g file\ngit gui\n\nNow clicking on \"g\" in the staged changes, git-gui gives this line:\n\terror: Unhandled 2 way diff marker: {d}\n\nThe following patch seems to fix this particular issue, but I don't think\nit's the right fix...\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex a30c80a..0dac732 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -345,6 +345,8 @@ proc read_diff {fd scroll_pos} {\n \t\t\t\tset tags {}\n \t\t\t}\n \t\t\t}\n+\t\t} elseif [string match {diff --git *} $line] {\n+\t\t\tcontinue\n \t\t} else {\n \t\t\tset op [string index $line 0]\n \t\t\tswitch -- $op {\n"},{"id":"90568","messageId":"20080912152345.GE22960@spearce.org","threadId":"15443","inReplyTo":"200809091030.04507.barra_cuda@katamail.com","subject":"Re: git-gui: more issues with diff parsing","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-12T15:23:45Z","receivedAt":"2008-09-12T15:23:45Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Michele Ballabio <barra_cuda@katamail.com> wrote:\n> The patch\n> \tgit-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\n> seems to have introduced some glitches. With this sequence:\n\nOy.\n \n> git init\n> touch g\n> git add g\n> git commit -m\"g is a file\"\n> rm g\n> echo \"vvvv\" > file\n> ln -s file g\n> git add g file\n> git gui\n> \n> Now clicking on \"g\" in the staged changes, git-gui gives this line:\n> \terror: Unhandled 2 way diff marker: {d}\n\nThe diff is weird:\n\n  $ git-diff-index --cached -p --no-color -U5 d6e02aa06c91c711d98ae06e6e69c5de5841a5e5 -- g\n  diff --git a/g b/g\n  deleted file mode 100644\n  index e69de29..1a010b1\n  diff --git a/g b/g\n  new file mode 120000\n  index e69de29..1a010b1\n  --- /dev/null\n  +++ b/g\n  @@ -0,0 +1 @@\n  +file\n  \\ No newline at end of file\n\nNotice how we get two diffs for the same file?  That's why git-gui\nis choking on this particular change.  It expected only one diff\nfor the path it gave to Git.  It got two back.  In cases like this\nwe may not be able to support line or hunk application as the patch\nis really two different patches against that path.  :-|\n\n> The following patch seems to fix this particular issue, but I don't think\n> it's the right fix...\n\nI don't think that is the right fix, but the one that I just tried to\nwrite to do clear_diff when we see the second diff --git line didn't\nwork either.  Plus we probably need to disable the hunk apply code.\n\nI'll look at it again when I can get more time.\n\n-- \nShawn.\n"},{"id":"90583","messageId":"7vy71xpa45.fsf@gitster.siamese.dyndns.org","threadId":"15443","inReplyTo":"20080912152345.GE22960@spearce.org","subject":"Re: git-gui: more issues with diff parsing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-12T17:06:18Z","receivedAt":"2008-09-12T17:06:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Notice how we get two diffs for the same file?  That's why git-gui\n> is choking on this particular change.  It expected only one diff\n> for the path it gave to Git.  It got two back.  In cases like this\n> we may not be able to support line or hunk application as the patch\n> is really two different patches against that path.  :-|\n>\n>> The following patch seems to fix this particular issue, but I don't think\n>> it's the right fix...\n>\n> I don't think that is the right fix, but the one that I just tried to\n> write to do clear_diff when we see the second diff --git line didn't\n> work either.  Plus we probably need to disable the hunk apply code.\n\nYou will have the same issue not for submodules, too.  A typechange has\nalways been expressed as delete followed by create.\n\nProbably you already have learned the nature of change (i.e. create?\nmodify? delete? typechange?) when you populate the list of files with\nchanges that could be staged, which means by the time the user picks from\nthe liast you already know if it is a typechange.\n"},{"id":"90586","messageId":"m3ljxxnt09.fsf@localhost.localdomain","threadId":"15443","inReplyTo":"20080912152345.GE22960@spearce.org","subject":"Re: git-gui: more issues with diff parsing","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-09-12T18:01:15Z","receivedAt":"2008-09-12T18:01:15Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> The diff is weird:\n> \n>   $ git-diff-index --cached -p --no-color -U5 \\\n>       d6e02aa06c91c711d98ae06e6e69c5de5841a5e5 -- g\n>   diff --git a/g b/g\n>   deleted file mode 100644\n>   index e69de29..1a010b1\n>   diff --git a/g b/g\n>   new file mode 120000\n>   index e69de29..1a010b1\n>   --- /dev/null\n>   +++ b/g\n>   @@ -0,0 +1 @@\n>   +file\n>   \\ No newline at end of file\n> \n> Notice how we get two diffs for the same file?  That's why git-gui\n> is choking on this particular change.  It expected only one diff\n> for the path it gave to Git.  It got two back.  In cases like this\n> we may not be able to support line or hunk application as the patch\n> is really two different patches against that path.  :-|\n\nHmmm... it looks _exactly_ like a problem I had with writing\n\"syntax highlighting\" (and linkage) for the patchset part of\n'commitdiff' and 'blobdiff' views, namely that typechange\n(file to symlink and vice versa) generates two patches for\nsingle difftree (raw diff format output) line.\n\nSee git_patchset_body in gitweb/gitweb.perl, and is_patch_split\nfunction, and commit message of 0cec6db (gitweb: Fix and simplify\n\"split patch\" detection), which tells about alternate solution.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}