git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: "Rémi Rampin" <remirampin@gmail.com>,
	"Pat Thoyts" <patthoyts@users.sourceforge.net>
Cc: GIT <git@vger.kernel.org>
Subject: Re: [git-gui] bug report: "Open existing repository" dialog fails on submodules
Date: Mon, 2 Feb 2015 21:43:08 +1300	[thread overview]
Message-ID: <CAFOYHZAz9LOsAG53GbxQtb3Hp4d_zMFCKbp_Z5NViwCCm+cLAg@mail.gmail.com> (raw)
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:
> 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.

  reply	other threads:[~2015-02-02  8:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 21:46 [git-gui] bug report: "Open existing repository" dialog fails on submodules Rémi Rampin
2015-02-02  8:41 ` Chris Packham
2015-02-02  8:43   ` Chris Packham [this message]
2015-02-02 15:59   ` Rémi Rampin
2015-02-02 17:24     ` [PATCH 1/2] Fixes _is_git Remi Rampin
2015-02-02 17:24       ` [PATCH 2/2] Makes _do_open2 set _gitdir to actual path Remi Rampin
2015-02-03  8:51         ` Chris Packham
2015-02-03 16:00           ` Rémi Rampin
2015-02-03  8:44       ` [PATCH 1/2] Fixes _is_git Chris Packham
2015-02-03 15:52         ` Rémi Rampin
2015-02-05  8:13           ` Chris Packham
2015-02-05 16:20     ` [PATCH 0/2] gitfile support git git-gui Remi Rampin
2015-02-05 16:20       ` [PATCH 1/2] Fixes chooser not accepting gitfiles Remi Rampin
2015-02-05 16:20       ` [PATCH 2/2] Makes chooser set 'gitdir' to the resolved path Remi Rampin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFOYHZAz9LOsAG53GbxQtb3Hp4d_zMFCKbp_Z5NViwCCm+cLAg@mail.gmail.com \
    --to=judge.packham@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=patthoyts@users.sourceforge.net \
    --cc=remirampin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).