# [PATCH] gitk: do not show local changes for bare repositories

5 messages from 2008-03-06 to 2008-03-10. Participants: David Aguilar, Paul Mackerras.
Thread: https://gitlist.dev/t/12539

## David Aguilar, 2008-03-06 12:39

Subject: [PATCH] gitk: do not show local changes for bare repositories
Message-ID: <64b42ab91804e670057c807fd8265fc07106792c.1204806475.git.davvid@gmail.com>
URL: https://gitlist.dev/e/64b42ab91804e670057c807fd8265fc07106792c.1204806475.git.davvid%40gmail.com

```
Launching gitk on a bare repository would previously show the
work tree as having removed all files.  We now test for bare
repositories before showing local changes.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index f1f21e9..cc4cde3 100755
--- a/gitk
+++ b/gitk
@@ -2843,9 +2843,9 @@ proc dohidelocalchanges {} {
 
 # spawn off a process to do git diff-index --cached HEAD
 proc dodiffindex {} {
-    global localirow localfrow lserial showlocalchanges
+    global localirow localfrow lserial showlocalchanges isbare
 
-    if {!$showlocalchanges} return
+    if {!$showlocalchanges || $isbare} return
     incr lserial
     set localfrow -1
     set localirow -1
@@ -8643,6 +8643,7 @@ set patchnum 0
 set localirow -1
 set localfrow -1
 set lserial 0
+set isbare [expr {[exec git rev-parse --is-bare-repository] == "true"}]
 setcoords
 makewindow
 # wait for the window to become visible
-- 
1.5.4.rc2.1105.gfc5f2


```

## Paul Mackerras, 2008-03-06 23:07

Subject: Re: [PATCH] gitk: do not show local changes for bare repositories
Message-ID: <18384.31029.243013.764703@cargo.ozlabs.ibm.com>
URL: https://gitlist.dev/e/18384.31029.243013.764703%40cargo.ozlabs.ibm.com
In-Reply-To: <64b42ab91804e670057c807fd8265fc07106792c.1204806475.git.davvid@gmail.com>

```
David Aguilar writes:

> +set isbare [expr {[exec git rev-parse --is-bare-repository] == "true"}]

Nice idea, but I think we should update isbare in updatecommits, in
case the user does a checkout and then presses F5.

Paul.

```

## David Aguilar, 2008-03-07 09:04

Subject: [PATCH] gitk: do not show local changes for bare repositories
Message-ID: <8875845cb2c0c3a1ac515b8f71e6be77f3266479.1204879048.git.davvid@gmail.com>
URL: https://gitlist.dev/e/8875845cb2c0c3a1ac515b8f71e6be77f3266479.1204879048.git.davvid%40gmail.com
In-Reply-To: <64b42ab91804e670057c807fd8265fc07106792c.1204806475.git.davvid@gmail.com>

```
Launching gitk on a bare repository would previously show the
work tree as having removed all files.  We now query for
bare repositories in updatecommits and test the value in
dodiffindex before showing local changes.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index f1f21e9..080459d 100755
--- a/gitk
+++ b/gitk
@@ -393,6 +393,7 @@ proc readcommit {id} {
 proc updatecommits {} {
     global viewdata curview phase displayorder ordertok idpending
     global children commitrow selectedline thickerline showneartags
+    global isbare
 
     if {$phase ne {}} {
 	stop_rev_list
@@ -407,6 +408,7 @@ proc updatecommits {} {
     foreach vid [array names idpending "$n,*"] {
 	unset idpending($vid)
     }
+    set isbare [expr {[exec git rev-parse --is-bare-repository] == "true"}]
     set curview -1
     catch {unset selectedline}
     catch {unset thickerline}
@@ -2843,9 +2845,9 @@ proc dohidelocalchanges {} {
 
 # spawn off a process to do git diff-index --cached HEAD
 proc dodiffindex {} {
-    global localirow localfrow lserial showlocalchanges
+    global localirow localfrow lserial showlocalchanges isbare
 
-    if {!$showlocalchanges} return
+    if {!$showlocalchanges || $isbare} return
     incr lserial
     set localfrow -1
     set localirow -1
-- 
1.5.4.1


```

## Paul Mackerras, 2008-03-08 11:14

Subject: Re: [PATCH] gitk: do not show local changes for bare repositories
Message-ID: <18386.29988.380116.517508@cargo.ozlabs.ibm.com>
URL: https://gitlist.dev/e/18386.29988.380116.517508%40cargo.ozlabs.ibm.com
In-Reply-To: <8875845cb2c0c3a1ac515b8f71e6be77f3266479.1204879048.git.davvid@gmail.com>

```
David Aguilar writes:

> @@ -407,6 +408,7 @@ proc updatecommits {} {
>      foreach vid [array names idpending "$n,*"] {
>  	unset idpending($vid)
>      }
> +    set isbare [expr {[exec git rev-parse --is-bare-repository] == "true"}]

Sorry, I meant do that in updatecommits as well as at startup.  You
still need that line in the startup code.

Paul.

```

## David Aguilar, 2008-03-10 10:54

Subject: [PATCH] gitk: do not show local changes when we there is no work tree
Message-ID: <309f000ad75b1842c11a04b16940dda8f1cd84af.1205145018.git.davvid@gmail.com>
URL: https://gitlist.dev/e/309f000ad75b1842c11a04b16940dda8f1cd84af.1205145018.git.davvid%40gmail.com
In-Reply-To: <18386.29988.380116.517508@cargo.ozlabs.ibm.com>

```
Launching gitk on a bare repository or a .git directory
would previously show the work tree as having removed all
files.  We now inhibit showing local changes when gitk
is not launched from within a work tree.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 gitk |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index f1f21e9..ef12845 100755
--- a/gitk
+++ b/gitk
@@ -393,6 +393,9 @@ proc readcommit {id} {
 proc updatecommits {} {
     global viewdata curview phase displayorder ordertok idpending
     global children commitrow selectedline thickerline showneartags
+    global isworktree
+
+    set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
 
     if {$phase ne {}} {
 	stop_rev_list
@@ -2844,8 +2847,9 @@ proc dohidelocalchanges {} {
 # spawn off a process to do git diff-index --cached HEAD
 proc dodiffindex {} {
     global localirow localfrow lserial showlocalchanges
+    global isworktree
 
-    if {!$showlocalchanges} return
+    if {!$showlocalchanges || !$isworktree} return
     incr lserial
     set localfrow -1
     set localirow -1
@@ -8643,6 +8647,7 @@ set patchnum 0
 set localirow -1
 set localfrow -1
 set lserial 0
+set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == "true"}]
 setcoords
 makewindow
 # wait for the window to become visible
-- 
1.5.4.3

```
