Fail git status if .git not in cwd or parent directory
This commit is contained in:
8
lib/git/helpers.sh
Normal file
8
lib/git/helpers.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
function find_in_cwd_or_parent() {
|
||||
local slashes=${PWD//[^\/]/}; local directory=$PWD;
|
||||
for (( n=${#slashes}; n>0; --n )); do
|
||||
test -e "$directory/$1" && echo "$directory/$1" && return 0
|
||||
directory="$directory/.."
|
||||
done
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user