Expand description
Git-compatible path normalization and helpers for test-tool path-utils.
Logic matches git/path.c (normalize_path_copy, longest_ancestor_length,
relative_path, strip_path_suffix) and git/remote.c (relative_url).
Enums§
- GitPath
Error - Errors returned by Git-compatible path helper routines.
Functions§
- abspath_
part_ inside_ repo - Git
setup.cabspath_part_inside_repo(POSIX). - cleanup_
path - Git’s
cleanup_pathfrompath.c: strip a single leading./and any directory separators immediately following it. Internal consecutive slashes (e.g.info//sparse-checkout) are deliberately preserved so the result matchesgit rev-parse --git-pathbyte-for-byte. - git_
path_ relative_ component - The relative portion of a
--git-pathargument, mirroring how Git builds the buffer inrepo_git_pathv: the caller-suppliedfmtstring is appended to<git_dir>/verbatim and onlycleanup_pathruns over the whole buffer. In practice that means a single leading/(and a leading./) is dropped from the user-supplied component while internal//runs are kept intact. - is_
absolute_ path_ unix - Whether
pathis an absolute Unix-style path. - longest_
ancestor_ length - Git’s
longest_ancestor_length- normalizespathand each colon-separated prefix. - normalize_
path_ copy - Purely textual path normalization matching Git’s
normalize_path_copy. ReturnsGitPathError::EscapesRootwhen..would escape above the root (Git returns -1). - path_
for_ disk_ compare - Canonicalize a path for on-disk comparison (macOS
/privatealiasing). - prefix_
path_ gently - Git
setup.cprefix_path_gently(POSIX). - real_
path_ resolving - Like Git’s
strbuf_realpath/test-tool path-utils real_path: resolve symlinks by walking path components (so symlink targets are interpreted at each step), then if the leaf is missing, resolve the longest existing prefix and append the remainder. - relative_
path - Git’s
relative_pathfrompath.c(POSIX subset). - relative_
url - Git’s
relative_urlfromremote.c(POSIX; no DOS drive handling). - strip_
path_ suffix - Git’s
stripped_path_suffix_offset/strip_path_suffix.