gitk: Display dirty submodules correctly

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 <Jens.Lehmann@web.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Jens Lehmann 2010-04-09 22:16:42 +02:00 committed by Paul Mackerras
parent e7d516b67b
commit a1d383c5ab

29
gitk
View File

@ -7509,7 +7509,7 @@ proc getblobdiffs {ids} {
global ignorespace global ignorespace
global limitdiffs vfilelimit curview global limitdiffs vfilelimit curview
global diffencoding targetline diffnparents global diffencoding targetline diffnparents
global git_version global git_version currdiffsubmod
set textconv {} set textconv {}
if {[package vcompare $git_version "1.6.1"] >= 0} { if {[package vcompare $git_version "1.6.1"] >= 0} {
@ -7536,6 +7536,7 @@ proc getblobdiffs {ids} {
set diffencoding [get_path_encoding {}] set diffencoding [get_path_encoding {}]
fconfigure $bdf -blocking 0 -encoding binary -eofchar {} fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
set blobdifffd($ids) $bdf set blobdifffd($ids) $bdf
set currdiffsubmod ""
filerun $bdf [list getblobdiffline $bdf $diffids] filerun $bdf [list getblobdiffline $bdf $diffids]
} }
@ -7606,7 +7607,7 @@ proc getblobdiffline {bdf ids} {
global diffnexthead diffnextnote difffilestart global diffnexthead diffnextnote difffilestart
global ctext_file_names ctext_file_lines global ctext_file_names ctext_file_lines
global diffinhdr treediffs mergemax diffnparents global diffinhdr treediffs mergemax diffnparents
global diffencoding jump_to_here targetline diffline global diffencoding jump_to_here targetline diffline currdiffsubmod
set nr 0 set nr 0
$ctext conf -state normal $ctext conf -state normal
@ -7687,19 +7688,30 @@ proc getblobdiffline {bdf ids} {
} elseif {![string compare -length 10 "Submodule " $line]} { } elseif {![string compare -length 10 "Submodule " $line]} {
# start of a new submodule # 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 $ctext insert end "\n"; # Add newline after commit message
} }
set curdiffstart [$ctext index "end - 1c"] set curdiffstart [$ctext index "end - 1c"]
lappend ctext_file_names "" lappend ctext_file_names ""
set fname [string range $line 10 [expr [string last " " $line] - 1]] if {$currdiffsubmod != $fname} {
lappend ctext_file_lines $fname lappend ctext_file_lines $fname
makediffhdr $fname $ids makediffhdr $fname $ids
$ctext insert end "\n$line\n" filesep set currdiffsubmod $fname
$ctext insert end "\n$line\n" filesep
} else {
$ctext insert end "$line\n" filesep
}
} elseif {![string compare -length 3 " >" $line]} { } elseif {![string compare -length 3 " >" $line]} {
set $currdiffsubmod ""
set line [encoding convertfrom $diffencoding $line] set line [encoding convertfrom $diffencoding $line]
$ctext insert end "$line\n" dresult $ctext insert end "$line\n" dresult
} elseif {![string compare -length 3 " <" $line]} { } elseif {![string compare -length 3 " <" $line]} {
set $currdiffsubmod ""
set line [encoding convertfrom $diffencoding $line] set line [encoding convertfrom $diffencoding $line]
$ctext insert end "$line\n" d0 $ctext insert end "$line\n" d0
} elseif {$diffinhdr} { } elseif {$diffinhdr} {
@ -8535,7 +8547,7 @@ proc do_cmp_commits {a b} {
} }
proc diffcommits {a b} { proc diffcommits {a b} {
global diffcontext diffids blobdifffd diffinhdr global diffcontext diffids blobdifffd diffinhdr currdiffsubmod
set tmpdir [gitknewtmpdir] set tmpdir [gitknewtmpdir]
set fna [file join $tmpdir "commit-[string range $a 0 7]"] set fna [file join $tmpdir "commit-[string range $a 0 7]"]
@ -8556,6 +8568,7 @@ proc diffcommits {a b} {
set diffids [list commits $a $b] set diffids [list commits $a $b]
set blobdifffd($diffids) $fd set blobdifffd($diffids) $fd
set diffinhdr 0 set diffinhdr 0
set currdiffsubmod ""
filerun $fd [list getblobdiffline $fd $diffids] filerun $fd [list getblobdiffline $fd $diffids]
} }