From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Lehmann Subject: [PATCH] Teach gitk to display dirty submodules correctly Date: Fri, 26 Mar 2010 23:09:03 +0100 Message-ID: <4BAD307F.1090602@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: Git Mailing List To: Paul Mackerras X-From: git-owner@vger.kernel.org Fri Mar 26 23:11:02 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NvHk6-0001gf-2j for gcvg-git-2@lo.gmane.org; Fri, 26 Mar 2010 23:11:02 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754387Ab0CZWKy (ORCPT ); Fri, 26 Mar 2010 18:10:54 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:58210 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753849Ab0CZWKy (ORCPT ); Fri, 26 Mar 2010 18:10:54 -0400 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate01.web.de (Postfix) with ESMTP id BC04E151D49A8; Fri, 26 Mar 2010 23:09:07 +0100 (CET) Received: from [80.128.72.101] (helo=[192.168.178.26]) by smtp07.web.de with asmtp (WEB.DE 4.110 #4) id 1NvHiF-0000MF-00; Fri, 26 Mar 2010 23:09:07 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3 X-Sender: Jens.Lehmann@web.de X-Provags-ID: V01U2FsdGVkX1/p/sfMcLujxtlbjRyPK9AvuG8uwsYfIFZKMIlh 1mVIYyFlhafVQkf1RqUdtwtIinGv2gbosY0GgKsFbvj4GzRSHb e4OOoabg3hGbtWxDrKiQ== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: Since recently "git diff --submodule" prints out extra lines when the submodule contains untracked or modified files. Show all those lines of one submodule under the same header. Also for newly added or removed submodules the submodule name contained trailing garbage because the extraction of the name was not done right. Signed-off-by: Jens Lehmann --- No need to test for the version of the underlying git here, as the string "Submodule" does not appear in the diff output when older git versions are used and the changed code is not executed at all in this case (except for setting the new "currdiffsubmod" variable to the empty string, but that doesn't have any negative side effects). gitk-git/gitk | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index 1f36a3e..36a9dcf 100644 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -7501,7 +7501,7 @@ proc getblobdiffs {ids} { global ignorespace global limitdiffs vfilelimit curview global diffencoding targetline diffnparents - global git_version + global git_version currdiffsubmod set textconv {} if {[package vcompare $git_version "1.6.1"] >= 0} { @@ -7528,6 +7528,7 @@ proc getblobdiffs {ids} { set diffencoding [get_path_encoding {}] fconfigure $bdf -blocking 0 -encoding binary -eofchar {} set blobdifffd($ids) $bdf + set currdiffsubmod "" filerun $bdf [list getblobdiffline $bdf $diffids] } @@ -7598,7 +7599,7 @@ proc getblobdiffline {bdf ids} { global diffnexthead diffnextnote difffilestart global ctext_file_names ctext_file_lines global diffinhdr treediffs mergemax diffnparents - global diffencoding jump_to_here targetline diffline + global diffencoding jump_to_here targetline diffline currdiffsubmod set nr 0 $ctext conf -state normal @@ -7679,19 +7680,30 @@ proc getblobdiffline {bdf ids} { } elseif {![string compare -length 10 "Submodule " $line]} { # start of a new submodule - if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} { + if {[regexp -indices "\[0-9a-f\]+\\.\\." $line nameend]} { + set fname [string range $line 10 [expr [lindex $nameend 0] - 2]] + } else { + set fname [string range $line 10 [expr [string first "contains " $line] - 2]] + } + if {$currdiffsubmod != $fname} { $ctext insert end "\n"; # Add newline after commit message } set curdiffstart [$ctext index "end - 1c"] lappend ctext_file_names "" - set fname [string range $line 10 [expr [string last " " $line] - 1]] - lappend ctext_file_lines $fname - makediffhdr $fname $ids - $ctext insert end "\n$line\n" filesep + if {$currdiffsubmod != $fname} { + lappend ctext_file_lines $fname + makediffhdr $fname $ids + set currdiffsubmod $fname + $ctext insert end "\n$line\n" filesep + } else { + $ctext insert end "$line\n" filesep + } } elseif {![string compare -length 3 " >" $line]} { + set $currdiffsubmod "" set line [encoding convertfrom $diffencoding $line] $ctext insert end "$line\n" dresult } elseif {![string compare -length 3 " <" $line]} { + set $currdiffsubmod "" set line [encoding convertfrom $diffencoding $line] $ctext insert end "$line\n" d0 } elseif {$diffinhdr} { @@ -8527,7 +8539,7 @@ proc do_cmp_commits {a b} { } proc diffcommits {a b} { - global diffcontext diffids blobdifffd diffinhdr + global diffcontext diffids blobdifffd diffinhdr currdiffsubmod set tmpdir [gitknewtmpdir] set fna [file join $tmpdir "commit-[string range $a 0 7]"] @@ -8548,6 +8560,7 @@ proc diffcommits {a b} { set diffids [list commits $a $b] set blobdifffd($diffids) $fd set diffinhdr 0 + set currdiffsubmod "" filerun $fd [list getblobdiffline $fd $diffids] } -- 1.7.0.2.448.g45e29