File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ package mirror
2
2
3
3
import (
4
4
"context"
5
+ "crypto/sha256"
5
6
"fmt"
6
7
"log/slog"
7
8
"path/filepath"
8
9
"slices"
9
- "strings"
10
10
)
11
11
12
12
type WorkTreeLink struct {
@@ -32,9 +32,11 @@ func (wt *WorkTreeLink) Equals(wtc WorktreeConfig) bool {
32
32
// worktreeDirName will generate worktree name for specific worktree link
33
33
// two worktree links can be on same ref but with diff pathspecs
34
34
// 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
35
36
func (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 ]
38
40
}
39
41
40
42
// currentWorktree reads symlink path of the given worktree link
You can’t perform that action at this time.
0 commit comments