{"thread":{"id":"15363","subject":"Re: Git Gui does not want to work on chunk level","startedAt":"2008-09-03T19:23:19Z","lastAt":"2010-12-06T21:30:08Z","messageCount":15,"participants":["Alexander Gladysh","Shawn O. Pearce","Junio C Hamano","Johannes Sixt","Bert Wesarg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"89673","messageId":"c6c947f60809031223i575ca3fdya357588610bb72e8@mail.gmail.com","threadId":"15363","inReplyTo":"c6c947f60808270216k2feb8f9ar765cdee1fc3910ee-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Alexander Gladysh","fromEmail":"agladysh-re5jqeeqqe8avxtiumwx3w@public.gmane.org","sentAt":"2008-09-03T19:23:19Z","receivedAt":"2008-09-03T19:23:19Z","isPatch":false,"sender":{"key":"agladysh-re5jqeeqqe8avxtiumwx3w@public.gmane.org","avatar":null},"body":"\nHi, list!\n\nOn Wed, Aug 27, 2008 at 1:16 PM, Alexander Gladysh <agladysh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:\n> $ git --version\n> git version 1.6.0.GIT\n>\n> $ git gui --version\n> git-gui version 0.11.GITGUI\n>\n> I like 'stage hunk for commit' feature in Git Gui, but often it gives\n> me an error message box:\n>\n> fatal: git-apply: bad git-diff - inconsistent old filename on line 4\n\nPlease advise how should I formulate this question to get an answer. I\nunderstand that it is hard to say something on the subject with that\nlittle info I provide, but anyway. I'm encountering this problem on\nroughly every fifth commit, and it is quite annoying, since I've got\nused to small feature-based per-chunk commits.\n\nDoes anyone else encounter this kind of error? Any debugging advice?\nPerhaps I can instrument git gui with logging somewhere (dump diffs\nfor example). (I have no experience with TCL though.)\n\nIf error appears for single file diff, it would be reproduced each\ntime I try to stage hunk from that diff. I have one such uncommitted\ndiff now (can't send it, sorry), please advise what can I do to debug\nit.\n\nAlexander.\n"},{"id":"89703","messageId":"20080903230814.GJ28315@spearce.org","threadId":"15363","inReplyTo":"c6c947f60809031223i575ca3fdya357588610bb72e8@mail.gmail.com","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-03T23:08:14Z","receivedAt":"2008-09-03T23:08:14Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alexander Gladysh <agladysh@gmail.com> wrote:\n> On Wed, Aug 27, 2008 at 1:16 PM, Alexander Gladysh <agladysh@gmail.com> wrote:\n> > $ git --version\n> > git version 1.6.0.GIT\n> >\n> > $ git gui --version\n> > git-gui version 0.11.GITGUI\n> >\n> > I like 'stage hunk for commit' feature in Git Gui, but often it gives\n> > me an error message box:\n> >\n> > fatal: git-apply: bad git-diff - inconsistent old filename on line 4\n...\n> Does anyone else encounter this kind of error? Any debugging advice?\n> Perhaps I can instrument git gui with logging somewhere (dump diffs\n> for example). (I have no experience with TCL though.)\n\nI've never seen that before, but its clearly dumping a bad diff\ninto git-apply.\n\nOpen up lib/diff.tcl and find \"proc apply_hunk\".  Inside of the\ncatch maybe insert a puts to see the diff, e.g.:\n\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 52b79e4..4acaccf 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -341,6 +341,8 @@ proc apply_hunk {x y} {\n \t\tfconfigure $p -translation binary -encoding binary\n \t\tputs -nonewline $p $current_diff_header\n \t\tputs -nonewline $p [$ui_diff get $s_lno $e_lno]\n+puts -nonewline stdout $current_diff_header\n+puts -nonewline stdout [$ui_diff get $s_lno $e_lno]\n \t\tclose $p} err]} {\n \t\terror_popup [append $failed_msg \"\\n\\n$err\"]\n \t\tunlock_index\n\nThen if you can scrub the context and +/- lines for a bad diff and\nsend us at least the headers, or tell us how they are malformed,\nit would help to debug it.\n \n-- \nShawn.\n"},{"id":"89745","messageId":"c6c947f60809040220t589e65bfkbd693fd335792069@mail.gmail.com","threadId":"15363","inReplyTo":"20080903230814.GJ28315@spearce.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Alexander Gladysh","fromEmail":"agladysh@gmail.com","sentAt":"2008-09-04T09:20:21Z","receivedAt":"2008-09-04T09:20:21Z","isPatch":false,"sender":{"key":"agladysh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38239?v=4"},"body":"On Thu, Sep 4, 2008 at 3:08 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> Alexander Gladysh <agladysh@gmail.com> wrote:\n>> On Wed, Aug 27, 2008 at 1:16 PM, Alexander Gladysh <agladysh@gmail.com> wrote:\n>> > I like 'stage hunk for commit' feature in Git Gui, but often it gives\n>> > me an error message box:\n>> >\n>> > fatal: git-apply: bad git-diff - inconsistent old filename on line 4\n> ...\n> I've never seen that before, but its clearly dumping a bad diff\n> into git-apply.\n>\n> Open up lib/diff.tcl and find \"proc apply_hunk\".  Inside of the\n> catch maybe insert a puts to see the diff, e.g.:\n> <...>\n> Then if you can scrub the context and +/- lines for a bad diff and\n> send us at least the headers, or tell us how they are malformed,\n> it would help to debug it.\n\nThank you!\n\nHeader looks well-formed to me:\n\ndiff --git a/path/file.ext b/path/file.ext\n--- a/path/file.ext\n+++ b/path/file.ext\n\nI have sent you full output privately. I do not see anything unusual\nin it... Anyplace where I may put more logging?\n\nThanks again,\nAlexander.\n"},{"id":"89769","messageId":"20080904143723.GB23708@spearce.org","threadId":"15363","inReplyTo":"c6c947f60809040220t589e65bfkbd693fd335792069@mail.gmail.com","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-04T14:37:23Z","receivedAt":"2008-09-04T14:37:23Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alexander Gladysh <agladysh@gmail.com> wrote:\n> On Thu, Sep 4, 2008 at 3:08 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n> >\n> > Open up lib/diff.tcl and find \"proc apply_hunk\".  Inside of the\n> > catch maybe insert a puts to see the diff, e.g.:\n> > <...>\n> \n> Header looks well-formed to me:\n> \n> diff --git a/path/file.ext b/path/file.ext\n> --- a/path/file.ext\n> +++ b/path/file.ext\n> \n> I have sent you full output privately. I do not see anything unusual\n> in it... Anyplace where I may put more logging?\n\nActually the header you sent me privately wasn't well formed.\nIt looked something like this:\n\n  diff --git a/path/file.ext b/path/file.ext\n  --- a/path/file.ext\n  +++ b/path/file.ext\n  --- assert(a != b)\n  --- assert(a != c)\n  @@ -10,1 +10,2 @@\n\nIt looks to me like some part of the context became part of the\ndiff header, with three \"-\" stuck in front of it.  Which git-apply\nthen thinks is the pre-image path name.\n\nCan you put in some more puts in that same section of the code\nso we can find out which of the puts has these extra asserts?\nIs it the first one for $current_diff_header or is it the second\none that is supposed to be pulling in the patch hunk?  Do you see\nthese extra asserts in the diff viewer like this before you try to\napply the patch?\n\n-- \nShawn.\n"},{"id":"89770","messageId":"c6c947f60809040754g34e60633lcd5f872ac5e80158@mail.gmail.com","threadId":"15363","inReplyTo":"20080904143723.GB23708-o8xcbExO1WpAfugRpC6u6w@public.gmane.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Alexander Gladysh","fromEmail":"agladysh-re5jqeeqqe8avxtiumwx3w@public.gmane.org","sentAt":"2008-09-04T14:54:21Z","receivedAt":"2008-09-04T14:54:21Z","isPatch":false,"sender":{"key":"agladysh-re5jqeeqqe8avxtiumwx3w@public.gmane.org","avatar":null},"body":"\n(Shawn, apologies for double-posting.)\n\n> Actually the header you sent me privately wasn't well formed.\n> It looked something like this:\n>\n>  diff --git a/path/file.ext b/path/file.ext\n>  --- a/path/file.ext\n>  +++ b/path/file.ext\n>  --- assert(a != b)\n>  --- assert(a != c)\n>  @@ -10,1 +10,2 @@\n>\n> It looks to me like some part of the context became part of the\n> diff header, with three \"-\" stuck in front of it.  Which git-apply\n> then thinks is the pre-image path name.\n\nAha! Thank you! That \"--\" is a comment in Lua (that is commented line\nthat was removed in diff). First dash is from diff, next two came from\nfile itself.\n\nSteps to reproduce the bug:\n\n$ mkdir test\n$ cd test\n$ git init\nInitialized empty Git repository in path/test/.git/\n$ cat >file.ext\n-- 1\n-- 2\n-- 3\n-- 4\n-- 5\n^D\n$ git add file.ext\n$ git commit -m \"one\"\nCreated initial commit 9226cdf: one\n 1 files changed, 5 insertions(+), 0 deletions(-)\n create mode 100644 file.ext\n$ cat >file.ext\n-- 1\n-- 2\n-- 33\n-- 4\n-- 5\n$ git gui\n\nAnd stage (sole) hunk. You see the error.\n\n> Can you put in some more puts in that same section of the code\n> so we can find out which of the puts has these extra asserts?\n> Is it the first one for $current_diff_header or is it the second\n> one that is supposed to be pulling in the patch hunk?  Do you see\n> these extra asserts in the diff viewer like this before you try to\n> apply the patch?\n\nHopefully the above steps would help to debug this bug directly. If\nyou still need any more info from me, please say, I'll be glad to\nprovide it.\n\nThank you again!\nAlexander.\n"},{"id":"89821","messageId":"20080905045327.GA31166@spearce.org","threadId":"15363","inReplyTo":"c6c947f60809040754g34e60633lcd5f872ac5e80158@mail.gmail.com","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-05T04:53:27Z","receivedAt":"2008-09-05T04:53:27Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Alexander Gladysh <agladysh@gmail.com> wrote:\n> \n> Aha! Thank you! That \"--\" is a comment in Lua (that is commented line\n> that was removed in diff). First dash is from diff, next two came from\n> file itself.\n> \n> Steps to reproduce the bug:\n...\n\nSo that was an awesome reproduction case.  I have committed the\nfollowing fix and will push it out in a few minutes:\n\n--8<--\ngit-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\n\nLanguages like Lua and SQL use \"--\" to mark a line as commented out.\nIf this appears at column 0 and is part of the pre-image we may see\n\"--- foo\" in the diff, indicating that the line whose content is\n \"-- foo\" has been removed from the new version.\n\ngit-gui was incorrectly parsing \"--- foo\" as the old file name\nin the file header, causing it to generate a bad patch file when\nthe user tried to stage or unstage a hunk or the selected line.\nWe need to keep track of where we are in the parsing so that we do\nnot misread a deletion or addition record as part of the header.\n\nReported-by: Alexander Gladysh <agladysh@gmail.com>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n lib/diff.tcl |   18 +++++++++++-------\n 1 files changed, 11 insertions(+), 7 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 4a7138b..1970b60 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -192,6 +192,7 @@ proc show_diff {path w {lno {}} {scroll_pos {}}} {\n \t\treturn\n \t}\n \n+\tset ::current_diff_inheader 1\n \tfconfigure $fd \\\n \t\t-blocking 0 \\\n \t\t-encoding binary \\\n@@ -207,18 +208,21 @@ proc read_diff {fd scroll_pos} {\n \twhile {[gets $fd line] >= 0} {\n \t\t# -- Cleanup uninteresting diff header lines.\n \t\t#\n-\t\tif {   [string match {diff --git *}      $line]\n-\t\t\t|| [string match {diff --cc *}       $line]\n-\t\t\t|| [string match {diff --combined *} $line]\n-\t\t\t|| [string match {--- *}             $line]\n-\t\t\t|| [string match {+++ *}             $line]} {\n-\t\t\tappend current_diff_header $line \"\\n\"\n-\t\t\tcontinue\n+\t\tif {$::current_diff_inheader} {\n+\t\t\tif {   [string match {diff --git *}      $line]\n+\t\t\t    || [string match {diff --cc *}       $line]\n+\t\t\t    || [string match {diff --combined *} $line]\n+\t\t\t    || [string match {--- *}             $line]\n+\t\t\t    || [string match {+++ *}             $line]} {\n+\t\t\t\tappend current_diff_header $line \"\\n\"\n+\t\t\t\tcontinue\n+\t\t\t}\n \t\t}\n \t\tif {[string match {index *} $line]} continue\n \t\tif {$line eq {deleted file mode 120000}} {\n \t\t\tset line \"deleted symlink\"\n \t\t}\n+\t\tset ::current_diff_inheader 0\n \n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n-- \n1.6.0.1.274.g007e4\n\n\n-- \nShawn.\n"},{"id":"89822","messageId":"7v63pbyxu9.fsf@gitster.siamese.dyndns.org","threadId":"15363","inReplyTo":"20080905045327.GA31166@spearce.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-05T05:18:38Z","receivedAt":"2008-09-05T05:18:38Z","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> git-gui was incorrectly parsing \"--- foo\" as the old file name\n> in the file header, causing it to generate a bad patch file when\n> the user tried to stage or unstage a hunk or the selected line.\n> We need to keep track of where we are in the parsing so that we do\n> not misread a deletion or addition record as part of the header.\n\nWhile keeping track of state is obviously a good change, it also might be\nworth noticing \"@@ -k,l +m,n @@\" header and actively using the\ninformation.\n"},{"id":"89823","messageId":"20080905052026.GB31166@spearce.org","threadId":"15363","inReplyTo":"7v63pbyxu9.fsf@gitster.siamese.dyndns.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-09-05T05:20:26Z","receivedAt":"2008-09-05T05:20:26Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> \"Shawn O. Pearce\" <spearce@spearce.org> writes:\n> \n> > git-gui was incorrectly parsing \"--- foo\" as the old file name\n> > in the file header, causing it to generate a bad patch file when\n> > the user tried to stage or unstage a hunk or the selected line.\n> > We need to keep track of where we are in the parsing so that we do\n> > not misread a deletion or addition record as part of the header.\n> \n> While keeping track of state is obviously a good change, it also might be\n> worth noticing \"@@ -k,l +m,n @@\" header and actively using the\n> information.\n\nYea.  But that was a lot more work.\n\nNoticing a hunk header, getting the line counts from it, then\nkeeping a running counter to know how many lines before either EOF\nor the next header are all part of that hunk is just a lot of code\nI didn't feel like writing this evening.  ;-)\n\n-- \nShawn.\n"},{"id":"89865","messageId":"c6c947f60809051227o6a3890c9m1767921a6bb9a804@mail.gmail.com","threadId":"15363","inReplyTo":"20080905045327.GA31166-o8xcbExO1WpAfugRpC6u6w@public.gmane.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Alexander Gladysh","fromEmail":"agladysh-re5jqeeqqe8avxtiumwx3w@public.gmane.org","sentAt":"2008-09-05T19:27:19Z","receivedAt":"2008-09-05T19:27:19Z","isPatch":false,"sender":{"key":"agladysh-re5jqeeqqe8avxtiumwx3w@public.gmane.org","avatar":null},"body":"\n> So that was an awesome reproduction case.  I have committed the\n> following fix and will push it out in a few minutes:\n\n<...>\n\nThank you! The fix helped indeed. I can commit on hunk level again! :-)\n\nAlexander.\n"},{"id":"90715","messageId":"48CE09EF.7090609@viscovery.net","threadId":"15363","inReplyTo":"20080905045327.GA31166@spearce.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-09-15T07:08:31Z","receivedAt":"2008-09-15T07:08:31Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Shawn O. Pearce schrieb:\n> git-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\n> \n> Languages like Lua and SQL use \"--\" to mark a line as commented out.\n> If this appears at column 0 and is part of the pre-image we may see\n> \"--- foo\" in the diff, indicating that the line whose content is\n>  \"-- foo\" has been removed from the new version.\n> \n> git-gui was incorrectly parsing \"--- foo\" as the old file name\n> in the file header, causing it to generate a bad patch file when\n> the user tried to stage or unstage a hunk or the selected line.\n> We need to keep track of where we are in the parsing so that we do\n> not misread a deletion or addition record as part of the header.\n\nThis (slightly) breaks parsing of new files and removed files that are\nstaged by showing the file names in the diff header:\n\n new file mode 100644\n --- /dev/null\n +++ b/foo\n @@ -0,0 +1 @@\n +foo\n\n-- Hannes\n"},{"id":"90742","messageId":"c6c947f60809150721m1ec11f10xc68ce39559398659@mail.gmail.com","threadId":"15363","inReplyTo":"20080905045327.GA31166@spearce.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Alexander Gladysh","fromEmail":"agladysh@gmail.com","sentAt":"2008-09-15T14:21:17Z","receivedAt":"2008-09-15T14:21:17Z","isPatch":false,"sender":{"key":"agladysh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/38239?v=4"},"body":"Hi, list!\n\nOn Fri, Sep 5, 2008 at 8:53 AM, Shawn O. Pearce <spearce@spearce.org> wrote:\n\n> git-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\n\nSomewhat related bug, but reproduceable event without \"--\". If I set\ndiff context to none in git gui (by repeatedly clicking \"show less\ncontext\") I'm sometimes not able to stage hunk or line.\n\ngit version 1.6.0.GIT\ngit-gui version 0.11.GITGUI\n\nSteps to reproduce:\n\nagladysh@agladysh-desktop:~$ mkdir test\nagladysh@agladysh-desktop:~$ cd test\nagladysh@agladysh-desktop:~/test$ git init\nInitialized empty Git repository in /home/agladysh/test/.git/\nagladysh@agladysh-desktop:~/test$ cat >file.ext\n-- 1\n-- 2\n-- 3\n-- 4\n-- 5\nagladysh@agladysh-desktop:~/test$ git add file.ext\nagladysh@agladysh-desktop:~/test$ git commit -m \"one\"\nCreated initial commit aa4da16: one\n 1 files changed, 5 insertions(+), 0 deletions(-)\n create mode 100644 file.ext\nagladysh@agladysh-desktop:~/test$ cat >file.ext\n-- 1\n-- 2\n-- 33\n-- 4\n-- 5\nagladysh@agladysh-desktop:~/test$ git gui\n\nReduce context to none, then do stage hunk. It fails with message:\n\nerror: patch failed: file.ext:3\nerror: file.ext: patch does not apply\nOK\n\nDump (by your debuging dumper patch from the same tread):\n\ndiff --git a/file.ext b/file.ext\n--- a/file.ext\n+++ b/file.ext\n@@ -1,5 +1,5 @@\n -- 1\n -- 2\n--- 3\n+-- 33\n -- 4\n -- 5\n\nDo stage line. It fails with message:\n\nfatal: corrupt patch at line 5\n\nDump:\n\ndiff --git a/file.ext b/file.ext\n--- a/file.ext\n+++ b/file.ext\n@@ -3 +3 @@\n--- 3\n+-- 33\n\nHTH,\nAlexander.\n"},{"id":"90743","messageId":"20080915142421.GE6320@spearce.org","threadId":"15363","inReplyTo":"c6c947f60809150721m1ec11f10xc68ce39559398659-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Shawn O. Pearce","fromEmail":"spearce-o8xcbexo1wpafugrpc6u6w@public.gmane.org","sentAt":"2008-09-15T14:24:21Z","receivedAt":"2008-09-15T14:24:21Z","isPatch":false,"sender":{"key":"spearce-o8xcbexo1wpafugrpc6u6w@public.gmane.org","avatar":null},"body":"\nAlexander Gladysh <agladysh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:\n> On Fri, Sep 5, 2008 at 8:53 AM, Shawn O. Pearce <spearce-o8xcbExO1WpAfugRpC6u6w@public.gmane.org> wrote:\n> \n> > git-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\n> \n> Somewhat related bug, but reproduceable event without \"--\". If I set\n> diff context to none in git gui (by repeatedly clicking \"show less\n> context\") I'm sometimes not able to stage hunk or line.\n\ngit-apply refuses to apply a patch with 0 context lines.  Latest\ngit-gui in maint (and in Git 1.6.0.2?) won't let you reduce the\nnumber of context lines below 1, so you never can see this error.\n \n> Reduce context to none, then do stage hunk. It fails with message:\n> \n> error: patch failed: file.ext:3\n> error: file.ext: patch does not apply\n> OK\n\n-- \nShawn.\n"},{"id":"156900","messageId":"AANLkTimz17vodjS7K_ts2pcoZHTo2eb9=FaWwEyhihsa@mail.gmail.com","threadId":"15363","inReplyTo":"48CE09EF.7090609@viscovery.net","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-11-30T21:19:38Z","receivedAt":"2010-11-30T21:19:38Z","isPatch":false,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Mon, Sep 15, 2008 at 09:08, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Shawn O. Pearce schrieb:\n>> git-gui: Fix diff parsing for lines starting with \"--\" or \"++\"\n>>\n>> Languages like Lua and SQL use \"--\" to mark a line as commented out.\n>> If this appears at column 0 and is part of the pre-image we may see\n>> \"--- foo\" in the diff, indicating that the line whose content is\n>>  \"-- foo\" has been removed from the new version.\n>>\n>> git-gui was incorrectly parsing \"--- foo\" as the old file name\n>> in the file header, causing it to generate a bad patch file when\n>> the user tried to stage or unstage a hunk or the selected line.\n>> We need to keep track of where we are in the parsing so that we do\n>> not misread a deletion or addition record as part of the header.\n>\n> This (slightly) breaks parsing of new files and removed files that are\n> staged by showing the file names in the diff header:\n>\n>  new file mode 100644\n>  --- /dev/null\n>  +++ b/foo\n>  @@ -0,0 +1 @@\n>  +foo\n\nI just noticed the same, and ask me why this report wasn't honored.\n\nAlso git may spill out 2 diffs for type changes (file to symlink, for\nexample). In this case the we should probably disable any hunk- or\nline-level (un)staging.\n\nBert\n\n>\n> -- Hannes\n"},{"id":"156901","messageId":"AANLkTikd84--37+vcoHifqFeUGznEQ9YXDaY3a3zOekn@mail.gmail.com","threadId":"15363","inReplyTo":"AANLkTimz17vodjS7K_ts2pcoZHTo2eb9=FaWwEyhihsa@mail.gmail.com","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-11-30T22:20:03Z","receivedAt":"2010-11-30T22:20:03Z","isPatch":false,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Tue, Nov 30, 2010 at 22:19, Bert Wesarg <bert.wesarg@googlemail.com> wrote:\n> On Mon, Sep 15, 2008 at 09:08, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>  new file mode 100644\n>>  --- /dev/null\n>>  +++ b/foo\n>>  @@ -0,0 +1 @@\n>>  +foo\n>\n> I just noticed the same, and ask me why this report wasn't honored.\n>\n> Also git may spill out 2 diffs for type changes (file to symlink, for\n> example). In this case the we should probably disable any hunk- or\n> line-level (un)staging.\n\nHere is a proposal which fixes this case. Not tested on the OPs report.\n\n--8<--\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 8fea947..b3901c3 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -398,7 +398,6 @@ proc read_diff {fd conflict_size cont_info} {\n \t\tif {$line eq {deleted file mode 120000}} {\n \t\t\tset line \"deleted symlink\"\n \t\t}\n-\t\tset ::current_diff_inheader 0\n\n \t\t# -- Automatically detect if this is a 3 way diff.\n \t\t#\n@@ -414,6 +413,7 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t|| [regexp {^\\* Unmerged path } $line]} {\n \t\t\tset tags {}\n \t\t} elseif {$is_3way_diff} {\n+\t\t\tset ::current_diff_inheader 0\n \t\t\tset op [string range $line 0 1]\n \t\t\tswitch -- $op {\n \t\t\t{  } {set tags {}}\n@@ -440,6 +440,7 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t}\n \t\t\t}\n \t\t} elseif {$is_submodule_diff} {\n+\t\t\tset ::current_diff_inheader 0\n \t\t\tif {$line == \"\"} continue\n \t\t\tif {[regexp {^Submodule } $line]} {\n \t\t\t\tset tags d_@\n@@ -459,6 +460,7 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t\t}\n \t\t\t}\n \t\t} else {\n+\t\t\tset ::current_diff_inheader 0\n \t\t\tset op [string index $line 0]\n \t\t\tswitch -- $op {\n \t\t\t{ } {set tags {}}\n"},{"id":"157436","messageId":"AANLkTi=VK6ghfzVbGmG0Ow7XGkWVa=QqorCBbMHo8e0O@mail.gmail.com","threadId":"15363","inReplyTo":"AANLkTikd84--37+vcoHifqFeUGznEQ9YXDaY3a3zOekn@mail.gmail.com","subject":"Re: Git Gui does not want to work on chunk level","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2010-12-06T21:30:08Z","receivedAt":"2010-12-06T21:30:08Z","isPatch":false,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Tue, Nov 30, 2010 at 23:20, Bert Wesarg <bert.wesarg@googlemail.com> wrote:\n> On Tue, Nov 30, 2010 at 22:19, Bert Wesarg <bert.wesarg@googlemail.com> wrote:\n>> On Mon, Sep 15, 2008 at 09:08, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>>  new file mode 100644\n>>>  --- /dev/null\n>>>  +++ b/foo\n>>>  @@ -0,0 +1 @@\n>>>  +foo\n>>\n>> I just noticed the same, and ask me why this report wasn't honored.\n>>\n>> Also git may spill out 2 diffs for type changes (file to symlink, for\n>> example). In this case the we should probably disable any hunk- or\n>> line-level (un)staging.\n>\n> Here is a proposal which fixes this case. Not tested on the OPs report.\n>\n> --8<--\n> diff --git a/lib/diff.tcl b/lib/diff.tcl\n> index 8fea947..b3901c3 100644\n> --- a/lib/diff.tcl\n> +++ b/lib/diff.tcl\n> @@ -398,7 +398,6 @@ proc read_diff {fd conflict_size cont_info} {\n>                if {$line eq {deleted file mode 120000}} {\n>                        set line \"deleted symlink\"\n>                }\n> -               set ::current_diff_inheader 0\n>\n>                # -- Automatically detect if this is a 3 way diff.\n>                #\n> @@ -414,6 +413,7 @@ proc read_diff {fd conflict_size cont_info} {\n>                        || [regexp {^\\* Unmerged path } $line]} {\n>                        set tags {}\n>                } elseif {$is_3way_diff} {\n> +                       set ::current_diff_inheader 0\n>                        set op [string range $line 0 1]\n>                        switch -- $op {\n>                        {  } {set tags {}}\n> @@ -440,6 +440,7 @@ proc read_diff {fd conflict_size cont_info} {\n>                        }\n>                        }\n>                } elseif {$is_submodule_diff} {\n> +                       set ::current_diff_inheader 0\n>                        if {$line == \"\"} continue\n>                        if {[regexp {^Submodule } $line]} {\n>                                set tags d_@\n> @@ -459,6 +460,7 @@ proc read_diff {fd conflict_size cont_info} {\n>                                }\n>                        }\n>                } else {\n> +                       set ::current_diff_inheader 0\n>                        set op [string index $line 0]\n>                        switch -- $op {\n>                        { } {set tags {}}\n>\n\nPlease ignore this proposal. I have a better solution in the pipe\n(which solves both problems reported here).\n\nBert\n"}]}