Skip to content

Commit

Permalink
gitk: Show modified files with separate work tree
Browse files Browse the repository at this point in the history
"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>
  • Loading branch information
Martin von Zweigbergk authored and Paul Mackerras committed Jul 24, 2011
1 parent 86e847b commit 74cb884
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)} {
Expand Down Expand Up @@ -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 {}} {
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 74cb884

Please sign in to comment.