{"thread":{"id":"48431","subject":"[PATCH 0/2] gitk: improve handling of submodules in the file list panel","startedAt":"2018-05-08T12:11:34Z","lastAt":"2018-05-09T18:52:35Z","messageCount":15,"participants":["Alex Riesen","Bert Wesarg","Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"346976","messageId":"20180508121104.rtsrektxiihvpqtx@pflmari","threadId":"48431","inReplyTo":null,"subject":"[PATCH 0/2] gitk: improve handling of submodules in the file list panel","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-08T12:11:04Z","receivedAt":"2018-05-08T12:11:34Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"Currently, the submodule entries in the file list panel are mostly ignored.\nThis series attempts to improve the situation by showing part of submodule\nhistory when focusing it in the file list panel and by adding a menu element\nto start gitk in the submodule (similar to git gui).\n\n  [1/2]: gitk: show part of submodule log instead of empty pane when listing trees\n  [2/2]: gitk: add an option to run gitk on an item in the file list\n\n gitk | 54 ++++++++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 44 insertions(+), 10 deletions(-)\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"346977","messageId":"20180508122229.k3n3ccpa5g3g4dxa@pflmari","threadId":"48431","inReplyTo":"20180508121104.rtsrektxiihvpqtx@pflmari","subject":"[PATCH 1/2] gitk: show part of submodule log instead of empty pane when listing trees","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-08T12:22:29Z","receivedAt":"2018-05-08T12:22:56Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nCurrently, the submodules either are not shown at all (if listing a\ncommitted tree) or a Tcl error appears (when clicking on a submodule\nfrom the index list).\n\nThis will make it show first arbitrarily chosen number of commits,\nwhich might be only marginally better.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n gitk | 42 ++++++++++++++++++++++++++++++++----------\n 1 file changed, 32 insertions(+), 10 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex a14d7a1..d34833f 100755\n--- a/gitk\n+++ b/gitk\n@@ -7627,9 +7627,10 @@ proc gettreeline {gtf id} {\n \t    if {$i < 0} continue\n \t    set fname [string range $line [expr {$i+1}] end]\n \t    set line [string range $line 0 [expr {$i-1}]]\n-\t    if {$diffids ne $nullid2 && [lindex $line 1] ne \"blob\"} continue\n+\t    set objtype [lindex $line 1]\n+\t    if {$diffids ne $nullid2 && $objtype ne \"blob\" && $objtype ne \"commit\" } { continue }\n \t    set sha1 [lindex $line 2]\n-\t    lappend treeidlist($id) $sha1\n+\t    lappend treeidlist($id) \"$sha1 $objtype\"\n \t}\n \tif {[string index $fname 0] eq \"\\\"\"} {\n \t    set fname [lindex $fname 0]\n@@ -7659,21 +7660,42 @@ proc showfile {f} {\n     global ctext_file_names ctext_file_lines\n     global ctext commentend\n \n+    set submodlog \"git\\\\ log\\\\ --format='%h\\\\ %aN:\\\\ %s'\\\\ -100\"\n+    set fcmt \"\"\n     set i [lsearch -exact $treefilelist($diffids) $f]\n     if {$i < 0} {\n \tputs \"oops, $f not in list for id $diffids\"\n \treturn\n     }\n     if {$diffids eq $nullid} {\n-\tif {[catch {set bf [open $f r]} err]} {\n-\t    puts \"oops, can't read $f: $err\"\n-\t    return\n+\tif {[file isdirectory $f]} {\n+\t    # a submodule\n+\t    if {[catch {set bf [open \"| sh -c cd\\\\ \\\"$f\\\"&&$submodlog\" r]} err]} {\n+\t\tputs \"oops, can't read submodule $f: $err\"\n+\t\treturn\n+\t    }\n+        } else {\n+\t    if {[catch {set bf [open $f r]} err]} {\n+\t\tputs \"oops, can't read $f: $err\"\n+\t\treturn\n+\t    }\n \t}\n     } else {\n-\tset blob [lindex $treeidlist($diffids) $i]\n-\tif {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {\n-\t    puts \"oops, error reading blob $blob: $err\"\n-\t    return\n+\tset bo [lindex $treeidlist($diffids) $i]\n+\tset blob [lindex $bo 0]\n+\tset objtype [lindex $bo 1]\n+\tif { \"$objtype\" eq \"blob\" } {\n+\t    if {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {\n+\t\tputs \"oops, error reading blob $blob: $err\"\n+\t\treturn\n+\t    }\n+\t} else {\n+\t    # also a submodule\n+\t    if {[catch {set bf [open \"| sh -c cd\\\\ \\\"$f\\\"&&$submodlog\\\\ $blob\" r]} err]} {\n+\t\tputs \"oops, error reading submodule commit: $err\"\n+\t\treturn\n+\t    }\n+\t    set fcmt \"/\"\n \t}\n     }\n     fconfigure $bf -blocking 0 -encoding [get_path_encoding $f]\n@@ -7683,7 +7705,7 @@ proc showfile {f} {\n     lappend ctext_file_names $f\n     lappend ctext_file_lines [lindex [split $commentend \".\"] 0]\n     $ctext insert end \"\\n\"\n-    $ctext insert end \"$f\\n\" filesep\n+    $ctext insert end \"$f$fcmt\\n\" filesep\n     $ctext config -state disabled\n     $ctext yview $commentend\n     settabs 0\n-- \n2.17.0.rc1.56.gb9824190bd\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"346978","messageId":"20180508122256.nyv6ddcoifygfpk4@pflmari","threadId":"48431","inReplyTo":"20180508121104.rtsrektxiihvpqtx@pflmari","subject":"[PATCH 2/2] gitk: add an option to run gitk on an item in the file list","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-08T12:22:56Z","receivedAt":"2018-05-08T12:23:24Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nSimilar to a git gui feature which visualizes history in a submodule,\nthe submodules cause the gitk be started inside the submodule.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n gitk | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/gitk b/gitk\nindex d34833f..1ec545e 100755\n--- a/gitk\n+++ b/gitk\n@@ -2682,6 +2682,7 @@ proc makewindow {} {\n \t{mc \"External diff\" command {external_diff}}\n \t{mc \"Blame parent commit\" command {external_blame 1}}\n \t{mc \"Copy path\" command {clipboard clear; clipboard append $flist_menu_file}}\n+\t{mc \"Run gitk on this\" command {flist_gitk}}\n     }\n     $flist_menu configure -tearoff 0\n \n@@ -3555,6 +3556,17 @@ proc flist_hl {only} {\n     set gdttype [mc \"touching paths:\"]\n }\n \n+proc flist_gitk {} {\n+    global flist_menu_file findstring gdttype\n+\n+    set x [shellquote $flist_menu_file]\n+    if {[file isdirectory $flist_menu_file]} {\n+\texec sh -c \"cd $x&&gitk\" &\n+    } else {\n+\texec gitk -- $x &\n+    }\n+}\n+\n proc gitknewtmpdir {} {\n     global diffnum gitktmpdir gitdir env\n \n-- \n2.17.0.rc1.56.gb9824190bd\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"346980","messageId":"CAKPyHN3YMU3oZaW-wR2ZMV6aMwoeFGMmiJBQXtvipVvkWPLZVQ@mail.gmail.com","threadId":"48431","inReplyTo":"20180508122256.nyv6ddcoifygfpk4@pflmari","subject":"Re: [PATCH 2/2] gitk: add an option to run gitk on an item in the file list","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2018-05-08T13:17:03Z","receivedAt":"2018-05-08T13:17:07Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Tue, May 8, 2018 at 2:22 PM, Alex Riesen\n<alexander.riesen@cetitec.com> wrote:\n> From: Alex Riesen <raa.lkml@gmail.com>\n>\n> Similar to a git gui feature which visualizes history in a submodule,\n> the submodules cause the gitk be started inside the submodule.\n>\n> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>\n> ---\n>  gitk | 12 ++++++++++++\n>  1 file changed, 12 insertions(+)\n>\n> diff --git a/gitk b/gitk\n> index d34833f..1ec545e 100755\n> --- a/gitk\n> +++ b/gitk\n> @@ -2682,6 +2682,7 @@ proc makewindow {} {\n>         {mc \"External diff\" command {external_diff}}\n>         {mc \"Blame parent commit\" command {external_blame 1}}\n>         {mc \"Copy path\" command {clipboard clear; clipboard append $flist_menu_file}}\n> +       {mc \"Run gitk on this\" command {flist_gitk}}\n>      }\n>      $flist_menu configure -tearoff 0\n>\n> @@ -3555,6 +3556,17 @@ proc flist_hl {only} {\n>      set gdttype [mc \"touching paths:\"]\n>  }\n>\n> +proc flist_gitk {} {\n> +    global flist_menu_file findstring gdttype\n> +\n> +    set x [shellquote $flist_menu_file]\n\nthis needs to handle cdup, i.e., if gitk is run from a subdirectory,\nall paths needs to be prefixed with $cdup, like: [file join $cdup\n$flist_menu_file]\n\nBert\n\n> +    if {[file isdirectory $flist_menu_file]} {\n> +       exec sh -c \"cd $x&&gitk\" &\n> +    } else {\n> +       exec gitk -- $x &\n> +    }\n> +}\n> +\n>  proc gitknewtmpdir {} {\n>      global diffnum gitktmpdir gitdir env\n>\n"},{"id":"346982","messageId":"20180508133905.6jhhhp6l7avjkctl@pflmari","threadId":"48431","inReplyTo":"CAKPyHN3YMU3oZaW-wR2ZMV6aMwoeFGMmiJBQXtvipVvkWPLZVQ@mail.gmail.com","subject":"Re: [PATCH 2/2] gitk: add an option to run gitk on an item in the file list","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-08T13:39:05Z","receivedAt":"2018-05-08T13:39:37Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"Bert Wesarg, Tue, May 08, 2018 15:17:03 +0200:\n> On Tue, May 8, 2018 at 2:22 PM, Alex Riesen <alexander.riesen@cetitec.com> wrote:\n> > +proc flist_gitk {} {\n> > +    global flist_menu_file findstring gdttype\n> > +\n> > +    set x [shellquote $flist_menu_file]\n> \n> this needs to handle cdup, i.e., if gitk is run from a subdirectory,\n> all paths needs to be prefixed with $cdup, like: [file join $cdup\n> $flist_menu_file]\n\nThat, indeed, is easily done:\n\n    set x [shellquote [file join $cdup $flist_menu_file]]\n    if {[file isdirectory $flist_menu_file]} {\n\texec sh -c \"cd $x&&gitk\" &\n    } else {\n\texec gitk -- $x &\n    }\n\n\nIt just doesn't seem to work: gitk does not find any commits!\nMaybe that's because the file panel lists only files for the current\nsubdirectory (without the path from the repo top-level)? E.g.\n\n    mkdir tst\n    cd tst\n    git init\n    mkdir a\n    touch top-file a/sub-file\n    git add -A ; git commit -m.\n    cd a\n    gitk\n\nGitk lists only sub-file.\n\nFrankly, this listing limited to just a sub-directory confuses me a bit. Is\nthere anyway to get to display full repository without changing to the top\nlevel?\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"346995","messageId":"CAGZ79kYxZ43kJwS_odhNwCO2e_n-8JLNynAZj0+Hp3ugzYbqUg@mail.gmail.com","threadId":"48431","inReplyTo":"20180508122229.k3n3ccpa5g3g4dxa@pflmari","subject":"Re: [PATCH 1/2] gitk: show part of submodule log instead of empty pane when listing trees","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-08T17:07:29Z","receivedAt":"2018-05-08T17:07:34Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 8, 2018 at 5:22 AM, Alex Riesen\n<alexander.riesen@cetitec.com> wrote:\n> From: Alex Riesen <raa.lkml@gmail.com>\n>\n> Currently, the submodules either are not shown at all (if listing a\n> committed tree) or a Tcl error appears (when clicking on a submodule\n> from the index list).\n\nI do not understand where this appears, yet.\nWhere do I have to click to see the effects of this patch?\n\n>\n> This will make it show first arbitrarily chosen number of commits,\n> which might be only marginally better.\n>\n> Signed-off-by: Alex Riesen <raa.lkml@gmail.com>\n> ---\n>  gitk | 42 ++++++++++++++++++++++++++++++++----------\n>  1 file changed, 32 insertions(+), 10 deletions(-)\n>\n> diff --git a/gitk b/gitk\n> index a14d7a1..d34833f 100755\n> --- a/gitk\n> +++ b/gitk\n> @@ -7627,9 +7627,10 @@ proc gettreeline {gtf id} {\n>             if {$i < 0} continue\n>             set fname [string range $line [expr {$i+1}] end]\n>             set line [string range $line 0 [expr {$i-1}]]\n> -           if {$diffids ne $nullid2 && [lindex $line 1] ne \"blob\"} continue\n> +           set objtype [lindex $line 1]\n> +           if {$diffids ne $nullid2 && $objtype ne \"blob\" && $objtype ne \"commit\" } { continue }\n>             set sha1 [lindex $line 2]\n> -           lappend treeidlist($id) $sha1\n> +           lappend treeidlist($id) \"$sha1 $objtype\"\n>         }\n>         if {[string index $fname 0] eq \"\\\"\"} {\n>             set fname [lindex $fname 0]\n> @@ -7659,21 +7660,42 @@ proc showfile {f} {\n>      global ctext_file_names ctext_file_lines\n>      global ctext commentend\n>\n> +    set submodlog \"git\\\\ log\\\\ --format='%h\\\\ %aN:\\\\ %s'\\\\ -100\"\n\nDo we want to respect the config option diff.submodule here?\nThe -100 is chosen rather arbitrarily. Ideally we'd only walk to the\nprevious entry?\n\n> +    set fcmt \"\"\n>      set i [lsearch -exact $treefilelist($diffids) $f]\n>      if {$i < 0} {\n>         puts \"oops, $f not in list for id $diffids\"\n>         return\n>      }\n>      if {$diffids eq $nullid} {\n> -       if {[catch {set bf [open $f r]} err]} {\n> -           puts \"oops, can't read $f: $err\"\n> -           return\n> +       if {[file isdirectory $f]} {\n> +           # a submodule\n> +           if {[catch {set bf [open \"| sh -c cd\\\\ \\\"$f\\\"&&$submodlog\" r]} err]} {\n\nCan we have $submodlog use the \"git -C <path> command\"\noption, then we could save the \"cd &&\" part, which might even\nsave us from spawning a shell?\n\nThanks,\nStefan\n"},{"id":"347055","messageId":"CAKPyHN1bGtCBZUh7cDAN-t+5DTutvyL6FLwynALTGZA5ijqwrA@mail.gmail.com","threadId":"48431","inReplyTo":"20180508133905.6jhhhp6l7avjkctl@pflmari","subject":"Re: [PATCH 2/2] gitk: add an option to run gitk on an item in the file list","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2018-05-09T07:19:55Z","receivedAt":"2018-05-09T07:19:59Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"On Tue, May 8, 2018 at 3:39 PM, Alex Riesen\n<alexander.riesen@cetitec.com> wrote:\n> Bert Wesarg, Tue, May 08, 2018 15:17:03 +0200:\n>> On Tue, May 8, 2018 at 2:22 PM, Alex Riesen <alexander.riesen@cetitec.com> wrote:\n>> > +proc flist_gitk {} {\n>> > +    global flist_menu_file findstring gdttype\n>> > +\n>> > +    set x [shellquote $flist_menu_file]\n>>\n>> this needs to handle cdup, i.e., if gitk is run from a subdirectory,\n>> all paths needs to be prefixed with $cdup, like: [file join $cdup\n>> $flist_menu_file]\n>\n> That, indeed, is easily done:\n>\n>     set x [shellquote [file join $cdup $flist_menu_file]]\n>     if {[file isdirectory $flist_menu_file]} {\n>         exec sh -c \"cd $x&&gitk\" &\n>     } else {\n>         exec gitk -- $x &\n>     }\n>\n>\n> It just doesn't seem to work: gitk does not find any commits!\n> Maybe that's because the file panel lists only files for the current\n> subdirectory (without the path from the repo top-level)? E.g.\n>\n>     mkdir tst\n>     cd tst\n>     git init\n>     mkdir a\n>     touch top-file a/sub-file\n>     git add -A ; git commit -m.\n>     cd a\n>     gitk\n>\n> Gitk lists only sub-file.\n>\n> Frankly, this listing limited to just a sub-directory confuses me a bit. Is\n> there anyway to get to display full repository without changing to the top\n> level?\n\nI noticed that too, while testing your patch and I'm also confused.\nBut was not able to send a request to Paul yet. ls-tree --full-tree\nseems to be one that should be used here, I think.\n\nBert\n"},{"id":"347059","messageId":"20180509090134.ozikiizgltfiusp5@pflmari","threadId":"48431","inReplyTo":"CAGZ79kYxZ43kJwS_odhNwCO2e_n-8JLNynAZj0+Hp3ugzYbqUg@mail.gmail.com","subject":"Re: [PATCH 1/2] gitk: show part of submodule log instead of empty pane when listing trees","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-09T09:01:34Z","receivedAt":"2018-05-09T09:02:14Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"Stefan Beller, Tue, May 08, 2018 19:07:29 +0200:\n> On Tue, May 8, 2018 at 5:22 AM, Alex Riesen\n> <alexander.riesen@cetitec.com> wrote:\n> > Currently, the submodules either are not shown at all (if listing a\n> > committed tree) or a Tcl error appears (when clicking on a submodule\n> > from the index list).\n> \n> I do not understand where this appears, yet.\n> Where do I have to click to see the effects of this patch?\n\nEr. I meant to say the file list panel (bottom right panel). Sorry,\ndidn't come out clear. I'll reword the commit message next time.\n\n> > @@ -7659,21 +7660,42 @@ proc showfile {f} {\n> >      global ctext_file_names ctext_file_lines\n> >      global ctext commentend\n> >\n> > +    set submodlog \"git\\\\ log\\\\ --format='%h\\\\ %aN:\\\\ %s'\\\\ -100\"\n> \n> Do we want to respect the config option diff.submodule here?\n\nProbably not. It is already done when the file list panel is in \"Patch\" mode.\nThe \"Tree\" mode of the panel shows the files in full, so the submodules should\nbe shown similarly: in a format resembling their full (referenced) contents.\n\n> The -100 is chosen rather arbitrarily. Ideally we'd only walk to the\n> previous entry?\n\nYes, the limit is indeed arbitrary. I'm reluctant of listing full history,\nthough: it might take too long a while (and does, in my line of work). Maybe\nan option in the settings? Or some kind of a more natural limit (for 1 second?\nUntil the end of panel?)\n\n> > -       if {[catch {set bf [open $f r]} err]} {\n> > -           puts \"oops, can't read $f: $err\"\n> > -           return\n> > +       if {[file isdirectory $f]} {\n> > +           # a submodule\n> > +           if {[catch {set bf [open \"| sh -c cd\\\\ \\\"$f\\\"&&$submodlog\" r]} err]} {\n> \n> Can we have $submodlog use the \"git -C <path> command\"\n> option, then we could save the \"cd &&\" part, which might even\n> save us from spawning a shell?\n\nThat's because I forgot about that option. Of course, I'll fix this.\nAlso need a shellquote for the path.\n\nThanks!\nAlex\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"347063","messageId":"56ccabf699cdc6e15c5dcb73db5692180c79906d.1525863290.git.raa.lkml@gmail.com","threadId":"48431","inReplyTo":"CAKPyHN1bGtCBZUh7cDAN-t+5DTutvyL6FLwynALTGZA5ijqwrA@mail.gmail.com","subject":"[PATCH] gitk: do not limit tree mode listing in the file list panel to current sub-directory","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-09T10:59:30Z","receivedAt":"2018-05-09T11:00:00Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nThe previous behavior conflicts with the \"Patch\" mode of the panel,\nwhich always shows the changes from the top-level of the repository.\nIt is also impossible to get back to the full listing without restarting\ngitk.\n---\n\nBert Wesarg, Wed, May 09, 2018 09:19:55 +0200:\n> > Frankly, this listing limited to just a sub-directory confuses me a bit. Is\n> > there anyway to get to display full repository without changing to the top\n> > level?\n> \n> I noticed that too, while testing your patch and I'm also confused.\n> But was not able to send a request to Paul yet. ls-tree --full-tree\n> seems to be one that should be used here, I think.\n\nWell, I just tried your suggestion. 'ls-files' doesn't have --full-tree, so\nfor those it is just cd-up.\n\nIt is on top of the re-sent series.\n\n gitk | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex c430dfe..03ead98 100755\n--- a/gitk\n+++ b/gitk\n@@ -7600,18 +7600,18 @@ proc go_to_parent {i} {\n \n proc gettree {id} {\n     global treefilelist treeidlist diffids diffmergeid treepending\n-    global nullid nullid2\n+    global nullid nullid2 cdup\n \n     set diffids $id\n     unset -nocomplain diffmergeid\n     if {![info exists treefilelist($id)]} {\n \tif {![info exists treepending]} {\n \t    if {$id eq $nullid} {\n-\t\tset cmd [list | git ls-files]\n+\t\tset cmd [list | git -C $cdup ls-files]\n \t    } elseif {$id eq $nullid2} {\n-\t\tset cmd [list | git ls-files --stage -t]\n+\t\tset cmd [list | git -C $cdup ls-files --stage -t]\n \t    } else {\n-\t\tset cmd [list | git ls-tree -r $id]\n+\t\tset cmd [list | git ls-tree --full-tree -r $id]\n \t    }\n \t    if {[catch {set gtf [open $cmd r]}]} {\n \t\treturn\n@@ -7670,7 +7670,7 @@ proc gettreeline {gtf id} {\n proc showfile {f} {\n     global treefilelist treeidlist diffids nullid nullid2\n     global ctext_file_names ctext_file_lines\n-    global ctext commentend\n+    global ctext commentend cdup\n \n     set submodlog \"log --format=%h\\\\ %aN:\\\\ %s -100\"\n     set fcmt \"\"\n@@ -7680,15 +7680,15 @@ proc showfile {f} {\n \treturn\n     }\n     if {$diffids eq $nullid} {\n-\tif {[file isdirectory $f]} {\n+\tif {[file isdirectory \"$cdup$f\"]} {\n \t    # a submodule\n-\t    set qf [shellquote $f]\n+\t    set qf [shellquote \"$cdup$f\"]\n \t    if {[catch {set bf [open \"| git -C $qf $submodlog\" r]} err]} {\n \t\tputs \"oops, can't read submodule $f: $err\"\n \t\treturn\n \t    }\n         } else {\n-\t    if {[catch {set bf [open $f r]} err]} {\n+\t    if {[catch {set bf [open \"$cdup$f\" r]} err]} {\n \t\tputs \"oops, can't read $f: $err\"\n \t\treturn\n \t    }\n@@ -7704,7 +7704,7 @@ proc showfile {f} {\n \t    }\n \t} else {\n \t    # also a submodule\n-\t    set qf [shellquote $f]\n+\t    set qf [shellquote \"$cdup$f\"]\n \t    if {[catch {set bf [open \"| git -C $qf $submodlog $blob\" r]} err]} {\n \t\tputs \"oops, error reading submodule commit: $err\"\n \t\treturn\n-- \n2.17.0.593.g2029711e64\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"347069","messageId":"CAKPyHN0iQh=UJOX-8u4PO1ON9SW+G1gBCGh25FJ_RyoGk906QQ@mail.gmail.com","threadId":"48431","inReplyTo":"56ccabf699cdc6e15c5dcb73db5692180c79906d.1525863290.git.raa.lkml@gmail.com","subject":"Re: [PATCH] gitk: do not limit tree mode listing in the file list panel to current sub-directory","fromName":"Bert Wesarg","fromEmail":"bert.wesarg@googlemail.com","sentAt":"2018-05-09T12:08:51Z","receivedAt":"2018-05-09T12:08:57Z","isPatch":true,"sender":{"key":"bert.wesarg@googlemail.com","avatar":"https://avatars.githubusercontent.com/u/111934?v=4"},"body":"Thanks.\n\nOn Wed, May 9, 2018 at 12:59 PM, Alex Riesen\n<alexander.riesen@cetitec.com> wrote:\n> From: Alex Riesen <raa.lkml@gmail.com>\n>\n> The previous behavior conflicts with the \"Patch\" mode of the panel,\n> which always shows the changes from the top-level of the repository.\n> It is also impossible to get back to the full listing without restarting\n> gitk.\n> ---\n>\n> Bert Wesarg, Wed, May 09, 2018 09:19:55 +0200:\n>> > Frankly, this listing limited to just a sub-directory confuses me a bit. Is\n>> > there anyway to get to display full repository without changing to the top\n>> > level?\n>>\n>> I noticed that too, while testing your patch and I'm also confused.\n>> But was not able to send a request to Paul yet. ls-tree --full-tree\n>> seems to be one that should be used here, I think.\n>\n> Well, I just tried your suggestion. 'ls-files' doesn't have --full-tree, so\n> for those it is just cd-up.\n>\n> It is on top of the re-sent series.\n\nI would consider the current behavior as a bug, therefor I would put\nthis patch first, and than your other fixes/enhancements.\n\n>\n>  gitk | 18 +++++++++---------\n>  1 file changed, 9 insertions(+), 9 deletions(-)\n>\n> diff --git a/gitk b/gitk\n> index c430dfe..03ead98 100755\n> --- a/gitk\n> +++ b/gitk\n> @@ -7600,18 +7600,18 @@ proc go_to_parent {i} {\n>\n>  proc gettree {id} {\n>      global treefilelist treeidlist diffids diffmergeid treepending\n> -    global nullid nullid2\n> +    global nullid nullid2 cdup\n>\n>      set diffids $id\n>      unset -nocomplain diffmergeid\n>      if {![info exists treefilelist($id)]} {\n>         if {![info exists treepending]} {\n>             if {$id eq $nullid} {\n> -               set cmd [list | git ls-files]\n> +               set cmd [list | git -C $cdup ls-files]\n>             } elseif {$id eq $nullid2} {\n> -               set cmd [list | git ls-files --stage -t]\n> +               set cmd [list | git -C $cdup ls-files --stage -t]\n>             } else {\n> -               set cmd [list | git ls-tree -r $id]\n> +               set cmd [list | git ls-tree --full-tree -r $id]\n>             }\n>             if {[catch {set gtf [open $cmd r]}]} {\n>                 return\n> @@ -7670,7 +7670,7 @@ proc gettreeline {gtf id} {\n>  proc showfile {f} {\n>      global treefilelist treeidlist diffids nullid nullid2\n>      global ctext_file_names ctext_file_lines\n> -    global ctext commentend\n> +    global ctext commentend cdup\n>\n>      set submodlog \"log --format=%h\\\\ %aN:\\\\ %s -100\"\n>      set fcmt \"\"\n> @@ -7680,15 +7680,15 @@ proc showfile {f} {\n>         return\n>      }\n>      if {$diffids eq $nullid} {\n> -       if {[file isdirectory $f]} {\n> +       if {[file isdirectory \"$cdup$f\"]} {\n>             # a submodule\n> -           set qf [shellquote $f]\n> +           set qf [shellquote \"$cdup$f\"]\n>             if {[catch {set bf [open \"| git -C $qf $submodlog\" r]} err]} {\n>                 puts \"oops, can't read submodule $f: $err\"\n>                 return\n>             }\n>          } else {\n> -           if {[catch {set bf [open $f r]} err]} {\n> +           if {[catch {set bf [open \"$cdup$f\" r]} err]} {\n>                 puts \"oops, can't read $f: $err\"\n>                 return\n>             }\n> @@ -7704,7 +7704,7 @@ proc showfile {f} {\n>             }\n>         } else {\n>             # also a submodule\n> -           set qf [shellquote $f]\n> +           set qf [shellquote \"$cdup$f\"]\n>             if {[catch {set bf [open \"| git -C $qf $submodlog $blob\" r]} err]} {\n>                 puts \"oops, error reading submodule commit: $err\"\n>                 return\n> --\n> 2.17.0.593.g2029711e64\n>\n>\n> ---\n> Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\n> https://www.avast.com/antivirus\n>\n"},{"id":"347071","messageId":"20180509121454.v4y4av3sk7nh4hnn@pflmari","threadId":"48431","inReplyTo":"CAKPyHN0iQh=UJOX-8u4PO1ON9SW+G1gBCGh25FJ_RyoGk906QQ@mail.gmail.com","subject":"Re: [PATCH] gitk: do not limit tree mode listing in the file list panel to current sub-directory","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-09T12:14:54Z","receivedAt":"2018-05-09T12:15:22Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"Bert Wesarg, Wed, May 09, 2018 14:08:51 +0200:\n> >> I noticed that too, while testing your patch and I'm also confused.\n> >> But was not able to send a request to Paul yet. ls-tree --full-tree\n> >> seems to be one that should be used here, I think.\n> >\n> > Well, I just tried your suggestion. 'ls-files' doesn't have --full-tree, so\n> > for those it is just cd-up.\n> >\n> > It is on top of the re-sent series.\n> \n> I would consider the current behavior as a bug, therefor I would put\n> this patch first, and than your other fixes/enhancements.\n\nI might do, just want to hear more opinions on the matter: someone might have\ngood reasons for the current behaviour and consider a bug the fact that Patch\nmode behaves differently, for instance.\n\nAnd as I completely screwed up the resend of the series, there will definitely\nbe a re-resend.\n\nRegards,\nAlex\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"347072","messageId":"cover.1525868167.git.raa.lkml@gmail.com","threadId":"48431","inReplyTo":"20180508121104.rtsrektxiihvpqtx@pflmari","subject":"[PATCH v2 0/2] gitk: improve handling of submodules in the file list panel","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-09T12:35:24Z","receivedAt":"2018-05-09T12:35:59Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nCurrently, the submodule entries in the file list panel are mostly ignored.\nThis series attempts to improve the situation by showing part of submodule\nhistory when focusing it in the file list panel and by adding a menu element\nto start gitk in the submodule (similar to git gui).\n\nThis iteration does not address the behaviour of file list panel in tree mode\nwhen gitk is started from a subdirectory (gitk strictly limits the file\nlisting to the files in that repository, without a way out).\nI would like to hear some more opinions regarding changing its behaviour to\nalways list the full tree.\n\nAlex Riesen (2):\n  gitk: show part of submodule log instead of empty pane when listing\n    trees\n  gitk: add an option to run gitk on an item in the file list\n\n gitk | 56 ++++++++++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 46 insertions(+), 10 deletions(-)\n\n-- \n2.17.0.593.g2029711e64\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"347073","messageId":"d3c1aad3b1152de9526d89d4c74042ff7b34a317.1525868167.git.raa.lkml@gmail.com","threadId":"48431","inReplyTo":"cover.1525868167.git.raa.lkml@gmail.com","subject":"[PATCH v2 2/2] gitk: add an option to run gitk on an item in the file list","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-09T12:35:26Z","receivedAt":"2018-05-09T12:36:01Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nSimilar to a git gui feature which visualizes history in a submodule,\nthe submodules cause the gitk be started inside the submodule.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n gitk | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/gitk b/gitk\nindex 742f36b..c430dfe 100755\n--- a/gitk\n+++ b/gitk\n@@ -2682,6 +2682,7 @@ proc makewindow {} {\n \t{mc \"External diff\" command {external_diff}}\n \t{mc \"Blame parent commit\" command {external_blame 1}}\n \t{mc \"Copy path\" command {clipboard clear; clipboard append $flist_menu_file}}\n+\t{mc \"Run gitk on this\" command {flist_gitk}}\n     }\n     $flist_menu configure -tearoff 0\n \n@@ -3555,6 +3556,17 @@ proc flist_hl {only} {\n     set gdttype [mc \"touching paths:\"]\n }\n \n+proc flist_gitk {} {\n+    global flist_menu_file findstring gdttype\n+\n+    set x [shellquote $flist_menu_file]\n+    if {[file isdirectory $flist_menu_file]} {\n+\texec sh -c \"cd $x&&gitk\" &\n+    } else {\n+\texec gitk -- $x &\n+    }\n+}\n+\n proc gitknewtmpdir {} {\n     global diffnum gitktmpdir gitdir env\n \n-- \n2.17.0.593.g2029711e64\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"347074","messageId":"bf7dfd9a48578d05dd91c0936ed55a88dd7d93d3.1525868167.git.raa.lkml@gmail.com","threadId":"48431","inReplyTo":"cover.1525868167.git.raa.lkml@gmail.com","subject":"[PATCH v2 1/2] gitk: show part of submodule log instead of empty pane when listing trees","fromName":"Alex Riesen","fromEmail":"alexander.riesen@cetitec.com","sentAt":"2018-05-09T12:35:25Z","receivedAt":"2018-05-09T12:36:05Z","isPatch":true,"sender":{"key":"alexander.riesen@cetitec.com","avatar":"https://avatars.githubusercontent.com/u/24452597?v=4"},"body":"From: Alex Riesen <raa.lkml@gmail.com>\n\nCurrently, selecting a name in the file list (bottom right) panel in\n\"Tree\" mode does not do anything useful if the name is a submodule.\nIf gitk is currently showing a commit, the submodule names are not shown\nat all (which is very confusing). If the gitk is showing the uncached\nchange, the submodules are shown, but focusing a submodule name causes a\nTcl error to appear. And finally, if gitk shows the index, the submodule\nis presented as its bare name in the diff/file contents panel.\n\nThis change will show the first arbitrarily chosen number of commits.\n\nSigned-off-by: Alex Riesen <raa.lkml@gmail.com>\n---\n gitk | 44 ++++++++++++++++++++++++++++++++++----------\n 1 file changed, 34 insertions(+), 10 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex a14d7a1..742f36b 100755\n--- a/gitk\n+++ b/gitk\n@@ -7627,9 +7627,10 @@ proc gettreeline {gtf id} {\n \t    if {$i < 0} continue\n \t    set fname [string range $line [expr {$i+1}] end]\n \t    set line [string range $line 0 [expr {$i-1}]]\n-\t    if {$diffids ne $nullid2 && [lindex $line 1] ne \"blob\"} continue\n+\t    set objtype [lindex $line 1]\n+\t    if {$diffids ne $nullid2 && $objtype ne \"blob\" && $objtype ne \"commit\" } { continue }\n \t    set sha1 [lindex $line 2]\n-\t    lappend treeidlist($id) $sha1\n+\t    lappend treeidlist($id) \"$sha1 $objtype\"\n \t}\n \tif {[string index $fname 0] eq \"\\\"\"} {\n \t    set fname [lindex $fname 0]\n@@ -7659,21 +7660,44 @@ proc showfile {f} {\n     global ctext_file_names ctext_file_lines\n     global ctext commentend\n \n+    set submodlog \"log --format=%h\\\\ %aN:\\\\ %s -100\"\n+    set fcmt \"\"\n     set i [lsearch -exact $treefilelist($diffids) $f]\n     if {$i < 0} {\n \tputs \"oops, $f not in list for id $diffids\"\n \treturn\n     }\n     if {$diffids eq $nullid} {\n-\tif {[catch {set bf [open $f r]} err]} {\n-\t    puts \"oops, can't read $f: $err\"\n-\t    return\n+\tif {[file isdirectory $f]} {\n+\t    # a submodule\n+\t    set qf [shellquote $f]\n+\t    if {[catch {set bf [open \"| git -C $qf $submodlog\" r]} err]} {\n+\t\tputs \"oops, can't read submodule $f: $err\"\n+\t\treturn\n+\t    }\n+        } else {\n+\t    if {[catch {set bf [open $f r]} err]} {\n+\t\tputs \"oops, can't read $f: $err\"\n+\t\treturn\n+\t    }\n \t}\n     } else {\n-\tset blob [lindex $treeidlist($diffids) $i]\n-\tif {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {\n-\t    puts \"oops, error reading blob $blob: $err\"\n-\t    return\n+\tset bo [lindex $treeidlist($diffids) $i]\n+\tset blob [lindex $bo 0]\n+\tset objtype [lindex $bo 1]\n+\tif { \"$objtype\" eq \"blob\" } {\n+\t    if {[catch {set bf [open [concat | git cat-file blob $blob] r]} err]} {\n+\t\tputs \"oops, error reading blob $blob: $err\"\n+\t\treturn\n+\t    }\n+\t} else {\n+\t    # also a submodule\n+\t    set qf [shellquote $f]\n+\t    if {[catch {set bf [open \"| git -C $qf $submodlog $blob\" r]} err]} {\n+\t\tputs \"oops, error reading submodule commit: $err\"\n+\t\treturn\n+\t    }\n+\t    set fcmt \"/\"\n \t}\n     }\n     fconfigure $bf -blocking 0 -encoding [get_path_encoding $f]\n@@ -7683,7 +7707,7 @@ proc showfile {f} {\n     lappend ctext_file_names $f\n     lappend ctext_file_lines [lindex [split $commentend \".\"] 0]\n     $ctext insert end \"\\n\"\n-    $ctext insert end \"$f\\n\" filesep\n+    $ctext insert end \"$f$fcmt\\n\" filesep\n     $ctext config -state disabled\n     $ctext yview $commentend\n     settabs 0\n-- \n2.17.0.593.g2029711e64\n\n\n---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"},{"id":"347123","messageId":"CAGZ79kaqp2sOU76+uQOvzvh_ojJf1O2YqmnmAU2UM-Jm+ZFQ8Q@mail.gmail.com","threadId":"48431","inReplyTo":"cover.1525868167.git.raa.lkml@gmail.com","subject":"Re: [PATCH v2 0/2] gitk: improve handling of submodules in the file list panel","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-09T18:52:30Z","receivedAt":"2018-05-09T18:52:35Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, May 9, 2018 at 5:35 AM, Alex Riesen\n<alexander.riesen@cetitec.com> wrote:\n> From: Alex Riesen <raa.lkml@gmail.com>\n>\n> Currently, the submodule entries in the file list panel are mostly ignored.\n> This series attempts to improve the situation by showing part of submodule\n> history when focusing it in the file list panel and by adding a menu element\n> to start gitk in the submodule (similar to git gui).\n>\n> This iteration does not address the behaviour of file list panel in tree mode\n> when gitk is started from a subdirectory (gitk strictly limits the file\n> listing to the files in that repository, without a way out).\n> I would like to hear some more opinions regarding changing its behaviour to\n> always list the full tree.\n>\n> Alex Riesen (2):\n>   gitk: show part of submodule log instead of empty pane when listing\n>     trees\n>   gitk: add an option to run gitk on an item in the file list\n\nboth patches look ok, to my untrained eye.\n"}]}