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>
Jens Lehmann committed
Oct 28, 2009 at 12:40 UTC
5c838d23aa02476cfe91b0eea047b6d5857da770
1 file changed
+20
-1
gitk
+20
-1
@@ -7344,7 +7344,11 @@ proc getblobdiffs {ids} {
7344
if {[package vcompare $git_version "1.6.1"] >= 0} {
7345
set textconv "--textconv"
7346
}
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"]
7352
if {$ignorespace} {
7353
append cmd " -w"
7354
}
@@ -7482,6 +7486,21 @@ proc getblobdiffline {bdf ids} {
7486
set diffnparents [expr {[string length $ats] - 1}]
7487
set diffinhdr 0
7488
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
7504
} elseif {$diffinhdr} {
7505
if {![string compare -length 12 "rename from " $line]} {
7506
set fname [string range $line [expr 6 + [string first " from " $line] ] end]