{"thread":{"id":"48435","subject":"[PATCH v2 1/2] gitk: show part of submodule log instead of empty pane when listing trees","startedAt":"2018-05-09T11:01:12Z","lastAt":"2018-05-09T11:01:25Z","messageCount":2,"participants":["Alex Riesen"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"347065","messageId":"20180509110044.jnuzyz7ya4ehersr@pflmari","threadId":"48435","inReplyTo":"cover.1525862998.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-09T11:00:44Z","receivedAt":"2018-05-09T11:01:12Z","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---\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":"347066","messageId":"20180509110058.5gwmxmai4mohui65@pflmari","threadId":"48435","inReplyTo":"cover.1525862998.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-09T11:00:58Z","receivedAt":"2018-05-09T11:01:25Z","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---\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---\nDiese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.\nhttps://www.avast.com/antivirus\n\n"}]}