Skip to content

Commit

Permalink
fix: Detect absolute paths in externals on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Feb 26, 2023
1 parent aa21a31 commit 592df36
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/chezmoi/sourcestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ func (s *SourceState) addExternal(sourceAbsPath AbsPath) error {
s.Lock()
defer s.Unlock()
for path, external := range externals {
if filepath.IsAbs(path) {
if strings.HasPrefix(path, "/") || filepath.IsAbs(path) {
return fmt.Errorf("%s: %s: path is not relative", sourceAbsPath, path)
}
targetRelPath := parentTargetSourceRelPath.JoinString(path)
Expand Down
2 changes: 0 additions & 2 deletions pkg/cmd/testdata/scripts/issue2302.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[windows] skip 'UNIX only'

# test that chezmoi does not panic if an external uses an absolute path
! exec chezmoi diff
stderr 'path is not relative'
Expand Down

0 comments on commit 592df36

Please sign in to comment.