1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-19 23:41:31 +01:00
zsh/Functions/VCS_Info/VCS_INFO_bydir_detect

28 lines
827 B
Bash

## vim:ft=zsh
## Written by Frank Terbeck <ft@bewatermyfriend.org>
## Distributed under the same BSD-ish license as zsh itself.
setopt localoptions NO_shwordsplit
local dirname=$1
local basedir="." realbasedir file
realbasedir="$(VCS_INFO_realpath ${basedir})"
while [[ ${realbasedir} != '/' ]]; do
[[ -r ${realbasedir} ]] || return 1
if [[ -n ${vcs_comm[detect_need_file]} ]] ; then
[[ -d ${basedir}/${dirname} ]] && {
for file in ${(s: :)${vcs_comm[detect_need_file]}}; do
[[ -e ${basedir}/${dirname}/${file} ]] && break 2
done
}
else
[[ -d ${basedir}/${dirname} ]] && break
fi
basedir=${basedir}/..
realbasedir="$(VCS_INFO_realpath ${basedir})"
done
[[ ${realbasedir} == "/" ]] && return 1
vcs_comm[basedir]=${realbasedir}
return 0