Skip to content

Misleading example in gix_path::normalize #2074

Open
@agashlin

Description

@agashlin

Current behavior 😯

The example given is

this turns a/./b/c/.././.. into a

which suggests that it removes . as well. However it does not affect . (or repeated separators), as the documentation later states; the . is only removed as part of the normalization done by components(). In particular, if there is no .. component, then the original Cow<Path> is returned without having been parsed and re-assembled. So e.g. a/./b is returned unchanged.

Expected behavior 🤔

This confusion should be either avoided or drawn attention to, maybe:

  • don't include an example with .
  • add an explanation like "(. is only incidentally removed because the Path is rewritten)"
  • move the examples after the "Single . components" line
  • include a/./b as an example (maybe after the "Single . components" line)

This is just to help someone else avoid a frustrating misunderstanding due to reading just the example, it is probably clear enough if one reads carefully and understands std::path better than I did.

Git behavior

No response

Steps to reproduce 🕹

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions