Skip to content

Commit

Permalink
git-gui: Support cloning Cygwin based work-dirs
Browse files Browse the repository at this point in the history
If the user tries to clone a Git repository that is actually a
workdir of another repository (by way of contrib git-new-workdir)
then the contents of .git is a series of Windows .lnk files which
Tcl can't read if this is a native Tcl process.  To read the real
objects directory we need to resolve the link to that location.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Shawn O. Pearce committed Oct 13, 2007
1 parent 51a41ac commit ba6c761
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions lib/choose_repository.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,42 @@ proc _is_git {path} {
&& [file exists [file join $path config]]} {
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} {
set objdir [file join $path .git objects]
if {[file isdirectory $objdir]} {
return $objdir
}

set objdir [file join $path objects]
if {[file isdirectory $objdir]} {
return $objdir
}

if {[is_Cygwin]} {
set objdir [file join $path .git objects.lnk]
if {[file isfile $objdir]} {
return [win32_read_lnk $objdir]
}

set objdir [file join $path objects.lnk]
if {[file isfile $objdir]} {
return [win32_read_lnk $objdir]
}
}

return {}
}

######################################################################
##
## Create New Repository
Expand Down Expand Up @@ -555,13 +588,10 @@ method _do_clone2 {} {
}

if {$clone_type eq {hardlink} || $clone_type eq {shared}} {
set objdir [file join $origin_url .git objects]
if {![file isdirectory $objdir]} {
set objdir [file join $origin_url objects]
if {![file isdirectory $objdir]} {
error_popup [mc "Not a Git repository: %s" [file tail $origin_url]]
return
}
set objdir [_objdir $origin_url]
if {$objdir eq {}} {
error_popup [mc "Not a Git repository: %s" [file tail $origin_url]]
return
}
}

Expand Down

0 comments on commit ba6c761

Please sign in to comment.