Xgit v0.1.1 Xgit.Util.Paths
Utility functions for comparing paths inside of a git repository.
Link to this section Summary
Types
Comparison result.
Functions
Compare two paths according to git path sort ordering rules.
Compare two paths, checking for identical name.
Remove trailing /
if present.
Link to this section Types
comparison_result()
comparison_result() :: :lt | :eq | :gt
comparison_result() :: :lt | :eq | :gt
Comparison result.
Link to this section Functions
compare(path1, mode1, path2, mode2)
compare(
path1 :: charlist(),
mode1 :: Xgit.Core.FileMode.t(),
path2 :: charlist(),
mode2 :: Xgit.Core.FileMode.t()
) :: comparison_result()
compare( path1 :: charlist(), mode1 :: Xgit.Core.FileMode.t(), path2 :: charlist(), mode2 :: Xgit.Core.FileMode.t() ) :: comparison_result()
Compare two paths according to git path sort ordering rules.
Return Value
:lt
ifpath1
sorts beforepath2
.:eq
if they are the same.:gt
ifpath1
sorts afterpath2
.
compare_same_name(path1, path2, mode2)
compare_same_name(
path1 :: charlist(),
path2 :: charlist(),
mode2 :: Xgit.Core.FileMode.t()
) :: comparison_result()
compare_same_name( path1 :: charlist(), path2 :: charlist(), mode2 :: Xgit.Core.FileMode.t() ) :: comparison_result()
Compare two paths, checking for identical name.
Unlike compare/4
, this method returns :eq
when the paths have
the same characters in their names, even if the mode differs. It is
intended for use in validation routines detecting duplicate entries.
Parameters
mode2
is the mode of the second file. Trees are sorted as though
List.last(path2) == ?/
, even if no such character exists.
Return :lt
if no duplicate name could exist; :eq
if the paths
have the same name; :gt
if other path2
should still be checked
by caller.
Return Value
Returns :eq
if the names are identical and a conflict exists
between path1
and path2
, as they share the same name.
Returns :lt
if all possible occurrences of path1
sort
before path2
and no conflict can happen. In a properly sorted
tree there are no other occurrences of path1
and therefore there
are no duplicate names.
Returns :gt
when it is possible for a duplicate occurrence of
path1
to appear later, after path2
. Callers should
continue to examine candidates for path2
until the method returns
one of the other return values.
strip_trailing_separator(path)
Remove trailing /
if present.