Short-circuit path shortening logic when possible
When `os::util::repository_relative_path` is given a path that already
starts with `$OS_ROOT` we can simply truncate the path string to get the
relative path.
@@ -78,10 +78,13 @@ function os::util::repository_relative_path() {
local directory; directory="$( dirname "${filename}" )"
filename="$( basename "${filename}" )"
+ if [[ "${directory}" != "${OS_ROOT}"* ]]; then
pushd "${OS_ORIGINAL_WD}" >/dev/null 2>&1
directory="$( os::util::absolute_path "${directory}" )"
- directory="${directory##*${OS_ROOT}/}"
popd >/dev/null 2>&1
+ fi
+
+ directory="${directory##*${OS_ROOT}/}"
echo "${directory}/${filename}"
}
