aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-09-04 12:22:01 +0200
committerGitHub <noreply@github.com>2020-09-04 12:22:01 +0200
commit63d92533b538cb380667deee5dc6d32f0946c737 (patch)
tree6603b432d724b822da25938a1d00369a460518d6 /repository.go
parent6da5e5958ecc0e6f8da6ee2b6714e50b8ef26df4 (diff)
parent70b98de4945f1b6bd0f92be049a36b90a0c23282 (diff)
downloadgo-git-63d92533b538cb380667deee5dc6d32f0946c737.tar.gz
Merge pull request #161 from ashokponkumar/master
PlainOpenWithOptions: support file path
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/repository.go b/repository.go
index 9dd35be..36fc1f5 100644
--- a/repository.go
+++ b/repository.go
@@ -278,6 +278,14 @@ func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem,
if path, err = filepath.Abs(path); err != nil {
return nil, nil, err
}
+
+ pathinfo, err := os.Stat(path)
+ if !os.IsNotExist(err) {
+ if !pathinfo.IsDir() && detect {
+ path = filepath.Dir(path)
+ }
+ }
+
var fs billy.Filesystem
var fi os.FileInfo
for {