* [PATCHv3 0/3] git-gui: more robust handling of fancy repos
@ 2009-08-16 23:58 Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 1/3] git-gui: handle non-standard worktree locations Giuseppe Bilotta
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Giuseppe Bilotta @ 2009-08-16 23:58 UTC (permalink / raw)
To: git; +Cc: Markus Heidelberg, Shawn O. Pearce, Giuseppe Bilotta
As promised a long time ago (March 30), version 3 of the small patchset
to improve handling of repositories in git gui. The most significant
change is the addition of the third patch.
The first patch allows git gui to work with respotiories for which
the worktree is not the parent of the gitdir.
The second patch refactors bare repository detection, improves the error
message if the bare support feature is disabled, and disabled
inapplicable menu entries.
The third patch allows git-gui to work properly when launched from the
.git directory itself, solving the issue Markus Heidelberg was having in
http://thread.gmane.org/gmane.comp.version-control.git/115044
Giuseppe Bilotta (3):
git-gui: handle non-standard worktree locations
git-gui: handle bare repos correctly
git-gui: work from the .git dir
git-gui/git-gui.sh | 88 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 73 insertions(+), 15 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCHv3 1/3] git-gui: handle non-standard worktree locations
2009-08-16 23:58 [PATCHv3 0/3] git-gui: more robust handling of fancy repos Giuseppe Bilotta
@ 2009-08-16 23:58 ` Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 2/3] git-gui: handle bare repos correctly Giuseppe Bilotta
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Giuseppe Bilotta @ 2009-08-16 23:58 UTC (permalink / raw)
To: git; +Cc: Markus Heidelberg, Shawn O. Pearce, Giuseppe Bilotta
Don't rely on the git worktree being the updir of the gitdir, since it
might not be. Instead, define (and use) a new _gitworktree global
variable, setting it to $GIT_WORK_TREE if present, falling back to
core.worktree if defined, and finally to whatever we guess the correct
worktree is. Getting core.worktree requires the config from the alleged
git dir _gitdir to be loaded early.
Supporting non-standard worktree locations also breaks the git-gui
assumption (made when calling gitk) that the worktree was the dirname of
$_gitdir and that, by consequence, the git dir could be set to the tail
of $_gitdir once we changed to the worktree root directory. Therefore,
we need to export a GIT_DIR environment variable set to the full,
normalized path of $_gitdir instead. We also skip changing to the worktree
directory if it's empty (i.e. if we're working on a bare repository).
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
git-gui/git-gui.sh | 37 ++++++++++++++++++++++++++++---------
1 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 14b92ba..229e94a 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -121,6 +121,7 @@ unset oguimsg
set _appname {Git Gui}
set _gitdir {}
+set _gitworktree {}
set _gitexec {}
set _githtmldir {}
set _reponame {}
@@ -1088,13 +1089,25 @@ if {![file isdirectory $_gitdir]} {
error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"]
exit 1
}
+# _gitdir exists, so try loading the config
+load_config 0
+apply_config
+# try to set work tree from environment, falling back to core.worktree
+if {[catch { set _gitworktree $env(GIT_WORK_TREE) }]} {
+ set _gitworktree [get_config core.worktree]
+}
if {$_prefix ne {}} {
- regsub -all {[^/]+/} $_prefix ../ cdup
+ if {$_gitworktree eq {}} {
+ regsub -all {[^/]+/} $_prefix ../ cdup
+ } else {
+ set cdup $_gitworktree
+ }
if {[catch {cd $cdup} err]} {
catch {wm withdraw .}
error_popup [strcat [mc "Cannot move to top of working directory:"] "\n\n$err"]
exit 1
}
+ set _gitworktree [pwd]
unset cdup
} elseif {![is_enabled bare]} {
if {[lindex [file split $_gitdir] end] ne {.git}} {
@@ -1102,11 +1115,15 @@ if {$_prefix ne {}} {
error_popup [strcat [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"]
exit 1
}
- if {[catch {cd [file dirname $_gitdir]} err]} {
+ if {$_gitworktree eq {}} {
+ set _gitworktree [file dirname $_gitdir]
+ }
+ if {[catch {cd $_gitworktree} err]} {
catch {wm withdraw .}
- error_popup [strcat [mc "No working directory"] " [file dirname $_gitdir]:\n\n$err"]
+ error_popup [strcat [mc "No working directory"] " $_gitworktree:\n\n$err"]
exit 1
}
+ set _gitworktree [pwd]
}
set _reponame [file split [file normalize $_gitdir]]
if {[lindex $_reponame end] eq {.git}} {
@@ -1905,6 +1922,7 @@ proc incr_font_size {font {amt 1}} {
set starting_gitk_msg [mc "Starting gitk... please wait..."]
proc do_gitk {revs} {
+ global _gitworktree
# -- Always start gitk through whatever we were loaded with. This
# lets us bypass using shell process on Windows systems.
#
@@ -1922,8 +1940,10 @@ proc do_gitk {revs} {
}
set pwd [pwd]
- cd [file dirname [gitdir]]
- set env(GIT_DIR) [file tail [gitdir]]
+ if { $_gitworktree ne {} } {
+ cd $_gitworktree
+ }
+ set env(GIT_DIR) [file normalize [gitdir]]
eval exec $cmd $revs &
@@ -1942,6 +1962,7 @@ proc do_gitk {revs} {
}
proc do_explore {} {
+ global _gitworktree
set explorer {}
if {[is_Cygwin] || [is_Windows]} {
set explorer "explorer.exe"
@@ -1951,7 +1972,7 @@ proc do_explore {} {
# freedesktop.org-conforming system is our best shot
set explorer "xdg-open"
}
- eval exec $explorer [list [file nativename [file dirname [gitdir]]]] &
+ eval exec $explorer $_gitworktree &
}
set is_quitting 0
@@ -2297,8 +2318,6 @@ proc show_less_context {} {
##
## ui construction
-load_config 0
-apply_config
set ui_comm {}
# -- Menu Bar
@@ -3328,7 +3347,7 @@ unset i
set file_lists($ui_index) [list]
set file_lists($ui_workdir) [list]
-wm title . "[appname] ([reponame]) [file normalize [file dirname [gitdir]]]"
+wm title . "[appname] ([reponame]) [file normalize $_gitworktree]"
focus -force $ui_comm
# -- Warn the user about environmental problems. Cygwin's Tcl
--
1.6.4.177.g695987
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCHv3 2/3] git-gui: handle bare repos correctly
2009-08-16 23:58 [PATCHv3 0/3] git-gui: more robust handling of fancy repos Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 1/3] git-gui: handle non-standard worktree locations Giuseppe Bilotta
@ 2009-08-16 23:58 ` Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 3/3] git-gui: work from the .git dir Giuseppe Bilotta
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Giuseppe Bilotta @ 2009-08-16 23:58 UTC (permalink / raw)
To: git; +Cc: Markus Heidelberg, Shawn O. Pearce, Giuseppe Bilotta
Refactor checking for a bare repository into its own proc, that relies
on git rev-parse --is-bare-repository if possible. For older versions of
git we fall back to a logic such that the repository is considered bare
if:
* either the core.bare setting is true
* or the worktree is not set and the directory name ends with .git
The error message for the case of an unhandled bare repository is also
updated to reflect the fact that the problem is not the funny name but
the bareness.
The new refactored proc is also used to disable the menu entry to
explore the working copy, and to skip changing to the worktree before
the gitk invocation.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
git-gui/git-gui.sh | 43 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 229e94a..38b11c1 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -122,6 +122,7 @@ unset oguimsg
set _appname {Git Gui}
set _gitdir {}
set _gitworktree {}
+set _isbare {}
set _gitexec {}
set _githtmldir {}
set _reponame {}
@@ -277,6 +278,32 @@ proc get_config {name} {
}
}
+proc is_bare {} {
+ global _isbare
+ global _gitdir
+ global _gitworktree
+
+ if {$_isbare eq {}} {
+ if {[catch {
+ set _bare [git rev-parse --is-bare-repository]
+ switch -- $_bare {
+ true { set _isbare 1 }
+ false { set _isbare 0}
+ default { throw }
+ }
+ }]} {
+ if {[is_config_true core.bare]
+ || ($_gitworktree eq {}
+ && [lindex [file split $_gitdir] end] ne {.git})} {
+ set _isbare 1
+ } else {
+ set _isbare 0
+ }
+ }
+ }
+ return $_isbare
+}
+
######################################################################
##
## handy utils
@@ -1110,9 +1137,9 @@ if {$_prefix ne {}} {
set _gitworktree [pwd]
unset cdup
} elseif {![is_enabled bare]} {
- if {[lindex [file split $_gitdir] end] ne {.git}} {
+ if {[is_bare]} {
catch {wm withdraw .}
- error_popup [strcat [mc "Cannot use funny .git directory:"] "\n\n$_gitdir"]
+ error_popup [strcat [mc "Cannot use bare repository:"] "\n\n$_gitdir"]
exit 1
}
if {$_gitworktree eq {}} {
@@ -1940,7 +1967,7 @@ proc do_gitk {revs} {
}
set pwd [pwd]
- if { $_gitworktree ne {} } {
+ if { ![is_bare] } {
cd $_gitworktree
}
set env(GIT_DIR) [file normalize [gitdir]]
@@ -2349,10 +2376,12 @@ if {[is_enabled multicommit] || [is_enabled singlecommit]} {
#
menu .mbar.repository
-.mbar.repository add command \
- -label [mc "Explore Working Copy"] \
- -command {do_explore}
-.mbar.repository add separator
+if {![is_bare]} {
+ .mbar.repository add command \
+ -label [mc "Explore Working Copy"] \
+ -command {do_explore}
+ .mbar.repository add separator
+}
.mbar.repository add command \
-label [mc "Browse Current Branch's Files"] \
--
1.6.4.177.g695987
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCHv3 3/3] git-gui: work from the .git dir
2009-08-16 23:58 [PATCHv3 0/3] git-gui: more robust handling of fancy repos Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 1/3] git-gui: handle non-standard worktree locations Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 2/3] git-gui: handle bare repos correctly Giuseppe Bilotta
@ 2009-08-16 23:58 ` Giuseppe Bilotta
2009-10-27 11:35 ` [PATCHv3 0/3] git-gui: more robust handling of fancy repos Bert Wesarg
2009-12-05 22:15 ` Shawn O. Pearce
4 siblings, 0 replies; 9+ messages in thread
From: Giuseppe Bilotta @ 2009-08-16 23:58 UTC (permalink / raw)
To: git; +Cc: Markus Heidelberg, Shawn O. Pearce, Giuseppe Bilotta
When git-gui is run from a .git dir, _gitdir would be set to "." by
rev-parse, something that confuses the worktree detection.
Fix by expanding the value of _gitdir to pwd in this special case.
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
---
git-gui/git-gui.sh | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 38b11c1..fbad6fd 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1100,6 +1100,8 @@ if {[catch {
set _prefix {}
}]
&& [catch {
+ # beware that from the .git dir this sets _gitdir to .
+ # and _prefix to the empty string
set _gitdir [git rev-parse --git-dir]
set _prefix [git rev-parse --show-prefix]
} err]} {
@@ -1108,6 +1110,14 @@ if {[catch {
choose_repository::pick
set picked 1
}
+
+# we expand the _gitdir when it's just a single dot (i.e. when we're being
+# run from the .git dir itself) lest the routines to find the worktree
+# get confused
+if {$_gitdir eq "."} {
+ set _gitdir [pwd]
+}
+
if {![file isdirectory $_gitdir] && [is_Cygwin]} {
catch {set _gitdir [exec cygpath --windows $_gitdir]}
}
--
1.6.4.177.g695987
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCHv3 0/3] git-gui: more robust handling of fancy repos
2009-08-16 23:58 [PATCHv3 0/3] git-gui: more robust handling of fancy repos Giuseppe Bilotta
` (2 preceding siblings ...)
2009-08-16 23:58 ` [PATCHv3 3/3] git-gui: work from the .git dir Giuseppe Bilotta
@ 2009-10-27 11:35 ` Bert Wesarg
2009-12-06 8:14 ` Giuseppe Bilotta
2009-12-05 22:15 ` Shawn O. Pearce
4 siblings, 1 reply; 9+ messages in thread
From: Bert Wesarg @ 2009-10-27 11:35 UTC (permalink / raw)
To: Giuseppe Bilotta; +Cc: git, Markus Heidelberg, Shawn O. Pearce
On Mon, Aug 17, 2009 at 00:58, Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
> As promised a long time ago (March 30), version 3 of the small patchset
> to improve handling of repositories in git gui. The most significant
> change is the addition of the third patch.
>
> The first patch allows git gui to work with respotiories for which
> the worktree is not the parent of the gitdir.
>
> The second patch refactors bare repository detection, improves the error
> message if the bare support feature is disabled, and disabled
> inapplicable menu entries.
>
> The third patch allows git-gui to work properly when launched from the
> .git directory itself, solving the issue Markus Heidelberg was having in
> http://thread.gmane.org/gmane.comp.version-control.git/115044
>
> Giuseppe Bilotta (3):
> git-gui: handle non-standard worktree locations
> git-gui: handle bare repos correctly
> git-gui: work from the .git dir
What is the state of this patch, I can't find it applied.
I would also suggest to always export GIT_DIR into the environment, so
that guitools can relay on this.
Regards,
Bert
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv3 0/3] git-gui: more robust handling of fancy repos
2009-08-16 23:58 [PATCHv3 0/3] git-gui: more robust handling of fancy repos Giuseppe Bilotta
` (3 preceding siblings ...)
2009-10-27 11:35 ` [PATCHv3 0/3] git-gui: more robust handling of fancy repos Bert Wesarg
@ 2009-12-05 22:15 ` Shawn O. Pearce
4 siblings, 0 replies; 9+ messages in thread
From: Shawn O. Pearce @ 2009-12-05 22:15 UTC (permalink / raw)
To: Giuseppe Bilotta; +Cc: git, Markus Heidelberg
Giuseppe Bilotta <giuseppe.bilotta@gmail.com> wrote:
> As promised a long time ago (March 30), version 3 of the small patchset
> to improve handling of repositories in git gui. The most significant
> change is the addition of the third patch.
...
> Giuseppe Bilotta (3):
> git-gui: handle non-standard worktree locations
> git-gui: handle bare repos correctly
> git-gui: work from the .git dir
>
> git-gui/git-gui.sh | 88 +++++++++++++++++++++++++++++++++++++++++++---------
> 1 files changed, 73 insertions(+), 15 deletions(-)
Unfortunately this series doesn't apply to my tree, and I don't
have the blobs which are recorded in the index line, so I can't
easily 3-way merge it onto the current tip.
Would you be able to rebase it?
--
Shawn.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv3 0/3] git-gui: more robust handling of fancy repos
2009-10-27 11:35 ` [PATCHv3 0/3] git-gui: more robust handling of fancy repos Bert Wesarg
@ 2009-12-06 8:14 ` Giuseppe Bilotta
2009-12-06 12:59 ` Bert Wesarg
0 siblings, 1 reply; 9+ messages in thread
From: Giuseppe Bilotta @ 2009-12-06 8:14 UTC (permalink / raw)
To: Bert Wesarg; +Cc: git, Markus Heidelberg, Shawn O. Pearce
On Tue, Oct 27, 2009 at 12:35 PM, Bert Wesarg
<bert.wesarg@googlemail.com> wrote:
>
> I would also suggest to always export GIT_DIR into the environment, so
> that guitools can relay on this.
I'm sorry I couldn't reply to this email earlier. I have never used
this feature, but if you can provide some example guitools
configuration I'll gladly move the environment export earlier and test
it.
--
Giuseppe "Oblomov" Bilotta
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv3 0/3] git-gui: more robust handling of fancy repos
2009-12-06 8:14 ` Giuseppe Bilotta
@ 2009-12-06 12:59 ` Bert Wesarg
2009-12-06 13:43 ` Giuseppe Bilotta
0 siblings, 1 reply; 9+ messages in thread
From: Bert Wesarg @ 2009-12-06 12:59 UTC (permalink / raw)
To: Giuseppe Bilotta; +Cc: git, Markus Heidelberg, Shawn O. Pearce
On Sun, Dec 6, 2009 at 09:14, Giuseppe Bilotta
<giuseppe.bilotta@gmail.com> wrote:
> On Tue, Oct 27, 2009 at 12:35 PM, Bert Wesarg
> <bert.wesarg@googlemail.com> wrote:
>>
>> I would also suggest to always export GIT_DIR into the environment, so
>> that guitools can relay on this.
>
> I'm sorry I couldn't reply to this email earlier. I have never used
> this feature, but if you can provide some example guitools
> configuration I'll gladly move the environment export earlier and test
> it.
Here it is:
[guitool "exclude/Ignore file"]
cmd = echo \"$FILENAME\" >> \"${GIT_DIR:=.git}/info/exclude\"
noconsole = yes
needsfile = yes
The purpose is simple: add the current file to the info/exclude file
in the git dir As you can see, I have a workaround for not having
GIT_DIR in the env, which should solve the issue. But it would be nice
to rely on this.
Bert
>
> --
> Giuseppe "Oblomov" Bilotta
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv3 0/3] git-gui: more robust handling of fancy repos
2009-12-06 12:59 ` Bert Wesarg
@ 2009-12-06 13:43 ` Giuseppe Bilotta
0 siblings, 0 replies; 9+ messages in thread
From: Giuseppe Bilotta @ 2009-12-06 13:43 UTC (permalink / raw)
To: Bert Wesarg; +Cc: git, Markus Heidelberg, Shawn O. Pearce
On Sun, Dec 6, 2009 at 1:59 PM, Bert Wesarg <bert.wesarg@googlemail.com> wrote:
> Here it is:
>
> [guitool "exclude/Ignore file"]
> cmd = echo \"$FILENAME\" >> \"${GIT_DIR:=.git}/info/exclude\"
> noconsole = yes
> needsfile = yes
>
> The purpose is simple: add the current file to the info/exclude file
> in the git dir As you can see, I have a workaround for not having
> GIT_DIR in the env, which should solve the issue. But it would be nice
> to rely on this.
Yup. I'm thinking about setting both $GIT_DIR and $GIT_WORK_TREE once
and for all at the end of the repo setup. This should also spare us
setting it up specifically for gitk (and then separately for the
tools). The question is: should it be done the way it's done for gitk
(i.e. normalizing the paths), or just use it as-is? In the latter
case, the question would be why is the path being normalized before
gitk is invoked.
Ideas?
--
Giuseppe "Oblomov" Bilotta
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-12-06 13:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-16 23:58 [PATCHv3 0/3] git-gui: more robust handling of fancy repos Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 1/3] git-gui: handle non-standard worktree locations Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 2/3] git-gui: handle bare repos correctly Giuseppe Bilotta
2009-08-16 23:58 ` [PATCHv3 3/3] git-gui: work from the .git dir Giuseppe Bilotta
2009-10-27 11:35 ` [PATCHv3 0/3] git-gui: more robust handling of fancy repos Bert Wesarg
2009-12-06 8:14 ` Giuseppe Bilotta
2009-12-06 12:59 ` Bert Wesarg
2009-12-06 13:43 ` Giuseppe Bilotta
2009-12-05 22:15 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).