* Problem with git-gui and relative directories
@ 2007-08-24 13:40 David Kastrup
2007-08-25 3:18 ` Shawn O. Pearce
0 siblings, 1 reply; 4+ messages in thread
From: David Kastrup @ 2007-08-24 13:40 UTC (permalink / raw)
To: git
Doing something like
mkdir -p junk/woozle
cd junk
git-init
cd woozle
echo "hooray" > plop
git add plop
git commit -m "x"
git gui blame plop
errors out with
fatal: cannot stat path woozle/plop: No such file or directory
Obviously, git-gui is confused about relative paths here.
--
David Kastrup
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem with git-gui and relative directories
2007-08-24 13:40 Problem with git-gui and relative directories David Kastrup
@ 2007-08-25 3:18 ` Shawn O. Pearce
2007-08-25 7:26 ` David Kastrup
0 siblings, 1 reply; 4+ messages in thread
From: Shawn O. Pearce @ 2007-08-25 3:18 UTC (permalink / raw)
To: David Kastrup; +Cc: git
David Kastrup <dak@gnu.org> wrote:
> Doing something like
...
> errors out with
>
> fatal: cannot stat path woozle/plop: No such file or directory
>
> Obviously, git-gui is confused about relative paths here.
Yes, it is. I'm committing this, to be included in 0.8.2:
-->8--
git-gui: Correct 'git gui blame' in a subdirectory
David Kastrup pointed out that the following sequence was not
working as we had intended:
$ cd lib
$ git gui blame console.tcl
fatal: cannot stat path lib/console.tcl: No such file or directory
The problem here was we disabled the chdir to the root of the
working tree when we are running with a "bare allowed" feature
such as blame or browser, but we still kept the prefix we found via
`git rev-parse --show-prefix`. This caused us to try and look for
the file "console.tcl" within the subdirectory but also include
the subdirectory's own path from the root of the working tree.
This is unlikely to succeed, unless the user just happened to have
a "lib/lib/console.tcl" file in the repository, in which case we
would produce the wrong result.
In the case of a bare repository we shouldn't get back a value from
`rev-parse --show-prefix`, so really $_prefix should only be set
to the non-empty string if we are in a working tree and we are in a
subdirectory of that working tree. If this is true we really want
to always be at the top level of the working tree, as all paths are
accessed as though they were relative to the top of the working tree.
Converting $_prefix to a ../ sequence is a fairly simple approach
to moving up the requisite levels.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
git-gui.sh | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index 743b7d4..fa30ccc 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -703,7 +703,15 @@ if {![file isdirectory $_gitdir]} {
error_popup "Git directory not found:\n\n$_gitdir"
exit 1
}
-if {![is_enabled bare]} {
+if {$_prefix ne {}} {
+ regsub -all {[^/]+/} $_prefix ../ cdup
+ if {[catch {cd $cdup} err]} {
+ catch {wm withdraw .}
+ error_popup "Cannot move to top of working directory:\n\n$err"
+ exit 1
+ }
+ unset cdup
+} elseif {![is_enabled bare]} {
if {[lindex [file split $_gitdir] end] ne {.git}} {
catch {wm withdraw .}
error_popup "Cannot use funny .git directory:\n\n$_gitdir"
--
1.5.3.rc6.17.g1911
--
Shawn.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: Problem with git-gui and relative directories
2007-08-25 3:18 ` Shawn O. Pearce
@ 2007-08-25 7:26 ` David Kastrup
2007-08-25 8:15 ` Shawn O. Pearce
0 siblings, 1 reply; 4+ messages in thread
From: David Kastrup @ 2007-08-25 7:26 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
"Shawn O. Pearce" <spearce@spearce.org> writes:
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
> git-gui.sh | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/git-gui.sh b/git-gui.sh
> index 743b7d4..fa30ccc 100755
> --- a/git-gui.sh
> +++ b/git-gui.sh
> @@ -703,7 +703,15 @@ if {![file isdirectory $_gitdir]} {
> error_popup "Git directory not found:\n\n$_gitdir"
> exit 1
> }
> -if {![is_enabled bare]} {
> +if {$_prefix ne {}} {
> + regsub -all {[^/]+/} $_prefix ../ cdup
I don't like this approach. It assumes too much about the file system
and cleanliness of paths. It does all of the following:
/somedir/ -> /../
/somedir -> /somedir
//server/somedir -> //../somedir
/somedir//someother -> /..//someother
and so on. It can't deal with directory symlinks properly. And the
approach does not scale to Windows and other systems with diverging
path syntaxes at all.
Isn't it possible to move to the workdir root for the purpose of
interpreting workdir root relative filenames?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem with git-gui and relative directories
2007-08-25 7:26 ` David Kastrup
@ 2007-08-25 8:15 ` Shawn O. Pearce
0 siblings, 0 replies; 4+ messages in thread
From: Shawn O. Pearce @ 2007-08-25 8:15 UTC (permalink / raw)
To: David Kastrup; +Cc: git
David Kastrup <dak@gnu.org> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> > +if {$_prefix ne {}} {
> > + regsub -all {[^/]+/} $_prefix ../ cdup
>
> I don't like this approach. It assumes too much about the file system
> and cleanliness of paths. It does all of the following:
>
> /somedir/ -> /../
> /somedir -> /somedir
> //server/somedir -> //../somedir
> /somedir//someother -> /..//someother
OK, well, uh. Go read the manpage for `git-rev-parse` and focus
in particular on the `--show-prefix` option of that command.
Its output is what we are using here. Its very well defined within
Git, and should have the same definition on all operating systems,
including MinGW.
And if the MinGW folks did something funny its only a translation
of / to \, in which case its easy enough for git-gui to make that
decision on its own based on what type of git it is running on.
> and so on. It can't deal with directory symlinks properly.
Depends on your definition of properly. Here git-gui does exactly
what the C programs in core Git do, which is counter to what the
shell scripts do. And people prefer the C behavior of going up
through the real parents, ignoring the symlinks that were used to
get to the directory the user started git-gui within.
> And the
> approach does not scale to Windows and other systems with diverging
> path syntaxes at all.
Yes, it does. Because the format of --show-prefix is defined.
> Isn't it possible to move to the workdir root for the purpose of
> interpreting workdir root relative filenames?
Because I have always disagreed with the GIT_WORK_TREE mess.
I think its insane to say "I'm here in A, my repository is over
there in B and my files are here in C... now go run status!".
But apparently its a use case.
I guess I could use `git rev-parse --show-cdup` and that would just
handle this case. But that's YAFAE (Yet Another Fork And Exec).
--
Shawn.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-25 8:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-24 13:40 Problem with git-gui and relative directories David Kastrup
2007-08-25 3:18 ` Shawn O. Pearce
2007-08-25 7:26 ` David Kastrup
2007-08-25 8: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).