gitk: Show modified files with separate work tree
"git rev-parse --is-inside-work-tree" is currently used to determine whether to show modified files in gitk (the red and green fake commits). This does not work if the current directory is not inside the work tree, as can be the case e.g. if GIT_WORK_TREE is set. Instead, check if the repository is not bare and that we are not inside the .git directory. Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Martin von Zweigbergk committed
May 23, 2011 at 22:44 UTC
74cb884faa2d4214e349879adda8adc73362d692
1 file changed
+11
-6
gitk
+11
-6
@@ -9,6 +9,11 @@ exec wish "$0" -- "$@"
9
10
package require Tk
11
12
+proc hasworktree {} {
13
+ return [expr {[exec git rev-parse --is-bare-repository] == "false" &&
14
+ [exec git rev-parse --is-inside-git-dir] == "false"}]
15
+}
16
+
17
# A simple scheduler for compute-intensive stuff.
18
# The aim is to make sure that event handlers for GUI actions can
19
# run at least every 50-100 ms. Unfortunately fileevent handlers are
@@ -459,11 +464,11 @@ proc updatecommits {} {
464
global viewactive viewcomplete tclencoding
465
global startmsecs showneartags showlocalchanges
466
global mainheadid viewmainheadid viewmainheadid_orig pending_select
462
- global isworktree
467
+ global hasworktree
468
global varcid vposids vnegids vflags vrevs
469
global show_notes
470
466
- set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
471
+ set hasworktree [hasworktree]
472
rereadrefs
473
set view $curview
474
if {$mainheadid ne $viewmainheadid_orig($view)} {
@@ -5024,9 +5029,9 @@ proc dohidelocalchanges {} {
5029
# spawn off a process to do git diff-index --cached HEAD
5030
proc dodiffindex {} {
5031
global lserial showlocalchanges vfilelimit curview
5027
- global isworktree
5032
+ global hasworktree
5033
5029
- if {!$showlocalchanges || !$isworktree} return
5034
+ if {!$showlocalchanges || !$hasworktree} return
5035
incr lserial
5036
set cmd "|git diff-index --cached HEAD"
5037
if {$vfilelimit($curview) ne {}} {
@@ -11633,9 +11638,9 @@ set stopped 0
11638
set stuffsaved 0
11639
set patchnum 0
11640
set lserial 0
11636
-set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
11641
+set hasworktree [hasworktree]
11642
set cdup {}
11638
-if {$isworktree} {
11643
+if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} {
11644
set cdup [exec git rev-parse --show-cdup]
11645
}
11646
set worktree [exec git rev-parse --show-toplevel]