309
global viewargs viewargscmd viewfiles vfilelimit
310
global showlocalchanges
311
global viewactive viewinstances vmergeonly
312
- global mainheadid
312
+ global mainheadid viewmainheadid viewmainheadid_orig
313
global vcanopt vflags vrevs vorigargs
314
315
set startmsecs [clock clicks -milliseconds]
367
}
368
set i [reg_instance $fd]
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
377
}
378
fconfigure $fd -blocking 0 -translation lf -eofchar {}
379
if {$tclencoding != {}} {
451
global curview vcanopt vorigargs vfilelimit viewinstances
452
global viewactive viewcomplete tclencoding
453
global startmsecs showneartags showlocalchanges
449
- global mainheadid pending_select
454
+ global mainheadid viewmainheadid viewmainheadid_orig pending_select
455
global isworktree
456
global varcid vposids vnegids vflags vrevs
457
458
set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
454
- set oldmainid $mainheadid
459
rereadrefs
456
- if {$showlocalchanges} {
457
- if {$mainheadid ne $oldmainid} {
460
+ set view $curview
461
+ if {$mainheadid ne $viewmainheadid_orig($view)} {
462
+ if {$showlocalchanges} {
463
dohidelocalchanges
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
469
}
470
}
464
- set view $curview
471
+ if {$showlocalchanges} {
472
+ doshowlocalchanges
473
+ }
474
if {$vcanopt($view)} {
475
set oldpos $vposids($view)
476
set oldneg $vnegids($view)
4652
drawvisible
4653
}
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
+
4697
proc doshowlocalchanges {} {
4647
- global curview mainheadid
4698
+ global curview viewmainheadid
4699
4649
- if {$mainheadid eq {}} return
4650
- if {[commitinview $mainheadid $curview]} {
4700
+ if {$viewmainheadid($curview) eq {}} return
4701
+ if {[commitinview $viewmainheadid($curview) $curview]} {
4702
dodiffindex
4703
} else {
4653
- interestedin $mainheadid dodiffindex
4704
+ interestedin $viewmainheadid($curview) dodiffindex
4705
}
4706
}
4707
4719
4720
# spawn off a process to do git diff-index --cached HEAD
4721
proc dodiffindex {} {
4671
- global lserial showlocalchanges
4722
+ global lserial showlocalchanges vfilelimit curview
4723
global isworktree
4724
4725
if {!$showlocalchanges || !$isworktree} return
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]
4732
fconfigure $fd -blocking 0
4733
set i [reg_instance $fd]
4734
filerun $fd [list readdiffindex $fd $lserial $i]
4735
}
4736
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
4740
4741
set isdiff 1
4742
if {[gets $fd line] < 0} {
4753
}
4754
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]
4761
fconfigure $fd -blocking 0
4762
set i [reg_instance $fd]
4763
filerun $fd [list readdifffiles $fd $serial $i]
4770
if {[commitinview $nullid $curview]} {
4771
removefakerow $nullid
4772
}
4713
- insertfakerow $nullid2 $mainheadid
4773
+ insertfakerow $nullid2 $viewmainheadid($curview)
4774
} elseif {!$isdiff && [commitinview $nullid2 $curview]} {
4775
+ if {[commitinview $nullid $curview]} {
4776
+ removefakerow $nullid
4777
+ }
4778
removefakerow $nullid2
4779
}
4780
return 0
4781
}
4782
4783
proc readdifffiles {fd serial inst} {
4721
- global mainheadid nullid nullid2 curview
4784
+ global viewmainheadid nullid nullid2 curview
4785
global commitinfo commitdata lserial
4786
4787
set isdiff 1
4806
if {[commitinview $nullid2 $curview]} {
4807
set p $nullid2
4808
} else {
4746
- set p $mainheadid
4809
+ set p $viewmainheadid($curview)
4810
}
4811
insertfakerow $nullid $p
4812
} elseif {!$isdiff && [commitinview $nullid $curview]} {
8404
}
8405
addnewchild $newhead $oldhead
8406
if {[commitinview $oldhead $curview]} {
8407
+ # XXX this isn't right if we have a path limit...
8408
insertrow $newhead $oldhead $curview
8409
if {$mainhead ne {}} {
8410
movehead $newhead $mainhead
8512
8513
proc cobranch {} {
8514
global headmenuid headmenuhead headids
8451
- global showlocalchanges mainheadid
8515
+ global showlocalchanges
8516
8517
# check the tree is clean first??
8518
nowbusy checkout [mc "Checking out"]
8533
8534
proc readcheckoutstat {fd newhead newheadid} {
8535
global mainhead mainheadid headids showlocalchanges progresscoords
8536
+ global viewmainheadid curview
8537
8538
if {[gets $fd line] >= 0} {
8539
if {[regexp {([0-9]+)% \(([0-9]+)/([0-9]+)\)} $line match p m n]} {
8551
set oldmainid $mainheadid
8552
set mainhead $newhead
8553
set mainheadid $newheadid
8554
+ set viewmainheadid($curview) $newheadid
8555
redrawtags $oldmainid
8556
redrawtags $newheadid
8557
selbyid $newheadid