git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [git-gui] bug report: "Open existing repository" dialog fails on submodules

From
Chris Packham <judge.packham@gmail.com>
Date
Feb 2, 2015, 08:43 UTC
Message-ID
<CAFOYHZAz9LOsAG53GbxQtb3Hp4d_zMFCKbp_Z5NViwCCm+cLAg@mail.gmail.com>
In-Reply-To
<CAFOYHZBpVf0Dk=aM3hbpVjwc-f_WtZx+Myaja6=V2KXCDijsQA@mail.gmail.com>
On Mon, Feb 2, 2015 at 9:41 PM, Chris Packham <judge.packham@gmail.com> wrote:
Show 80 quoted lines
> Hi,
>
> On Sat, Jan 31, 2015 at 10:46 AM, Rémi Rampin <remirampin@gmail.com> wrote:
>> 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.
Not a new one. Happens in 1.9.1. Still a bit counter-intuitive IMO.
Previous: Chris PackhamNext: Rémi Rampin
Message 3 of 14 in “[git-gui] bug report: "Open existing repository" dialog fails on submodules”
  1. Rémi RampinJan 30, 2015
  2. Chris PackhamFeb 2, 2015
  3. Chris PackhamFeb 2, 2015
  4. Rémi RampinFeb 2, 2015
  5. 1/2 Fixes _is_gitRemi Rampin, Feb 2, 2015
  6. 2/2 Makes _do_open2 set _gitdir to actual pathRemi Rampin, Feb 2, 2015
  7. Chris PackhamFeb 3, 2015
  8. Rémi RampinFeb 3, 2015
  9. Chris PackhamFeb 3, 2015
  10. Rémi RampinFeb 3, 2015
  11. Chris PackhamFeb 5, 2015
  12. 0/2 gitfile support git git-guiRemi Rampin, Feb 5, 2015
  13. 1/2 Fixes chooser not accepting gitfilesRemi Rampin, Feb 5, 2015
  14. 2/2 Makes chooser set 'gitdir' to the resolved pathRemi Rampin, Feb 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.