aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-07-08 12:34:25 +0100
committerGitHub <noreply@github.com>2023-07-08 12:34:25 +0100
commitdc17aae6503560777a665c9cfb0d2fcb3a9a9274 (patch)
treed7235df1afd2959f3fb5e9dc122424887b620bbc /repository.go
parent7e143ceb36ed6d46462f3c37f07993f9a10f91e3 (diff)
parenta9a658ee4ecb0c2f0fcb1962b7c6a408a8116309 (diff)
downloadgo-git-dc17aae6503560777a665c9cfb0d2fcb3a9a9274.tar.gz
Merge pull request #808 from ricci2511/plainopen-tilde-path-fix
*: Handle paths starting with tilde
Diffstat (limited to 'repository.go')
-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