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

Link to this type

comparison_result()
comparison_result() :: :lt | :eq | :gt

Comparison result.

Link to this section Functions

Link to this function

compare(path1, mode1, path2, mode2)
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 if path1 sorts before path2.
  • :eq if they are the same.
  • :gt if path1 sorts after path2.
Link to this function

compare_same_name(path1, path2, mode2)
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.

Link to this function

strip_trailing_separator(path)
strip_trailing_separator(path :: charlist()) :: charlist()

Remove trailing / if present.