@@ -309,7 +309,7 @@ proc start_rev_list {view} {
309
309
global viewargs viewargscmd viewfiles vfilelimit
310
310
global showlocalchanges
311
311
global viewactive viewinstances vmergeonly
312
- global mainheadid
312
+ global mainheadid viewmainheadid viewmainheadid_orig
313
313
global vcanopt vflags vrevs vorigargs
314
314
315
315
set startmsecs [clock clicks -milliseconds]
@@ -367,8 +367,13 @@ proc start_rev_list {view} {
367
367
}
368
368
set i [reg_instance $fd ]
369
369
set viewinstances($view ) [list $i ]
370
- if {$showlocalchanges && $mainheadid ne {}} {
371
- interestedin $mainheadid dodiffindex
370
+ set viewmainheadid($view ) $mainheadid
371
+ set viewmainheadid_orig($view ) $mainheadid
372
+ if {$files ne {} && $mainheadid ne {}} {
373
+ get_viewmainhead $view
374
+ }
375
+ if {$showlocalchanges && $viewmainheadid($view) ne {}} {
376
+ interestedin $viewmainheadid($view) dodiffindex
372
377
}
373
378
fconfigure $fd -blocking 0 -translation lf -eofchar {}
374
379
if {$tclencoding != {}} {
@@ -446,22 +451,26 @@ proc updatecommits {} {
446
451
global curview vcanopt vorigargs vfilelimit viewinstances
447
452
global viewactive viewcomplete tclencoding
448
453
global startmsecs showneartags showlocalchanges
449
- global mainheadid pending_select
454
+ global mainheadid viewmainheadid viewmainheadid_orig pending_select
450
455
global isworktree
451
456
global varcid vposids vnegids vflags vrevs
452
457
453
458
set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == " true" }]
454
- set oldmainid $mainheadid
455
459
rereadrefs
456
- if {$showlocalchanges } {
457
- if {$mainheadid ne $oldmainid } {
460
+ set view $curview
461
+ if {$mainheadid ne $viewmainheadid_orig($view) } {
462
+ if {$showlocalchanges } {
458
463
dohidelocalchanges
459
464
}
460
- if {[commitinview $mainheadid $curview ]} {
461
- dodiffindex
465
+ set viewmainheadid($view ) $mainheadid
466
+ set viewmainheadid_orig($view ) $mainheadid
467
+ if {$vfilelimit($view) ne {}} {
468
+ get_viewmainhead $view
462
469
}
463
470
}
464
- set view $curview
471
+ if {$showlocalchanges } {
472
+ doshowlocalchanges
473
+ }
465
474
if {$vcanopt($view) } {
466
475
set oldpos $vposids($view)
467
476
set oldneg $vnegids($view)
@@ -4643,14 +4652,56 @@ proc layoutmore {} {
4643
4652
drawvisible
4644
4653
}
4645
4654
4655
+ # With path limiting, we mightn't get the actual HEAD commit,
4656
+ # so ask git rev-list what is the first ancestor of HEAD that
4657
+ # touches a file in the path limit.
4658
+ proc get_viewmainhead {view} {
4659
+ global viewmainheadid vfilelimit viewinstances mainheadid
4660
+
4661
+ catch {
4662
+ set rfd [open [concat | git rev-list -1 $mainheadid \
4663
+ -- $vfilelimit($view) ] r]
4664
+ set j [reg_instance $rfd ]
4665
+ lappend viewinstances($view ) $j
4666
+ fconfigure $rfd -blocking 0
4667
+ filerun $rfd [list getviewhead $rfd $j $view ]
4668
+ set viewmainheadid($curview ) {}
4669
+ }
4670
+ }
4671
+
4672
+ # git rev-list should give us just 1 line to use as viewmainheadid($view)
4673
+ proc getviewhead {fd inst view} {
4674
+ global viewmainheadid commfd curview viewinstances showlocalchanges
4675
+
4676
+ set id {}
4677
+ if {[gets $fd line] < 0} {
4678
+ if {![eof $fd ]} {
4679
+ return 1
4680
+ }
4681
+ } elseif {[string length $line ] == 40 && [string is xdigit $line ]} {
4682
+ set id $line
4683
+ }
4684
+ set viewmainheadid($view ) $id
4685
+ close $fd
4686
+ unset commfd($inst )
4687
+ set i [lsearch -exact $viewinstances($view) $inst ]
4688
+ if {$i >= 0} {
4689
+ set viewinstances($view ) [lreplace $viewinstances($view) $i $i ]
4690
+ }
4691
+ if {$showlocalchanges && $id ne {} && $view == $curview } {
4692
+ doshowlocalchanges
4693
+ }
4694
+ return 0
4695
+ }
4696
+
4646
4697
proc doshowlocalchanges {} {
4647
- global curview mainheadid
4698
+ global curview viewmainheadid
4648
4699
4649
- if {$mainheadid eq {}} return
4650
- if {[commitinview $mainheadid $curview ]} {
4700
+ if {$viewmainheadid($curview) eq {}} return
4701
+ if {[commitinview $viewmainheadid($curview) $curview ]} {
4651
4702
dodiffindex
4652
4703
} else {
4653
- interestedin $mainheadid dodiffindex
4704
+ interestedin $viewmainheadid($curview) dodiffindex
4654
4705
}
4655
4706
}
4656
4707
@@ -4668,19 +4719,24 @@ proc dohidelocalchanges {} {
4668
4719
4669
4720
# spawn off a process to do git diff-index --cached HEAD
4670
4721
proc dodiffindex {} {
4671
- global lserial showlocalchanges
4722
+ global lserial showlocalchanges vfilelimit curview
4672
4723
global isworktree
4673
4724
4674
4725
if {!$showlocalchanges || !$isworktree } return
4675
4726
incr lserial
4676
- set fd [open " |git diff-index --cached HEAD" r]
4727
+ set cmd " |git diff-index --cached HEAD"
4728
+ if {$vfilelimit($curview) ne {}} {
4729
+ set cmd [concat $cmd -- $vfilelimit($curview) ]
4730
+ }
4731
+ set fd [open $cmd r]
4677
4732
fconfigure $fd -blocking 0
4678
4733
set i [reg_instance $fd ]
4679
4734
filerun $fd [list readdiffindex $fd $lserial $i ]
4680
4735
}
4681
4736
4682
4737
proc readdiffindex {fd serial inst} {
4683
- global mainheadid nullid nullid2 curview commitinfo commitdata lserial
4738
+ global viewmainheadid nullid nullid2 curview commitinfo commitdata lserial
4739
+ global vfilelimit
4684
4740
4685
4741
set isdiff 1
4686
4742
if {[gets $fd line] < 0} {
@@ -4697,7 +4753,11 @@ proc readdiffindex {fd serial inst} {
4697
4753
}
4698
4754
4699
4755
# now see if there are any local changes not checked in to the index
4700
- set fd [open " |git diff-files" r]
4756
+ set cmd " |git diff-files"
4757
+ if {$vfilelimit($curview) ne {}} {
4758
+ set cmd [concat $cmd -- $vfilelimit($curview) ]
4759
+ }
4760
+ set fd [open $cmd r]
4701
4761
fconfigure $fd -blocking 0
4702
4762
set i [reg_instance $fd ]
4703
4763
filerun $fd [list readdifffiles $fd $serial $i ]
@@ -4710,15 +4770,18 @@ proc readdiffindex {fd serial inst} {
4710
4770
if {[commitinview $nullid $curview ]} {
4711
4771
removefakerow $nullid
4712
4772
}
4713
- insertfakerow $nullid2 $mainheadid
4773
+ insertfakerow $nullid2 $viewmainheadid($curview)
4714
4774
} elseif {!$isdiff && [commitinview $nullid2 $curview ]} {
4775
+ if {[commitinview $nullid $curview ]} {
4776
+ removefakerow $nullid
4777
+ }
4715
4778
removefakerow $nullid2
4716
4779
}
4717
4780
return 0
4718
4781
}
4719
4782
4720
4783
proc readdifffiles {fd serial inst} {
4721
- global mainheadid nullid nullid2 curview
4784
+ global viewmainheadid nullid nullid2 curview
4722
4785
global commitinfo commitdata lserial
4723
4786
4724
4787
set isdiff 1
@@ -4743,7 +4806,7 @@ proc readdifffiles {fd serial inst} {
4743
4806
if {[commitinview $nullid2 $curview ]} {
4744
4807
set p $nullid2
4745
4808
} else {
4746
- set p $mainheadid
4809
+ set p $viewmainheadid($curview)
4747
4810
}
4748
4811
insertfakerow $nullid $p
4749
4812
} elseif {!$isdiff && [commitinview $nullid $curview ]} {
@@ -8341,6 +8404,7 @@ proc cherrypick {} {
8341
8404
}
8342
8405
addnewchild $newhead $oldhead
8343
8406
if {[commitinview $oldhead $curview ]} {
8407
+ # XXX this isn't right if we have a path limit...
8344
8408
insertrow $newhead $oldhead $curview
8345
8409
if {$mainhead ne {}} {
8346
8410
movehead $newhead $mainhead
@@ -8448,7 +8512,7 @@ proc headmenu {x y id head} {
8448
8512
8449
8513
proc cobranch {} {
8450
8514
global headmenuid headmenuhead headids
8451
- global showlocalchanges mainheadid
8515
+ global showlocalchanges
8452
8516
8453
8517
# check the tree is clean first??
8454
8518
nowbusy checkout [mc " Checking out" ]
@@ -8469,6 +8533,7 @@ proc cobranch {} {
8469
8533
8470
8534
proc readcheckoutstat {fd newhead newheadid} {
8471
8535
global mainhead mainheadid headids showlocalchanges progresscoords
8536
+ global viewmainheadid curview
8472
8537
8473
8538
if {[gets $fd line] >= 0} {
8474
8539
if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
@@ -8486,6 +8551,7 @@ proc readcheckoutstat {fd newhead newheadid} {
8486
8551
set oldmainid $mainheadid
8487
8552
set mainhead $newhead
8488
8553
set mainheadid $newheadid
8554
+ set viewmainheadid($curview ) $newheadid
8489
8555
redrawtags $oldmainid
8490
8556
redrawtags $newheadid
8491
8557
selbyid $newheadid
0 commit comments