Re: [git-gui] bug report: "Open existing repository" dialog fails on submodules
Hi,
On Sat, Jan 31, 2015 at 10:46 AM, Rémi Rampin <remirampin@gmail.com> wrote:
Show 16 quoted lines
> Hi,
>
> This bug report concerns git-gui. Apologies if this is not the right
> mailing-list.
>
> By submodule I mean a repository for which .git is not a regular Git
> directory, but rather a "gitdir: ..." file.
> While running "git gui" from such a directory will work fine, trying
> to open it from the choose_repository window will fail with "Not a Git
> repository". This is because of the simplistic implementation of proc
> _is_git in lib/choose_repository.tcl.
>
> I suggest fixing that function, or using Git directly to perform that
> check, for instance checking "git rev-parse --show-toplevel". I'd
> attempt a patch but my tcl-fu is weak.
>
I would have thought the following would work
--- 8< ---
Subject: [PATCH] git-gui: use git rev-parse to validate paths
The current _is_git function to validate a path as a git repository does not handle a gitfiles which have been used for submodules for some time. Instead of using a custom function let's just ask git rev-parse.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
lib/choose_repository.tcl | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
index 92d6022..944ab50 100644
--- a/lib/choose_repository.tcl
+++ b/lib/choose_repository.tcl
@@ -339,19 +339,12 @@ method _git_init {} {
}
proc _is_git {path} {
- if {[file exists [file join $path HEAD]]
- && [file exists [file join $path objects]]
- && [file exists [file join $path config]]} {
+ puts $path
+ if {[catch {exec git rev-parse --resolve-git-dir $path}]} {
+ return 0
+ } else {
return 1
}
- if {[is_Cygwin]} {
- if {[file exists [file join $path HEAD]]
- && [file exists [file join $path objects.lnk]]
- && [file exists [file join $path config.lnk]]} {
- return 1
- }
- }
- return 0
}
proc _objdir {path} {
--
2.3.0.rc2
--- >8 ---
But it actually looks like git rev-parse --resolve-git-dir $path needs
to be run inside a git repository _any_ git repository, which seems a
bit backwards to me.
$ cd
$ git rev-parse --resolve-git-dir ~/src/git/.git
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
$ cd ~/src/git
$ git rev-parse --resolve-git-dir ~/src/git-gui/.git
/home/chrisp/src/git-gui/.git
So one potential fix git a gui-gui bug, one new(?) bug in git rev-parse.