Skip to content

Commit 5c838d2

Browse files
jlehmannpaulusmack
authored andcommitted
gitk: Use the --submodule option for displaying diffs when available
When displaying diffs in a submodule, this makes gitk display the headlines of the commits being diffed, instead of just showing not-quite-helpful SHA-1 pairs, if the underlying git installation supports this. That makes it much easier to evaluate the changes, as it eliminates the need to start a gitk inside the submodule and use the superprojects hashes there to find out what the commits are about. Since the --submodule option of git diff is new in git version 1.6.6, this only uses the --submodule option when a git version of 1.6.6 or higher is detected. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 90a7792 commit 5c838d2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

gitk

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7344,7 +7344,11 @@ proc getblobdiffs {ids} {
73447344
if {[package vcompare $git_version "1.6.1"] >= 0} {
73457345
set textconv "--textconv"
73467346
}
7347-
set cmd [diffcmd $ids "-p $textconv -C --cc --no-commit-id -U$diffcontext"]
7347+
set submodule {}
7348+
if {[package vcompare $git_version "1.6.6"] >= 0} {
7349+
set submodule "--submodule"
7350+
}
7351+
set cmd [diffcmd $ids "-p $textconv $submodule -C --cc --no-commit-id -U$diffcontext"]
73487352
if {$ignorespace} {
73497353
append cmd " -w"
73507354
}
@@ -7482,6 +7486,21 @@ proc getblobdiffline {bdf ids} {
74827486
set diffnparents [expr {[string length $ats] - 1}]
74837487
set diffinhdr 0
74847488

7489+
} elseif {![string compare -length 10 "Submodule " $line]} {
7490+
# start of a new submodule
7491+
if {[string compare [$ctext get "end - 4c" end] "\n \n\n"]} {
7492+
$ctext insert end "\n"; # Add newline after commit message
7493+
}
7494+
set curdiffstart [$ctext index "end - 1c"]
7495+
lappend ctext_file_names ""
7496+
set fname [string range $line 10 [expr [string last " " $line] - 1]]
7497+
lappend ctext_file_lines $fname
7498+
makediffhdr $fname $ids
7499+
$ctext insert end "\n$line\n" filesep
7500+
} elseif {![string compare -length 3 " >" $line]} {
7501+
$ctext insert end "$line\n" dresult
7502+
} elseif {![string compare -length 3 " <" $line]} {
7503+
$ctext insert end "$line\n" d0
74857504
} elseif {$diffinhdr} {
74867505
if {![string compare -length 12 "rename from " $line]} {
74877506
set fname [string range $line [expr 6 + [string first " from " $line] ] end]

0 commit comments

Comments
 (0)