Skip to content

Commit

Permalink
git: ActionChanges - evaluate symlinks before generating relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Oct 13, 2024
1 parent 7b571b1 commit f19d12b
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 f19d12b

Please sign in to comment.