summaryrefslogtreecommitdiff
path: root/gitk
diff options
context:
space:
mode:
authorLibravatar Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>2011-05-23 22:44:08 -0400
committerLibravatar Paul Mackerras <paulus@samba.org>2011-07-24 15:34:54 +1000
commit74cb884faa2d4214e349879adda8adc73362d692 (patch)
tree3a9167575e4f07aafac265b59ff457cd16b1b64a /gitk
parentgitk: Simplify calculation of gitdir (diff)
downloadtgif-74cb884faa2d4214e349879adda8adc73362d692.tar.xz
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>
Diffstat (limited to 'gitk')
-rwxr-xr-xgitk17
1 files changed, 11 insertions, 6 deletions
diff --git a/gitk b/gitk
index facf294cc0..18e3626845 100755
--- a/gitk
+++ b/gitk
@@ -9,6 +9,11 @@ exec wish "$0" -- "$@"
package require Tk
+proc hasworktree {} {
+ return [expr {[exec git rev-parse --is-bare-repository] == "false" &&
+ [exec git rev-parse --is-inside-git-dir] == "false"}]
+}
+
# A simple scheduler for compute-intensive stuff.
# The aim is to make sure that event handlers for GUI actions can
# run at least every 50-100 ms. Unfortunately fileevent handlers are
@@ -459,11 +464,11 @@ proc updatecommits {} {
global viewactive viewcomplete tclencoding
global startmsecs showneartags showlocalchanges
global mainheadid viewmainheadid viewmainheadid_orig pending_select
- global isworktree
+ global hasworktree
global varcid vposids vnegids vflags vrevs
global show_notes
- set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
+ set hasworktree [hasworktree]
rereadrefs
set view $curview
if {$mainheadid ne $viewmainheadid_orig($view)} {
@@ -5024,9 +5029,9 @@ proc dohidelocalchanges {} {
# spawn off a process to do git diff-index --cached HEAD
proc dodiffindex {} {
global lserial showlocalchanges vfilelimit curview
- global isworktree
+ global hasworktree
- if {!$showlocalchanges || !$isworktree} return
+ if {!$showlocalchanges || !$hasworktree} return
incr lserial
set cmd "|git diff-index --cached HEAD"
if {$vfilelimit($curview) ne {}} {
@@ -11633,9 +11638,9 @@ set stopped 0
set stuffsaved 0
set patchnum 0
set lserial 0
-set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
+set hasworktree [hasworktree]
set cdup {}
-if {$isworktree} {
+if {[expr {[exec git rev-parse --is-inside-work-tree] == "true"}]} {
set cdup [exec git rev-parse --show-cdup]
}
set worktree [exec git rev-parse --show-toplevel]