Skip to content

Commit

Permalink
git-gui: allow opening work trees from the startup dialog
Browse files Browse the repository at this point in the history
In proc _is_git check that supplied path is a valid work tree path.
This allows the choose_repository::pick dialog to accept path to a
work tree directory.

Signed-off-by: Mikhail Terekhov <termim@gmail.com>
  • Loading branch information
termim committed Jun 6, 2020
1 parent c195247 commit c3b378f
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions lib/choose_repository.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -357,31 +357,12 @@ 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 {[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
}
if {[catch {
set outdir [git rev-parse --resolve-git-dir $path]
} ]} {
return 0
}
return 0
return 1
}

proc _objdir {path} {
Expand Down

0 comments on commit c3b378f

Please sign in to comment.