@@ -2526,6 +2526,7 @@ proc savestuff {w} {
2526
2526
if {$stuffsaved } return
2527
2527
if {![winfo viewable .]} return
2528
2528
catch {
2529
+ if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
2529
2530
set f [open " ~/.gitk-new" w]
2530
2531
if {$::tcl_platform(platform) eq {windows}} {
2531
2532
file attributes " ~/.gitk-new" -hidden true
@@ -3167,6 +3168,28 @@ proc flist_hl {only} {
3167
3168
set gdttype [mc " touching paths:" ]
3168
3169
}
3169
3170
3171
+ proc gitknewtmpdir {} {
3172
+ global diffnum gitktmpdir gitdir
3173
+
3174
+ if {![info exists gitktmpdir]} {
3175
+ set gitktmpdir [file join [file dirname $gitdir ] \
3176
+ [format " .gitk-tmp.%s" [pid ]]]
3177
+ if {[catch {file mkdir $gitktmpdir } err]} {
3178
+ error_popup " [ mc " Error creating temporary directory %s:" $gitktmpdir ] $err "
3179
+ unset gitktmpdir
3180
+ return {}
3181
+ }
3182
+ set diffnum 0
3183
+ }
3184
+ incr diffnum
3185
+ set diffdir [file join $gitktmpdir $diffnum ]
3186
+ if {[catch {file mkdir $diffdir } err]} {
3187
+ error_popup " [ mc " Error creating temporary directory %s:" $diffdir ] $err "
3188
+ return {}
3189
+ }
3190
+ return $diffdir
3191
+ }
3192
+
3170
3193
proc save_file_from_commit {filename output what} {
3171
3194
global nullfile
3172
3195
@@ -3201,11 +3224,10 @@ proc external_diff_get_one_file {diffid filename diffdir} {
3201
3224
}
3202
3225
3203
3226
proc external_diff {} {
3204
- global gitktmpdir nullid nullid2
3227
+ global nullid nullid2
3205
3228
global flist_menu_file
3206
3229
global diffids
3207
- global diffnum
3208
- global gitdir extdifftool
3230
+ global extdifftool
3209
3231
3210
3232
if {[llength $diffids ] == 1} {
3211
3233
# no reference commit given
@@ -3227,22 +3249,8 @@ proc external_diff {} {
3227
3249
}
3228
3250
3229
3251
# make sure that several diffs wont collide
3230
- if {![info exists gitktmpdir]} {
3231
- set gitktmpdir [file join [file dirname $gitdir ] \
3232
- [format " .gitk-tmp.%s" [pid ]]]
3233
- if {[catch {file mkdir $gitktmpdir } err]} {
3234
- error_popup " [ mc " Error creating temporary directory %s:" $gitktmpdir ] $err "
3235
- unset gitktmpdir
3236
- return
3237
- }
3238
- set diffnum 0
3239
- }
3240
- incr diffnum
3241
- set diffdir [file join $gitktmpdir $diffnum ]
3242
- if {[catch {file mkdir $diffdir } err]} {
3243
- error_popup " [ mc " Error creating temporary directory %s:" $diffdir ] $err "
3244
- return
3245
- }
3252
+ set diffdir [gitknewtmpdir]
3253
+ if {$diffdir eq {}} return
3246
3254
3247
3255
# gather files to diff
3248
3256
set difffromfile [external_diff_get_one_file $diffidfrom $flist_menu_file $diffdir ]
@@ -7400,7 +7408,7 @@ proc getblobdiffline {bdf ids} {
7400
7408
$ctext conf -state normal
7401
7409
while {[incr nr] <= 1000 && [gets $bdf line] >= 0} {
7402
7410
if {$ids != $diffids || $bdf != $blobdifffd($ids) } {
7403
- close $bdf
7411
+ catch { close $bdf }
7404
7412
return 0
7405
7413
}
7406
7414
if {![string compare -length 5 " diff " $line ]} {
@@ -7552,7 +7560,7 @@ proc getblobdiffline {bdf ids} {
7552
7560
}
7553
7561
$ctext conf -state disabled
7554
7562
if {[eof $bdf ]} {
7555
- close $bdf
7563
+ catch { close $bdf }
7556
7564
return 0
7557
7565
}
7558
7566
return [expr {$nr >= 1000? 2: 1}]
@@ -8273,8 +8281,11 @@ proc do_cmp_commits {a b} {
8273
8281
appendshortlink $a [mc " Commit " ] " $heada \n "
8274
8282
appendshortlink $b [mc " differs from\n " ] \
8275
8283
" $headb \n "
8276
- $ctext insert end [mc " - stopping\n " ]
8277
- break
8284
+ $ctext insert end [mc " Diff of commits:\n\n " ]
8285
+ $ctext conf -state disabled
8286
+ update
8287
+ diffcommits $a $b
8288
+ return
8278
8289
}
8279
8290
}
8280
8291
if {$skipa } {
@@ -8300,6 +8311,31 @@ proc do_cmp_commits {a b} {
8300
8311
$ctext conf -state disabled
8301
8312
}
8302
8313
8314
+ proc diffcommits {a b} {
8315
+ global diffcontext diffids blobdifffd diffinhdr
8316
+
8317
+ set tmpdir [gitknewtmpdir]
8318
+ set fna [file join $tmpdir " commit-[ string range $a 0 7] " ]
8319
+ set fnb [file join $tmpdir " commit-[ string range $b 0 7] " ]
8320
+ if {[catch {
8321
+ exec git diff-tree -p --pretty $a >$fna
8322
+ exec git diff-tree -p --pretty $b >$fnb
8323
+ } err]} {
8324
+ error_popup [mc " Error writing commit to file: %s" $err ]
8325
+ return
8326
+ }
8327
+ if {[catch {
8328
+ set fd [open " | diff -U$diffcontext $fna $fnb " r]
8329
+ } err]} {
8330
+ error_popup [mc " Error diffing commits: %s" $err ]
8331
+ return
8332
+ }
8333
+ set diffids [list commits $a $b ]
8334
+ set blobdifffd($diffids ) $fd
8335
+ set diffinhdr 0
8336
+ filerun $fd [list getblobdiffline $fd $diffids ]
8337
+ }
8338
+
8303
8339
proc diffvssel {dirn} {
8304
8340
global rowmenuid selectedline
8305
8341
0 commit comments