{"thread":{"id":"51919","subject":"[PATCH 1/2] git-gui: use existing interface to query a path's attribute","startedAt":"2019-09-25T20:38:56Z","lastAt":"2019-10-04T16:09:42Z","messageCount":9,"participants":["Bert Wesarg","Pratyush Yadav","Philip Oakley"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"382942","messageId":"97013a71289857767100d6a4adcb39ca99b2b21b.1569443729.git.bert.wesarg@googlemail.com","threadId":"51919","inReplyTo":null,"subject":"[PATCH 1/2] git-gui: use existing interface to query a path's attribute","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-09-25T20:38:50Z","receivedAt":"2019-09-25T20:38:56Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Replace the hand-coded call to git check-attr with the already provided one.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n lib/diff.tcl | 15 +--------------\n 1 file changed, 1 insertion(+), 14 deletions(-)\n\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 958a0fa..0fd4600 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -270,19 +270,6 @@ proc show_other_diff {path w m cont_info} {\n \t}\n }\n \n-proc get_conflict_marker_size {path} {\n-\tset size 7\n-\tcatch {\n-\t\tset fd_rc [eval [list git_read check-attr \"conflict-marker-size\" -- $path]]\n-\t\tset ret [gets $fd_rc line]\n-\t\tclose $fd_rc\n-\t\tif {$ret > 0} {\n-\t\t\tregexp {.*: conflict-marker-size: (\\d+)$} $line line size\n-\t\t}\n-\t}\n-\treturn $size\n-}\n-\n proc start_show_diff {cont_info {add_opts {}}} {\n \tglobal file_states file_lists\n \tglobal is_3way_diff is_submodule_diff diff_active repo_config\n@@ -298,7 +285,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \tset is_submodule_diff 0\n \tset diff_active 1\n \tset current_diff_header {}\n-\tset conflict_size [get_conflict_marker_size $path]\n+\tset conflict_size [gitattr $path conflict-marker-size 7]\n \n \tset cmd [list]\n \tif {$w eq $ui_index} {\n-- \n2.21.0.789.ga095d9d866\n\n"},{"id":"382943","messageId":"f1477ba53a03484a0440202065a5293c8795d3b7.1569443729.git.bert.wesarg@googlemail.com","threadId":"51919","inReplyTo":"97013a71289857767100d6a4adcb39ca99b2b21b.1569443729.git.bert.wesarg@googlemail.com","subject":"[PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-09-25T20:38:51Z","receivedAt":"2019-09-25T20:38:58Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"This adds highlight support for the diff3 conflict style.\n\nThe common pre-image will be reversed to --, because it has been removed\nand either replaced with ours or theirs side.\n\nSigned-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n---\n git-gui.sh   |  3 +++\n lib/diff.tcl | 22 ++++++++++++++++++++++\n 2 files changed, 25 insertions(+)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex fd476b6..6d80f82 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -3581,6 +3581,9 @@ $ui_diff tag conf d_s- \\\n $ui_diff tag conf d< \\\n \t-foreground orange \\\n \t-font font_diffbold\n+$ui_diff tag conf d| \\\n+\t-foreground orange \\\n+\t-font font_diffbold\n $ui_diff tag conf d= \\\n \t-foreground orange \\\n \t-font font_diffbold\ndiff --git a/lib/diff.tcl b/lib/diff.tcl\nindex 0fd4600..6caf4e7 100644\n--- a/lib/diff.tcl\n+++ b/lib/diff.tcl\n@@ -347,6 +347,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n \t}\n \n \tset ::current_diff_inheader 1\n+\tset ::conflict_state {CONTEXT}\n \tfconfigure $fd \\\n \t\t-blocking 0 \\\n \t\t-encoding [get_path_encoding $path] \\\n@@ -450,10 +451,28 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t{++} {\n \t\t\t\tset regexp [string map [list %conflict_size $conflict_size]\\\n \t\t\t\t\t\t\t\t{^\\+\\+([<>=]){%conflict_size}(?: |$)}]\n+\t\t\t\tset regexp_pre_image [string map [list %conflict_size $conflict_size]\\\n+\t\t\t\t\t\t\t\t{^\\+\\+\\|{%conflict_size}(?: |$)}]\n \t\t\t\tif {[regexp $regexp $line _g op]} {\n \t\t\t\t\tset is_conflict_diff 1\n \t\t\t\t\tset line [string replace $line 0 1 {  }]\n+\t\t\t\t\tset markup {}\n \t\t\t\t\tset tags d$op\n+\t\t\t\t\tswitch -exact -- $op {\n+\t\t\t\t\t< { set ::conflict_state {OURS} }\n+\t\t\t\t\t= { set ::conflict_state {THEIRS} }\n+\t\t\t\t\t> { set ::conflict_state {CONTEXT} }\n+\t\t\t\t\t}\n+\t\t\t\t} elseif {[regexp $regexp_pre_image $line]} {\n+\t\t\t\t\tset is_conflict_diff 1\n+\t\t\t\t\tset line [string replace $line 0 1 {  }]\n+\t\t\t\t\tset markup {}\n+\t\t\t\t\tset tags d|\n+\t\t\t\t\tset ::conflict_state {BASE}\n+\t\t\t\t} elseif {$::conflict_state eq {BASE}} {\n+\t\t\t\t\tset line [string replace $line 0 1 {--}]\n+\t\t\t\t\tset markup {}\n+\t\t\t\t\tset tags d_--\n \t\t\t\t} else {\n \t\t\t\t\tset tags d_++\n \t\t\t\t}\n@@ -505,6 +524,9 @@ proc read_diff {fd conflict_size cont_info} {\n \t\t\t}\n \t\t}\n \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n+\t\tif {[llength $markup] > 0} {\n+\t\t\tset tags {}\n+\t\t}\n \t\t$ui_diff insert end $line $tags\n \t\tif {[string index $line end] eq \"\\r\"} {\n \t\t\t$ui_diff tag add d_cr {end - 2c}\n-- \n2.21.0.789.ga095d9d866\n\n"},{"id":"383053","messageId":"20190927052723.4ttgxpqijqde57er@yadavpratyush.com","threadId":"51919","inReplyTo":"97013a71289857767100d6a4adcb39ca99b2b21b.1569443729.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 1/2] git-gui: use existing interface to query a path's attribute","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-27T05:27:23Z","receivedAt":"2019-09-27T05:31:18Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Looks good. Thanks.\n\nOn 25/09/19 10:38PM, Bert Wesarg wrote:\n> Replace the hand-coded call to git check-attr with the already provided one.\n> \n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> ---\n>  lib/diff.tcl | 15 +--------------\n>  1 file changed, 1 insertion(+), 14 deletions(-)\n> \n> diff --git a/lib/diff.tcl b/lib/diff.tcl\n> index 958a0fa..0fd4600 100644\n> --- a/lib/diff.tcl\n> +++ b/lib/diff.tcl\n> @@ -270,19 +270,6 @@ proc show_other_diff {path w m cont_info} {\n>  \t}\n>  }\n>  \n> -proc get_conflict_marker_size {path} {\n> -\tset size 7\n> -\tcatch {\n> -\t\tset fd_rc [eval [list git_read check-attr \"conflict-marker-size\" -- $path]]\n> -\t\tset ret [gets $fd_rc line]\n> -\t\tclose $fd_rc\n> -\t\tif {$ret > 0} {\n> -\t\t\tregexp {.*: conflict-marker-size: (\\d+)$} $line line size\n> -\t\t}\n> -\t}\n> -\treturn $size\n> -}\n> -\n>  proc start_show_diff {cont_info {add_opts {}}} {\n>  \tglobal file_states file_lists\n>  \tglobal is_3way_diff is_submodule_diff diff_active repo_config\n> @@ -298,7 +285,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n>  \tset is_submodule_diff 0\n>  \tset diff_active 1\n>  \tset current_diff_header {}\n> -\tset conflict_size [get_conflict_marker_size $path]\n> +\tset conflict_size [gitattr $path conflict-marker-size 7]\n>  \n>  \tset cmd [list]\n>  \tif {$w eq $ui_index} {\n> -- \n> 2.21.0.789.ga095d9d866\n> \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383100","messageId":"20190929150406.s57pmb3dggfbcqhr@yadavpratyush.com","threadId":"51919","inReplyTo":"f1477ba53a03484a0440202065a5293c8795d3b7.1569443729.git.bert.wesarg@googlemail.com","subject":"Re: [PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-09-29T15:04:07Z","receivedAt":"2019-09-29T15:13:02Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Philip, Bert,\n\nIs there any way I can test this change? Philip, I ran the rebase you \nmention in the GitHub issue [0], and I get that '9c8cba6862abe5ac821' is \nan unknown revision.\n\nIs there any quick way I can reproduce this (maybe on a sample repo)?\n\n[0] https://github.com/git-for-windows/git/issues/2340\n\nOn 25/09/19 10:38PM, Bert Wesarg wrote:\n> This adds highlight support for the diff3 conflict style.\n> \n> The common pre-image will be reversed to --, because it has been removed\n> and either replaced with ours or theirs side.\n> \n> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> ---\n>  git-gui.sh   |  3 +++\n>  lib/diff.tcl | 22 ++++++++++++++++++++++\n>  2 files changed, 25 insertions(+)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index fd476b6..6d80f82 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -3581,6 +3581,9 @@ $ui_diff tag conf d_s- \\\n>  $ui_diff tag conf d< \\\n>  \t-foreground orange \\\n>  \t-font font_diffbold\n> +$ui_diff tag conf d| \\\n> +\t-foreground orange \\\n> +\t-font font_diffbold\n>  $ui_diff tag conf d= \\\n>  \t-foreground orange \\\n>  \t-font font_diffbold\n> diff --git a/lib/diff.tcl b/lib/diff.tcl\n> index 0fd4600..6caf4e7 100644\n> --- a/lib/diff.tcl\n> +++ b/lib/diff.tcl\n> @@ -347,6 +347,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n>  \t}\n>  \n>  \tset ::current_diff_inheader 1\n> +\tset ::conflict_state {CONTEXT}\n>  \tfconfigure $fd \\\n>  \t\t-blocking 0 \\\n>  \t\t-encoding [get_path_encoding $path] \\\n> @@ -450,10 +451,28 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t\t{++} {\n>  \t\t\t\tset regexp [string map [list %conflict_size $conflict_size]\\\n>  \t\t\t\t\t\t\t\t{^\\+\\+([<>=]){%conflict_size}(?: |$)}]\n> +\t\t\t\tset regexp_pre_image [string map [list %conflict_size $conflict_size]\\\n> +\t\t\t\t\t\t\t\t{^\\+\\+\\|{%conflict_size}(?: |$)}]\n>  \t\t\t\tif {[regexp $regexp $line _g op]} {\n>  \t\t\t\t\tset is_conflict_diff 1\n>  \t\t\t\t\tset line [string replace $line 0 1 {  }]\n> +\t\t\t\t\tset markup {}\n>  \t\t\t\t\tset tags d$op\n> +\t\t\t\t\tswitch -exact -- $op {\n> +\t\t\t\t\t< { set ::conflict_state {OURS} }\n> +\t\t\t\t\t= { set ::conflict_state {THEIRS} }\n> +\t\t\t\t\t> { set ::conflict_state {CONTEXT} }\n> +\t\t\t\t\t}\n> +\t\t\t\t} elseif {[regexp $regexp_pre_image $line]} {\n> +\t\t\t\t\tset is_conflict_diff 1\n> +\t\t\t\t\tset line [string replace $line 0 1 {  }]\n> +\t\t\t\t\tset markup {}\n> +\t\t\t\t\tset tags d|\n> +\t\t\t\t\tset ::conflict_state {BASE}\n> +\t\t\t\t} elseif {$::conflict_state eq {BASE}} {\n> +\t\t\t\t\tset line [string replace $line 0 1 {--}]\n> +\t\t\t\t\tset markup {}\n> +\t\t\t\t\tset tags d_--\n\nI'm afraid I don't follow what this hunk is supposed to do.\n\nYou set the variable ::conflict_state to the values like OURS, THEIRS, \nCONTEXT, but I don't see those values being used anywhere. A quick \nsearch for these words shows me that you only set them, never read them.\n\nIs there some extra code that you have and I don't?\n\nAlso, this function is long and complicated already. A comment \nexplaining what this code is doing would be nice, since it is not at all \nobvious at first read-through.\n\n>  \t\t\t\t} else {\n>  \t\t\t\t\tset tags d_++\n>  \t\t\t\t}\n> @@ -505,6 +524,9 @@ proc read_diff {fd conflict_size cont_info} {\n>  \t\t\t}\n>  \t\t}\n>  \t\tset mark [$ui_diff index \"end - 1 line linestart\"]\n> +\t\tif {[llength $markup] > 0} {\n> +\t\t\tset tags {}\n> +\t\t}\n>  \t\t$ui_diff insert end $line $tags\n>  \t\tif {[string index $line end] eq \"\\r\"} {\n>  \t\t\t$ui_diff tag add d_cr {end - 2c}\n> -- \n> 2.21.0.789.ga095d9d866\n> \n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383156","messageId":"CAKPyHN3nOL6qy4RhwwHrh2m3EJuJ1-rt-8+0+=z2oJi96Nigpw@mail.gmail.com","threadId":"51919","inReplyTo":"20190929150406.s57pmb3dggfbcqhr@yadavpratyush.com","subject":"Re: [PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2019-09-30T12:17:04Z","receivedAt":"2019-09-30T12:17:19Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Pratyush,\n\nOn Sun, Sep 29, 2019 at 5:04 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n>\n> Hi Philip, Bert,\n>\n> Is there any way I can test this change? Philip, I ran the rebase you\n> mention in the GitHub issue [0], and I get that '9c8cba6862abe5ac821' is\n> an unknown revision.\n>\n> Is there any quick way I can reproduce this (maybe on a sample repo)?\n\nThe easiest way to produce a merge conflict, is to change the same\nline differently in two branches and try to merge them. I added a\nfast-import file to demonstrate this for you.\n\n$ git init foo\n$ cd foo\n$ git fast-import <../conflict-merge.fi\n$ git reset --hard master\n$ git merge branch\n\nthis gets you into the conflict, probably the usual style. Which looks\nin liek this on the terminal:\n\n@@@ -2,7 -2,7 +2,11 @@@ Lorem ipsum dolor sit amet, consectetu\n  Sed feugiat nisl eget efficitur ultrices.\n  Nunc cursus metus rutrum, mollis lorem vitae, hendrerit mi.\n  Aenean vestibulum ante ac libero venenatis, non hendrerit orci pharetra.\n++<<<<<<< HEAD\n +Proin bibendum purus ut est tristique, non pharetra dui consectetur.\n++=======\n+ Proin placerat leo malesuada lacinia lobortis.\n++>>>>>>> branch\n  Pellentesque aliquam libero et nisi scelerisque commodo.\n  Quisque id velit sed magna molestie porttitor.\n  Vivamus sed urna in risus molestie ultricies.\n\nand this in git gui: https://kgab.selfhost.eu/s/gHHaQqowGp7mXEb\n\nGit gui removes the '++' in front of the marker lines. It therefor\nalready 'changes' the 'diff'. Though git-apply cannot handle such\n'diffs' anyway.\n\nTo get the diff3 style do:\n\n$ git merge --abort\n$ git -c merge.conflictStyle=diff3 merge branch\n\nThis is how it looks in the terminal now:\n\n@@@ -2,7 -2,7 +2,13 @@@ Lorem ipsum dolor sit amet, consectetu\n  Sed feugiat nisl eget efficitur ultrices.\n  Nunc cursus metus rutrum, mollis lorem vitae, hendrerit mi.\n  Aenean vestibulum ante ac libero venenatis, non hendrerit orci pharetra.\n++<<<<<<< HEAD\n +Proin bibendum purus ut est tristique, non pharetra dui consectetur.\n++||||||| merged common ancestors\n++Proin in felis eu elit suscipit rhoncus vel ut metus.\n++=======\n+ Proin placerat leo malesuada lacinia lobortis.\n++>>>>>>> branch\n  Pellentesque aliquam libero et nisi scelerisque commodo.\n  Quisque id velit sed magna molestie porttitor.\n  Vivamus sed urna in risus molestie ultricies.\n\nAs you can see, there is not the usual 'I removed this, and added\nthat' experience, everything is 'added'. Thus I inverted the pre-image\nto '--'. Here is how it looks in the gui:\nhttps://kgab.selfhost.eu/s/5c8Tosra7WRfjwJ\n\n> [0] https://github.com/git-for-windows/git/issues/2340\n>\n> On 25/09/19 10:38PM, Bert Wesarg wrote:\n> > This adds highlight support for the diff3 conflict style.\n> >\n> > The common pre-image will be reversed to --, because it has been removed\n> > and either replaced with ours or theirs side.\n> >\n> > Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n> > ---\n> >  git-gui.sh   |  3 +++\n> >  lib/diff.tcl | 22 ++++++++++++++++++++++\n> >  2 files changed, 25 insertions(+)\n> >\n> > diff --git a/git-gui.sh b/git-gui.sh\n> > index fd476b6..6d80f82 100755\n> > --- a/git-gui.sh\n> > +++ b/git-gui.sh\n> > @@ -3581,6 +3581,9 @@ $ui_diff tag conf d_s- \\\n> >  $ui_diff tag conf d< \\\n> >       -foreground orange \\\n> >       -font font_diffbold\n> > +$ui_diff tag conf d| \\\n> > +     -foreground orange \\\n> > +     -font font_diffbold\n> >  $ui_diff tag conf d= \\\n> >       -foreground orange \\\n> >       -font font_diffbold\n> > diff --git a/lib/diff.tcl b/lib/diff.tcl\n> > index 0fd4600..6caf4e7 100644\n> > --- a/lib/diff.tcl\n> > +++ b/lib/diff.tcl\n> > @@ -347,6 +347,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n> >       }\n> >\n> >       set ::current_diff_inheader 1\n> > +     set ::conflict_state {CONTEXT}\n> >       fconfigure $fd \\\n> >               -blocking 0 \\\n> >               -encoding [get_path_encoding $path] \\\n> > @@ -450,10 +451,28 @@ proc read_diff {fd conflict_size cont_info} {\n> >                       {++} {\n> >                               set regexp [string map [list %conflict_size $conflict_size]\\\n> >                                                               {^\\+\\+([<>=]){%conflict_size}(?: |$)}]\n> > +                             set regexp_pre_image [string map [list %conflict_size $conflict_size]\\\n> > +                                                             {^\\+\\+\\|{%conflict_size}(?: |$)}]\n> >                               if {[regexp $regexp $line _g op]} {\n> >                                       set is_conflict_diff 1\n> >                                       set line [string replace $line 0 1 {  }]\n> > +                                     set markup {}\n> >                                       set tags d$op\n> > +                                     switch -exact -- $op {\n> > +                                     < { set ::conflict_state {OURS} }\n> > +                                     = { set ::conflict_state {THEIRS} }\n> > +                                     > { set ::conflict_state {CONTEXT} }\n> > +                                     }\n> > +                             } elseif {[regexp $regexp_pre_image $line]} {\n> > +                                     set is_conflict_diff 1\n> > +                                     set line [string replace $line 0 1 {  }]\n> > +                                     set markup {}\n> > +                                     set tags d|\n> > +                                     set ::conflict_state {BASE}\n> > +                             } elseif {$::conflict_state eq {BASE}} {\n> > +                                     set line [string replace $line 0 1 {--}]\n> > +                                     set markup {}\n> > +                                     set tags d_--\n>\n> I'm afraid I don't follow what this hunk is supposed to do.\n>\n> You set the variable ::conflict_state to the values like OURS, THEIRS,\n> CONTEXT, but I don't see those values being used anywhere. A quick\n> search for these words shows me that you only set them, never read them.\n\nthe last elseif depends on it.\n\nI actually only need to detect the pre-image lines, which starts with\nthe ||| conflict-marker and ends with the === conflict-marker, instead\nof all possible states.\n\n>\n> Is there some extra code that you have and I don't?\n>\n> Also, this function is long and complicated already. A comment\n> explaining what this code is doing would be nice, since it is not at all\n> obvious at first read-through.\n\nWill re-send.\n\nBert\n\n>\n> >                               } else {\n> >                                       set tags d_++\n> >                               }\n> > @@ -505,6 +524,9 @@ proc read_diff {fd conflict_size cont_info} {\n> >                       }\n> >               }\n> >               set mark [$ui_diff index \"end - 1 line linestart\"]\n> > +             if {[llength $markup] > 0} {\n> > +                     set tags {}\n> > +             }\n> >               $ui_diff insert end $line $tags\n> >               if {[string index $line end] eq \"\\r\"} {\n> >                       $ui_diff tag add d_cr {end - 2c}\n> > --\n> > 2.21.0.789.ga095d9d866\n> >\n>\n> --\n> Regards,\n> Pratyush Yadav\n"},{"id":"383346","messageId":"dc210bf0-eef3-ed58-f596-0999fd9d9a98@iee.email","threadId":"51919","inReplyTo":"CAKPyHN3nOL6qy4RhwwHrh2m3EJuJ1-rt-8+0+=z2oJi96Nigpw@mail.gmail.com","subject":"Re: [PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-10-03T20:02:47Z","receivedAt":"2019-10-03T20:02:53Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 30/09/2019 13:17, Bert Wesarg wrote:\n> Pratyush,\n>\n> On Sun, Sep 29, 2019 at 5:04 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n>> Hi Philip, Bert,\n>>\n>> Is there any way I can test this change? Philip, I ran the rebase you\n>> mention in the GitHub issue [0], and I get that '9c8cba6862abe5ac821' is\n>> an unknown revision.\n>>\n>> Is there any quick way I can reproduce this (maybe on a sample repo)?\n> The easiest way to produce a merge conflict, is to change the same\n> line differently in two branches and try to merge them. I added a\n> fast-import file to demonstrate this for you.\n>\n> $ git init foo\n> $ cd foo\n> $ git fast-import <../conflict-merge.fi\n> $ git reset --hard master\n> $ git merge branch\n>\n> this gets you into the conflict, probably the usual style. Which looks\n> in liek this on the terminal:\n>\n> @@@ -2,7 -2,7 +2,11 @@@ Lorem ipsum dolor sit amet, consectetu\n>    Sed feugiat nisl eget efficitur ultrices.\n>    Nunc cursus metus rutrum, mollis lorem vitae, hendrerit mi.\n>    Aenean vestibulum ante ac libero venenatis, non hendrerit orci pharetra.\n> ++<<<<<<< HEAD\n>   +Proin bibendum purus ut est tristique, non pharetra dui consectetur.\n> ++=======\n> + Proin placerat leo malesuada lacinia lobortis.\n> ++>>>>>>> branch\n>    Pellentesque aliquam libero et nisi scelerisque commodo.\n>    Quisque id velit sed magna molestie porttitor.\n>    Vivamus sed urna in risus molestie ultricies.\n>\n> and this in git gui: https://kgab.selfhost.eu/s/gHHaQqowGp7mXEb\n\nThe snapshot of the Gui looks just the thing! (I've been away).\n\nI'm sure this would solve my immediate issue.\n\nMy only remaining bikeshed question it prompted was to check which parts \nwould be committed as part of committing the whole \"hunk\". But haven't \nhad time to look at all!\n\n>\n> Git gui removes the '++' in front of the marker lines. It therefor\n> already 'changes' the 'diff'. Though git-apply cannot handle such\n> 'diffs' anyway.\n>\n> To get the diff3 style do:\n>\n> $ git merge --abort\n> $ git -c merge.conflictStyle=diff3 merge branch\n>\n> This is how it looks in the terminal now:\n>\n> @@@ -2,7 -2,7 +2,13 @@@ Lorem ipsum dolor sit amet, consectetu\n>    Sed feugiat nisl eget efficitur ultrices.\n>    Nunc cursus metus rutrum, mollis lorem vitae, hendrerit mi.\n>    Aenean vestibulum ante ac libero venenatis, non hendrerit orci pharetra.\n> ++<<<<<<< HEAD\n>   +Proin bibendum purus ut est tristique, non pharetra dui consectetur.\n> ++||||||| merged common ancestors\n> ++Proin in felis eu elit suscipit rhoncus vel ut metus.\n> ++=======\n> + Proin placerat leo malesuada lacinia lobortis.\n> ++>>>>>>> branch\n>    Pellentesque aliquam libero et nisi scelerisque commodo.\n>    Quisque id velit sed magna molestie porttitor.\n>    Vivamus sed urna in risus molestie ultricies.\n>\n> As you can see, there is not the usual 'I removed this, and added\n> that' experience, everything is 'added'. Thus I inverted the pre-image\n> to '--'. Here is how it looks in the gui:\n> https://kgab.selfhost.eu/s/5c8Tosra7WRfjwJ\n>\n>> [0] https://github.com/git-for-windows/git/issues/2340\n>>\n>> On 25/09/19 10:38PM, Bert Wesarg wrote:\n>>> This adds highlight support for the diff3 conflict style.\n>>>\n>>> The common pre-image will be reversed to --, because it has been removed\n>>> and either replaced with ours or theirs side.\n>>>\n>>> Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>\n>>> ---\n>>>   git-gui.sh   |  3 +++\n>>>   lib/diff.tcl | 22 ++++++++++++++++++++++\n>>>   2 files changed, 25 insertions(+)\n>>>\n>>> diff --git a/git-gui.sh b/git-gui.sh\n>>> index fd476b6..6d80f82 100755\n>>> --- a/git-gui.sh\n>>> +++ b/git-gui.sh\n>>> @@ -3581,6 +3581,9 @@ $ui_diff tag conf d_s- \\\n>>>   $ui_diff tag conf d< \\\n>>>        -foreground orange \\\n>>>        -font font_diffbold\n>>> +$ui_diff tag conf d| \\\n>>> +     -foreground orange \\\n>>> +     -font font_diffbold\n>>>   $ui_diff tag conf d= \\\n>>>        -foreground orange \\\n>>>        -font font_diffbold\n>>> diff --git a/lib/diff.tcl b/lib/diff.tcl\n>>> index 0fd4600..6caf4e7 100644\n>>> --- a/lib/diff.tcl\n>>> +++ b/lib/diff.tcl\n>>> @@ -347,6 +347,7 @@ proc start_show_diff {cont_info {add_opts {}}} {\n>>>        }\n>>>\n>>>        set ::current_diff_inheader 1\n>>> +     set ::conflict_state {CONTEXT}\n>>>        fconfigure $fd \\\n>>>                -blocking 0 \\\n>>>                -encoding [get_path_encoding $path] \\\n>>> @@ -450,10 +451,28 @@ proc read_diff {fd conflict_size cont_info} {\n>>>                        {++} {\n>>>                                set regexp [string map [list %conflict_size $conflict_size]\\\n>>>                                                                {^\\+\\+([<>=]){%conflict_size}(?: |$)}]\n>>> +                             set regexp_pre_image [string map [list %conflict_size $conflict_size]\\\n>>> +                                                             {^\\+\\+\\|{%conflict_size}(?: |$)}]\n>>>                                if {[regexp $regexp $line _g op]} {\n>>>                                        set is_conflict_diff 1\n>>>                                        set line [string replace $line 0 1 {  }]\n>>> +                                     set markup {}\n>>>                                        set tags d$op\n>>> +                                     switch -exact -- $op {\n>>> +                                     < { set ::conflict_state {OURS} }\n>>> +                                     = { set ::conflict_state {THEIRS} }\n>>> +                                     > { set ::conflict_state {CONTEXT} }\n>>> +                                     }\n>>> +                             } elseif {[regexp $regexp_pre_image $line]} {\n>>> +                                     set is_conflict_diff 1\n>>> +                                     set line [string replace $line 0 1 {  }]\n>>> +                                     set markup {}\n>>> +                                     set tags d|\n>>> +                                     set ::conflict_state {BASE}\n>>> +                             } elseif {$::conflict_state eq {BASE}} {\n>>> +                                     set line [string replace $line 0 1 {--}]\n>>> +                                     set markup {}\n>>> +                                     set tags d_--\n>> I'm afraid I don't follow what this hunk is supposed to do.\n>>\n>> You set the variable ::conflict_state to the values like OURS, THEIRS,\n>> CONTEXT, but I don't see those values being used anywhere. A quick\n>> search for these words shows me that you only set them, never read them.\n> the last elseif depends on it.\n>\n> I actually only need to detect the pre-image lines, which starts with\n> the ||| conflict-marker and ends with the === conflict-marker, instead\n> of all possible states.\n>\n>> Is there some extra code that you have and I don't?\n>>\n>> Also, this function is long and complicated already. A comment\n>> explaining what this code is doing would be nice, since it is not at all\n>> obvious at first read-through.\n> Will re-send.\n>\n> Bert\n>\n>>>                                } else {\n>>>                                        set tags d_++\n>>>                                }\n>>> @@ -505,6 +524,9 @@ proc read_diff {fd conflict_size cont_info} {\n>>>                        }\n>>>                }\n>>>                set mark [$ui_diff index \"end - 1 line linestart\"]\n>>> +             if {[llength $markup] > 0} {\n>>> +                     set tags {}\n>>> +             }\n>>>                $ui_diff insert end $line $tags\n>>>                if {[string index $line end] eq \"\\r\"} {\n>>>                        $ui_diff tag add d_cr {end - 2c}\n>>> --\n>>> 2.21.0.789.ga095d9d866\n>>>\n>> --\n>> Regards,\n>> Pratyush Yadav\n\n"},{"id":"383361","messageId":"20191003205407.uaguw7qyabfy3aym@yadavpratyush.com","threadId":"51919","inReplyTo":"dc210bf0-eef3-ed58-f596-0999fd9d9a98@iee.email","subject":"Re: [PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-10-03T20:54:07Z","receivedAt":"2019-10-03T20:54:13Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 03/10/19 09:02PM, Philip Oakley wrote:\n> On 30/09/2019 13:17, Bert Wesarg wrote:\n> > Pratyush,\n> > \n> > On Sun, Sep 29, 2019 at 5:04 PM Pratyush Yadav <me@yadavpratyush.com> wrote:\n> > > Hi Philip, Bert,\n> > > \n> > > Is there any way I can test this change? Philip, I ran the rebase you\n> > > mention in the GitHub issue [0], and I get that '9c8cba6862abe5ac821' is\n> > > an unknown revision.\n> > > \n> > > Is there any quick way I can reproduce this (maybe on a sample repo)?\n> > The easiest way to produce a merge conflict, is to change the same\n> > line differently in two branches and try to merge them. I added a\n> > fast-import file to demonstrate this for you.\n> > \n> > $ git init foo\n> > $ cd foo\n> > $ git fast-import <../conflict-merge.fi\n> > $ git reset --hard master\n> > $ git merge branch\n> > \n> > this gets you into the conflict, probably the usual style. Which looks\n> > in liek this on the terminal:\n> > \n> > @@@ -2,7 -2,7 +2,11 @@@ Lorem ipsum dolor sit amet, consectetu\n> >    Sed feugiat nisl eget efficitur ultrices.\n> >    Nunc cursus metus rutrum, mollis lorem vitae, hendrerit mi.\n> >    Aenean vestibulum ante ac libero venenatis, non hendrerit orci pharetra.\n> > ++<<<<<<< HEAD\n> >   +Proin bibendum purus ut est tristique, non pharetra dui consectetur.\n> > ++=======\n> > + Proin placerat leo malesuada lacinia lobortis.\n> > ++>>>>>>> branch\n> >    Pellentesque aliquam libero et nisi scelerisque commodo.\n> >    Quisque id velit sed magna molestie porttitor.\n> >    Vivamus sed urna in risus molestie ultricies.\n> > \n> > and this in git gui: https://kgab.selfhost.eu/s/gHHaQqowGp7mXEb\n> \n> The snapshot of the Gui looks just the thing! (I've been away).\n> \n> I'm sure this would solve my immediate issue.\n> \n> My only remaining bikeshed question it prompted was to check which parts\n> would be committed as part of committing the whole \"hunk\". But haven't had\n> time to look at all!\n\nI'm not sure what you mean by \"committing the whole hunk\". In a merge \nconflict state, you don't get the usual \"Stage hunk\" and \"Stage lines\" \noptions, but instead get 3 options:\n\n  Use Remote Version\n  Use Local Version\n  Revert To Base\n\nYou can use these to choose how you want to resolve the conflict.\n\nThese 3 options seem to work fine on my quick testing.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"383364","messageId":"e5ae969c-6d82-ed13-b309-f8010288fbd9@iee.email","threadId":"51919","inReplyTo":"20191003205407.uaguw7qyabfy3aym@yadavpratyush.com","subject":"Re: [PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-10-03T21:40:09Z","receivedAt":"2019-10-03T21:40:15Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 03/10/2019 21:54, Pratyush Yadav wrote:\n>> My only remaining bikeshed question it prompted was to check which parts\n>> would be committed as part of committing the whole \"hunk\". But haven't had\n>> time to look at all!\n> I'm not sure what you mean by \"committing the whole hunk\". In a merge\n> conflict state, you don't get the usual \"Stage hunk\" and \"Stage lines\"\n> options, but instead get 3 options:\n>\n>    Use Remote Version\n>    Use Local Version\n>    Revert To Base\n>\n> You can use these to choose how you want to resolve the conflict.\n>\n> These 3 options seem to work fine on my quick testing.\nThat looks like just the answer I was hoping for!\n\nThanks.\n\n-- \nPhilip\n"},{"id":"383435","messageId":"c1d27317-3ca7-14c6-7fd8-047282894c68@iee.email","threadId":"51919","inReplyTo":"CAKPyHN0_AUqLpPVDNJUZqNV8zRQzaDOMXJV4AbnK969AdtGpNg@mail.gmail.com","subject":"Re: [PATCH 2/2] git-gui: support for diff3 conflict style","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-10-04T16:09:39Z","receivedAt":"2019-10-04T16:09:42Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 04/10/2019 16:22, Bert Wesarg wrote:\n> On Thu, Oct 3, 2019 at 11:40 PM Philip Oakley <philipoakley@iee.email> wrote:\n>> On 03/10/2019 21:54, Pratyush Yadav wrote:\n>>>> My only remaining bikeshed question it prompted was to check which parts\n>>>> would be committed as part of committing the whole \"hunk\". But haven't had\n>>>> time to look at all!\n>>> I'm not sure what you mean by \"committing the whole hunk\". In a merge\n>>> conflict state, you don't get the usual \"Stage hunk\" and \"Stage lines\"\n>>> options, but instead get 3 options:\n>>>\n>>>     Use Remote Version\n>>>     Use Local Version\n>>>     Revert To Base\n>>>\n>>> You can use these to choose how you want to resolve the conflict.\n>>>\n>>> These 3 options seem to work fine on my quick testing.\n>> That looks like just the answer I was hoping for!\n> note, that these three options apply to the whole file, not for\n> individual conflicts.\n>\n>\nHmm, maybe not as great as hoped, but it's a start.\nPhilip\n"}]}