fix: `treefmt .` no longer segfaults if `.` is root and symlink by jfly · Pull Request #595 · numtide/treefmt

@jfly

In short, the old code would massage the given paths to relative paths
(in the `resolvePaths` function I removed). It operated under an
impossible-to-satisfy requirement: to return relative paths that when
joined with the project root would create paths to regular files/folders
(*not* symlinks). This is possible for all paths except `.`: if your
project root is a symlink, then `join(root, ".") == root`, which is
still a symlink.

Rather than try to fix that flawed assumption, I opted to refactor
things. I think that was the right call: excluding the tests I added,
this is a net reduction in code!

Basically, I moved moved `resolvePath` into `walk.go`, and interleaved
the remaining `resolvePaths` logic into `walk.go::NewCompositeReader`.
A happy side effect of this is that we no longer have 2 functions with very similar names
(`resolvePaths` and `resolvePath`) that do different things.

This fixes numtide#594