mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-11-03 03:38:18 +00:00
Clean up gitroot
This commit is contained in:
committed by
Wataru Ishida
parent
f2f76ca120
commit
e13ab6ad95
@@ -1,4 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
######################################################################
|
||||||
|
#
|
||||||
|
# gitroot
|
||||||
|
#
|
||||||
|
# Translate $1 or $PWD into the top-level workspace directory
|
||||||
|
# containing .git
|
||||||
|
#
|
||||||
|
######################################################################
|
||||||
|
|
||||||
if test $# -gt 0; then
|
if test $# -gt 0; then
|
||||||
dir=$(realpath $1)
|
dir=$(realpath $1)
|
||||||
@@ -10,5 +19,20 @@ while test $dir != /; do
|
|||||||
echo $dir
|
echo $dir
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
if test -f $dir/.git; then
|
||||||
|
ndir=$(sed -n -e 's/^gitdir: \(.*\)/\1/p' $dir/.git)
|
||||||
|
if test "$ndir"; then
|
||||||
|
ndir=$(cd $dir && cd $ndir && pwd)
|
||||||
|
ndir=${ndir%/.git/*}
|
||||||
|
if test -d "$ndir"; then
|
||||||
|
dir=$ndir
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
dir=${dir%/*}
|
dir=${dir%/*}
|
||||||
done
|
done
|
||||||
|
if test "$dir" = "/"; then
|
||||||
|
echo "*** cannot find git root" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user