File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ package mirror
22
33import (
44 "context"
5+ "crypto/sha256"
56 "fmt"
67 "log/slog"
78 "path/filepath"
89 "slices"
9- "strings"
1010)
1111
1212type WorkTreeLink struct {
@@ -32,9 +32,11 @@ func (wt *WorkTreeLink) Equals(wtc WorktreeConfig) bool {
3232// worktreeDirName will generate worktree name for specific worktree link
3333// two worktree links can be on same ref but with diff pathspecs
3434// hence we cant just use tree hash as path
35+ // 2 diff worktree links can have same basename hence also including hash of absolute link path
3536func (w * WorkTreeLink ) worktreeDirName (hash string ) string {
36- parts := strings .Split (strings .Trim (w .linkAbs , "/" ), "/" )
37- return parts [len (parts )- 1 ] + "-" + hash [:7 ]
37+ linkHash := fmt .Sprintf ("%x" , sha256 .Sum256 ([]byte (w .linkAbs )))
38+ base := filepath .Base (w .linkAbs )
39+ return base + "_" + linkHash [:7 ] + "-" + hash [:7 ]
3840}
3941
4042// currentWorktree reads symlink path of the given worktree link
You can’t perform that action at this time.
0 commit comments