@matheusbsbs / matheus-bagliano / commits / ba6c761e62
Fork 0

git-gui: Support cloning Cygwin based work-dirs

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>

Shawn O. Pearce committed Oct 12, 2007 at 16:24 UTC ba6c761e6287f9987d70ed4d2a609a7ed415a6a5
1 file changed +37 -7
lib/choose_repository.tcl
+37 -7
@@ -324,9 +324,42 @@ proc _is_git {path} {
324 && [file exists [file join $path config]]} {
325 return 1
326 }
327 + if {[is_Cygwin]} {
328 + if {[file exists [file join $path HEAD]]
329 + && [file exists [file join $path objects.lnk]]
330 + && [file exists [file join $path config.lnk]]} {
331 + return 1
332 + }
333 + }
334 return 0
335 }
336
337 +proc _objdir {path} {
338 + set objdir [file join $path .git objects]
339 + if {[file isdirectory $objdir]} {
340 + return $objdir
341 + }
342 +
343 + set objdir [file join $path objects]
344 + if {[file isdirectory $objdir]} {
345 + return $objdir
346 + }
347 +
348 + if {[is_Cygwin]} {
349 + set objdir [file join $path .git objects.lnk]
350 + if {[file isfile $objdir]} {
351 + return [win32_read_lnk $objdir]
352 + }
353 +
354 + set objdir [file join $path objects.lnk]
355 + if {[file isfile $objdir]} {
356 + return [win32_read_lnk $objdir]
357 + }
358 + }
359 +
360 + return {}
361 +}
362 +
363 ######################################################################
364 ##
365 ## Create New Repository
@@ -555,13 +588,10 @@ method _do_clone2 {} {
588 }
589
590 if {$clone_type eq {hardlink} || $clone_type eq {shared}} {
558 - set objdir [file join $origin_url .git objects]
559 - if {![file isdirectory $objdir]} {
560 - set objdir [file join $origin_url objects]
561 - if {![file isdirectory $objdir]} {
562 - error_popup [mc "Not a Git repository: %s" [file tail $origin_url]]
563 - return
564 - }
591 + set objdir [_objdir $origin_url]
592 + if {$objdir eq {}} {
593 + error_popup [mc "Not a Git repository: %s" [file tail $origin_url]]
594 + return
595 }
596 }
597