aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorArieh Schneier <15041913+AriehSchneier@users.noreply.github.com>2023-07-09 17:08:04 +1000
committerArieh Schneier <15041913+AriehSchneier@users.noreply.github.com>2023-07-09 17:08:04 +1000
commit5dad9b23030e344a4fd1458df0c50e6ada55a01a (patch)
tree3049fbf24af25a3e52bf7a391e959e837e032e3a /repository.go
parentdc17aae6503560777a665c9cfb0d2fcb3a9a9274 (diff)
downloadgo-git-5dad9b23030e344a4fd1458df0c50e6ada55a01a.tar.gz
*: Handle paths starting with ~username
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/repository.go b/repository.go
index 168303f..02edb66 100644
--- a/repository.go
+++ b/repository.go
@@ -19,6 +19,7 @@ import (
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-billy/v5/util"
"github.com/go-git/go-git/v5/config"
+ "github.com/go-git/go-git/v5/internal/path_util"
"github.com/go-git/go-git/v5/internal/revision"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/cache"
@@ -322,16 +323,13 @@ func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error)
}
func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem, err error) {
- 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
- }
+ path, err = path_util.ReplaceTildeWithHome(path)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ if path, err = filepath.Abs(path); err != nil {
+ return nil, nil, err
}
var fs billy.Filesystem