]> Cypherpunks repositories - gostls13.git/commit
os: drop unnecessary trailing . from symlink targets
authorDamien Neil <dneil@google.com>
Thu, 21 Nov 2024 17:20:46 +0000 (09:20 -0800)
committerDamien Neil <dneil@google.com>
Thu, 21 Nov 2024 22:25:09 +0000 (22:25 +0000)
commit83e6781cb75f9470430fd40c9751e846b998a49e
tree4941cc922ecd3007fccf50b3e1edbfddaeca2590
parenta925402b62c06d1cfe2b345cba0b11fa06b8401d
os: drop unnecessary trailing . from symlink targets

Adjust splitPathInRoot to match its documented behavior
of dropping . path components except at the end of the path.
This function takes a prefix, path, and suffix; previously
it would preserve a trailing . at the end of the path
even when joining to a suffix.

The practical effect of this change is that we we'll skip
a pointless open of . when following a symlink under some
circumstances:

  - open "a/target"
  - "a" is a symlink to "b/."
  - previously: we rewrite our path to "b/./target"
  - now: we rewrite our path to "b/target"

This is a fairly unimportant edge case, and our observable
behavior isn't changing. The main motivation for this change is
that the overall behavior is more comprehensible if splitPathInRoot
follows its documentation.

Change-Id: I96c6a5e3f489cdac991ba1bd702180d69625bc64
Reviewed-on: https://go-review.googlesource.com/c/go/+/630615
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/os/root.go
src/os/root_test.go