Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 57 lines (49 sloc) 1.261 kB
#!/bin/bash -e
## Check for non-tracking branches not fully merged to HEAD.
## if argument -p is given: does not exit with a failure
## read input, display help if necessary
if [[ "$@" == *--help* ]]; then
cat<<EOF
Check for any non-tracking branches
This command checks for non-tracking branches that are not fully
merged to a tracking branch. This is part of a series of checks
used to determine whether it is safe to remove a submodule.
Usage:
git check-non-tracking [-p]
-p: do not raise an error
EOF
exit 0;
fi
while getopts ":p" opt; do
case $opt in
p)
p=1
#echo "-p was triggered!" >&2
;;
\?)
# ignore this
#echo "Invalid option: -$OPTARG" >&2
;;
esac
done
## cycle all branches
tmp=`git branch -vv --no-color --no-merged 2> /dev/null`
if [[ "$tmp" ]]; then
while read line; do
##echo "$line"
branch=`expr "$line" : '\** *\([^ ]*\)'`
##echo "$branch"
remote=`expr "$line" : '.*\[\(.*\)\]'` && continue
nontracking="$nontracking $branch is not a remote tracking branch and is not fully merged to HEAD.
"
done <<< "$tmp"
fi
if [ "$nontracking" ]; then
if [[ $p -ne 1 ]]; then
echo >&2 -n "Error in $PWD:
$nontracking"
exit 1
fi
echo -n "In $PWD:
$nontracking"
fi
Jump to Line
Something went wrong with that request. Please try again.