Merge branch 'mt/open-worktree'

Clean up the code that checks if a directory is a Git repo. Use git
rev-parse instead of rolling our own logic to find that out. A side
effect (which also happens to be the main motivation behind it) of this
change is that git-gui can now open worktrees other than the main
worktree.

* mt/open-worktree:
  git-gui: allow opening work trees from the startup dialog
This commit is contained in:
Pratyush Yadav 2020-06-22 20:23:28 +05:30
commit 469725c1a3
1 changed files with 3 additions and 24 deletions

View File

@ -357,31 +357,10 @@ 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]} {
set path [file join [file dirname $path] $link_target]
set path [file normalize $path]
}
if {[catch {set outdir [git rev-parse --resolve-git-dir $path]}]} {
return 0
}
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
}
}
return 0
return 1
}
proc _objdir {path} {