Skip to content

Commit

Permalink
Merge pull request #2549 from carapace-sh/git-eval-symlink
Browse files Browse the repository at this point in the history
git: ActionChanges - evaluate symlinks before generating relative paths
  • Loading branch information
rsteube authored Oct 13, 2024
2 parents 7b571b1 + f19d12b commit eb3fdba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/actions/tools/git/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ func ActionChanges(opts ChangeOpts) carapace.Action {
if splitted := strings.SplitN(path, " -> ", 2); len(splitted) > 1 { // renamed
path = splitted[1]
}
if relativePath, err := filepath.Rel(c.Dir, root+"/"+path); err != nil {

evaluatedDir, err := filepath.EvalSymlinks(c.Dir)
if err != nil {
return carapace.ActionMessage(err.Error())
}
if relativePath, err := filepath.Rel(evaluatedDir, root+"/"+path); err != nil {
return carapace.ActionMessage(err.Error())
} else {
if status := line[:2]; strings.Contains(status, "D") { // deleted
Expand Down

0 comments on commit eb3fdba

Please sign in to comment.