{"thread":{"id":"51928","subject":"[PATCH 1/1] git gui: fix staging a second line to a 1-line file","startedAt":"2019-09-26T17:43:30Z","lastAt":"2019-09-26T21:05:44Z","messageCount":5,"participants":["Johannes Schindelin via GitGitGadget","Bert Wesarg","Pratyush Yadav","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"383003","messageId":"02ec6c5bde2f15c51e946c6806d8231fb5abffe5.1569519804.git.gitgitgadget@gmail.com","threadId":"51928","inReplyTo":"pull.359.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] git gui: fix staging a second line to a 1-line file","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-26T17:43:26Z","receivedAt":"2019-09-26T17:43:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen a 1-line file is augmented by a second line, and the user tries to\nstage that single line via the \"Stage Line\" context menu item, we do not\nwant to see \"apply: corrupt patch at line 5\".\n\nThe reason for this error was that the hunk header looks like this:\n\n\t@@ -1 +1,2 @@\n\nbut the existing code expects the original range always to contain a\ncomma. This problem is easily fixed by cutting the string \"1 +1,2\"\n(that Git GUI formerly mistook for the starting line) at the space.\n\nThis fixes https://github.com/git-for-windows/git/issues/515\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n lib/diff.tcl | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 4cae10a4c7..68c4a6c736 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -698,6 +698,7 @@ proc apply_range_or_line {x y} {\n \t\tset hh [$ui_diff get $i_l \"$i_l + 1 lines\"]\n \t\tset hh [lindex [split $hh ,] 0]\n \t\tset hln [lindex [split $hh -] 1]\n+\t\tset hln [lindex [split $hln \" \"] 0]\n \n \t\t# There is a special situation to take care of. Consider this\n \t\t# hunk:\n-- \ngitgitgadget\n"},{"id":"383004","messageId":"pull.359.git.gitgitgadget@gmail.com","threadId":"51928","inReplyTo":null,"subject":"[PATCH 0/1] git gui: fix staging a second line to a 1-line file","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-26T17:43:25Z","receivedAt":"2019-09-26T17:43:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Yet another patch that is carried in Git for Windows for quite a long time.\nThis fixes https://github.com/git-for-windows/git/issues/515.\n\nThis commit was contributed as https://github.com/patthoyts/git/gui/pull/7 \nwhich was ignored for almost three years, and then as \nhttps://github.com/prati0100/git-gui/pull/1 which was rejected in favor of a\nmailing list-centric workflow.\n\nThe patch is based on Git GUI's master branch at \nhttps://github.com/prati0100/git-gui/.\n\nJohannes Schindelin (1):\n  git gui: fix staging a second line to a 1-line file\n\n lib/diff.tcl | 1 +\n 1 file changed, 1 insertion(+)\n\n\nbase-commit: 12d29c326551a6570594db525bea42ad9cea8028\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-359%2Fdscho%2Fgit-gui-stage-line-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-359/dscho/git-gui-stage-line-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/359\n-- \ngitgitgadget\n"},{"id":"383010","messageId":"CAKPyHN1XJHtcdzhaaeACFfb9=7PxdyHvrdafwJxDwQjbW_hbcA@mail.gmail.com","threadId":"51928","inReplyTo":"02ec6c5bde2f15c51e946c6806d8231fb5abffe5.1569519804.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] git gui: fix staging a second line to a 1-line file","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-09-26T18:25:46Z","receivedAt":"2019-09-26T18:26:00Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Thu, Sep 26, 2019 at 7:43 PM Johannes Schindelin via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> When a 1-line file is augmented by a second line, and the user tries to\n> stage that single line via the \"Stage Line\" context menu item, we do not\n> want to see \"apply: corrupt patch at line 5\".\n>\n> The reason for this error was that the hunk header looks like this:\n>\n>         @@ -1 +1,2 @@\n>\n> but the existing code expects the original range always to contain a\n> comma. This problem is easily fixed by cutting the string \"1 +1,2\"\n> (that Git GUI formerly mistook for the starting line) at the space.\n>\n> This fixes https://github.com/git-for-windows/git/issues/515\n>\n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  lib/diff.tcl | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/lib/diff.tcl b/lib/diff.tcl\n> index 4cae10a4c7..68c4a6c736 100644\n> --- a/lib/diff.tcl\n> +++ b/lib/diff.tcl\n> @@ -698,6 +698,7 @@ proc apply_range_or_line {x y} {\n>                 set hh [$ui_diff get $i_l \"$i_l + 1 lines\"]\n>                 set hh [lindex [split $hh ,] 0]\n>                 set hln [lindex [split $hh -] 1]\n> +               set hln [lindex [split $hln \" \"] 0]\n\nthis is already in that master\n\nhttps://github.com/prati0100/git-gui/blob/60c60b627e81bf84e1cb01729d2ae882178f079d/lib/diff.tcl#L727\n\n>\n>                 # There is a special situation to take care of. Consider this\n>                 # hunk:\n> --\n> gitgitgadget\n"},{"id":"383013","messageId":"20190926184449.swkqutltmwpzde6s@yadavpratyush.com","threadId":"51928","inReplyTo":"CAKPyHN1XJHtcdzhaaeACFfb9=7PxdyHvrdafwJxDwQjbW_hbcA@mail.gmail.com","subject":"Re: [PATCH 1/1] git gui: fix staging a second line to a 1-line file","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-26T18:44:49Z","receivedAt":"2019-09-26T18:44:56Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 26/09/19 08:25PM, Bert Wesarg wrote:\n> On Thu, Sep 26, 2019 at 7:43 PM Johannes Schindelin via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> >\n> > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> >\n> > When a 1-line file is augmented by a second line, and the user tries to\n> > stage that single line via the \"Stage Line\" context menu item, we do not\n> > want to see \"apply: corrupt patch at line 5\".\n> >\n> > The reason for this error was that the hunk header looks like this:\n> >\n> >         @@ -1 +1,2 @@\n> >\n> > but the existing code expects the original range always to contain a\n> > comma. This problem is easily fixed by cutting the string \"1 +1,2\"\n> > (that Git GUI formerly mistook for the starting line) at the space.\n> >\n> > This fixes https://github.com/git-for-windows/git/issues/515\n> >\n> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > ---\n> >  lib/diff.tcl | 1 +\n> >  1 file changed, 1 insertion(+)\n> >\n> > diff --git a/lib/diff.tcl b/lib/diff.tcl\n> > index 4cae10a4c7..68c4a6c736 100644\n> > --- a/lib/diff.tcl\n> > +++ b/lib/diff.tcl\n> > @@ -698,6 +698,7 @@ proc apply_range_or_line {x y} {\n> >                 set hh [$ui_diff get $i_l \"$i_l + 1 lines\"]\n> >                 set hh [lindex [split $hh ,] 0]\n> >                 set hln [lindex [split $hh -] 1]\n> > +               set hln [lindex [split $hln \" \"] 0]\n> \n> this is already in that master\n\nYes, this was recently merged in when I was pulling in some stuff that \nwent directly into git.git's git-gui subtree, instead of making it into \ngit-gui first (thread at [0] in case someone wants to find out more). \nThis commit was one of those. Junio directly merged this commit into \ngit/git-gui, along with some other stuff from Johannes in the commit \n02a5f25d95 (Merge branch 'js/misc-git-gui-stuff' of ../git-gui) of \ngit.git.\n\n[0] https://public-inbox.org/git/CAGr--=KXqFbivuXHPNecb3dBR_hx8QqWoR4pBGXy7uOiT+ESbg@mail.gmail.com/\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383028","messageId":"nycvar.QRO.7.76.6.1909262303310.15067@tvgsbejvaqbjf.bet","threadId":"51928","inReplyTo":"20190926184449.swkqutltmwpzde6s@yadavpratyush.com","subject":"Re: [PATCH 1/1] git gui: fix staging a second line to a 1-line file","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-09-26T21:05:20Z","receivedAt":"2019-09-26T21:05:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n\nOn Fri, 27 Sep 2019, Pratyush Yadav wrote:\n\n> On 26/09/19 08:25PM, Bert Wesarg wrote:\n> > On Thu, Sep 26, 2019 at 7:43 PM Johannes Schindelin via GitGitGadget\n> > <gitgitgadget@gmail.com> wrote:\n> > >\n> > > From: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > >\n> > > When a 1-line file is augmented by a second line, and the user tries to\n> > > stage that single line via the \"Stage Line\" context menu item, we do not\n> > > want to see \"apply: corrupt patch at line 5\".\n> > >\n> > > The reason for this error was that the hunk header looks like this:\n> > >\n> > >         @@ -1 +1,2 @@\n> > >\n> > > but the existing code expects the original range always to contain a\n> > > comma. This problem is easily fixed by cutting the string \"1 +1,2\"\n> > > (that Git GUI formerly mistook for the starting line) at the space.\n> > >\n> > > This fixes https://github.com/git-for-windows/git/issues/515\n> > >\n> > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> > > ---\n> > >  lib/diff.tcl | 1 +\n> > >  1 file changed, 1 insertion(+)\n> > >\n> > > diff --git a/lib/diff.tcl b/lib/diff.tcl\n> > > index 4cae10a4c7..68c4a6c736 100644\n> > > --- a/lib/diff.tcl\n> > > +++ b/lib/diff.tcl\n> > > @@ -698,6 +698,7 @@ proc apply_range_or_line {x y} {\n> > >                 set hh [$ui_diff get $i_l \"$i_l + 1 lines\"]\n> > >                 set hh [lindex [split $hh ,] 0]\n> > >                 set hln [lindex [split $hh -] 1]\n> > > +               set hln [lindex [split $hln \" \"] 0]\n> >\n> > this is already in that master\n\nSorry, I thought I had rebased, but I obviously failed to do so.\n\nCiao,\nJohannes\n>\n> Yes, this was recently merged in when I was pulling in some stuff that\n> went directly into git.git's git-gui subtree, instead of making it into\n> git-gui first (thread at [0] in case someone wants to find out more).\n> This commit was one of those. Junio directly merged this commit into\n> git/git-gui, along with some other stuff from Johannes in the commit\n> 02a5f25d95 (Merge branch 'js/misc-git-gui-stuff' of ../git-gui) of\n> git.git.\n>\n> [0] https://public-inbox.org/git/CAGr--=KXqFbivuXHPNecb3dBR_hx8QqWoR4pBGXy7uOiT+ESbg@mail.gmail.com/\n>\n> --\n> Regards,\n> Pratyush Yadav\n>\n"}]}