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

Re: [PATCH 2/2] Makes _do_open2 set _gitdir to actual path

From
Chris Packham <judge.packham@gmail.com>
Date
Feb 3, 2015, 08:51 UTC
Message-ID
<CAFOYHZB_c3U9jpAq=jrGgMU+wMMf8w5D9iqLC9ccGC8S3hhXZg@mail.gmail.com>
In-Reply-To
<1422897883-11036-2-git-send-email-remirampin@gmail.com>
On Tue, Feb 3, 2015 at 6:24 AM, Remi Rampin <remirampin@gmail.com> wrote:
Show 26 quoted lines
> If _is_git had to follow "gitdir: ..." files to reach the actual Git
> directory, we set _gitdir to that final path.
> ---
>  lib/choose_repository.tcl | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
> index 49ff641..641068d 100644
> --- a/lib/choose_repository.tcl
> +++ b/lib/choose_repository.tcl
> @@ -338,13 +338,17 @@ method _git_init {} {
>         return 1
>  }
>
> -proc _is_git {path} {
> +proc _is_git {path {outdir_var ""}} {
> +       if {$outdir_var ne ""} {
> +               upvar 1 $outdir_var outdir
> +       }
>         if {[file isfile $path]} {
>                 set fp [open $path r]
>                 gets $fp line
>                 close $fp
>                 if {[regexp "^gitdir: (.+)$" $line line link_target]} {
> -                       return [_is_git [file join [file dirname $path] $link_target]]
> +                       set link_target_abs [file join [file dirname $path] $link_target]

At this point link_target_abs is something like sub/../.git/modules/sub. It might be nice to normalize this with 'git rev-parse --git-dir' or even just (cd $link_target_abs && pwd). I'm not sure if tcl has anything built in that could do this kind of normalization.

Show 44 quoted lines
> +                       return [_is_git $link_target_abs outdir]
>                 }
>                 return 0
>         }
> @@ -352,12 +356,14 @@ proc _is_git {path} {
>         if {[file exists [file join $path HEAD]]
>          && [file exists [file join $path objects]]
>          && [file exists [file join $path config]]} {
> +               set outdir $path
>                 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]]} {
> +                       set outdir $path
>                         return 1
>                 }
>         }
> @@ -1103,7 +1109,7 @@ method _open_local_path {} {
>  }
>
>  method _do_open2 {} {
> -       if {![_is_git [file join $local_path .git]]} {
> +       if {![_is_git [file join $local_path .git] actualgit]} {
>                 error_popup [mc "Not a Git repository: %s" [file tail $local_path]]
>                 return
>         }
> @@ -1116,7 +1122,7 @@ method _do_open2 {} {
>         }
>
>         _append_recentrepos [pwd]
> -       set ::_gitdir .git
> +       set ::_gitdir $actualgit
>         set ::_prefix {}
>         set done 1
>  }
> --
> 1.9.5.msysgit.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Remi RampinNext: Rémi Rampin
Message 7 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.