Skip to content

Commit 469725c

Browse files
committed
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
2 parents c195247 + a747395 commit 469725c

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

lib/choose_repository.tcl

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -357,31 +357,10 @@ proc _is_git {path {outdir_var ""}} {
357357
if {$outdir_var ne ""} {
358358
upvar 1 $outdir_var outdir
359359
}
360-
if {[file isfile $path]} {
361-
set fp [open $path r]
362-
gets $fp line
363-
close $fp
364-
if {[regexp "^gitdir: (.+)$" $line line link_target]} {
365-
set path [file join [file dirname $path] $link_target]
366-
set path [file normalize $path]
367-
}
368-
}
369-
370-
if {[file exists [file join $path HEAD]]
371-
&& [file exists [file join $path objects]]
372-
&& [file exists [file join $path config]]} {
373-
set outdir $path
374-
return 1
375-
}
376-
if {[is_Cygwin]} {
377-
if {[file exists [file join $path HEAD]]
378-
&& [file exists [file join $path objects.lnk]]
379-
&& [file exists [file join $path config.lnk]]} {
380-
set outdir $path
381-
return 1
382-
}
360+
if {[catch {set outdir [git rev-parse --resolve-git-dir $path]}]} {
361+
return 0
383362
}
384-
return 0
363+
return 1
385364
}
386365

387366
proc _objdir {path} {

0 commit comments

Comments
 (0)