aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorricci2511 <ricardo.christmann@protonmail.com>2023-07-06 18:18:38 +0200
committerricci2511 <ricardo.christmann@protonmail.com>2023-07-06 18:18:38 +0200
commit252b5d240274e99eec8a63e4906b54f097c5f693 (patch)
treebe5bda085efb8ac92ec7721996525a44d855686a
parentdd4e2b7f4b01e2aaafcf182d2884a186a6f37d21 (diff)
downloadgo-git-252b5d240274e99eec8a63e4906b54f097c5f693.tar.gz
*: Handle paths starting with tilde
-rw-r--r--repository.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/repository.go b/repository.go
index dd822a5..168303f 100644
--- a/repository.go
+++ b/repository.go
@@ -322,8 +322,16 @@ func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error)
}
func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem, err error) {
- if path, err = filepath.Abs(path); err != nil {
- return nil, nil, err
+ if strings.HasPrefix(path, "~/") {
+ home, err := os.UserHomeDir()
+ if err != nil {
+ return nil, nil, err
+ }
+ path = filepath.Join(home, path[2:])
+ } else {
+ if path, err = filepath.Abs(path); err != nil {
+ return nil, nil, err
+ }
}
var fs billy.Filesystem