mirror of
https://gitlab.com/xonotic/xonotic
synced 2025-01-18 20:21:18 +00:00
./all branches: more concise display; ./all clean: allow resetting the repo into pristine state (-m -fu -r -D, meaning "master, force upstream, remove untracked, delete other branches")
This commit is contained in:
parent
9a4a45b283
commit
8fa18b2570
103
all
103
all
@ -438,26 +438,15 @@ case "$cmd" in
|
||||
branches)
|
||||
for d in $repos; do
|
||||
cd "$d0/$d" # am in a pipe, shouldn't use enter
|
||||
git branch -a -v -v | cut -c 3- | sed "s/^(no branch)/(no_branch)/" | sed "s,^,$d ,"
|
||||
git branch -r -v -v | cut -c 3- | sed "s/^(no branch)/(no_branch)/" | sed "s,^,$d ,"
|
||||
cd "$d0"
|
||||
done | {
|
||||
branches_list=
|
||||
# branches_repos_*=
|
||||
while read -r d BRANCH REV UPSTREAM TEXT; do
|
||||
while read -r d BRANCH REV TEXT; do
|
||||
if [ x"$BRANCH" = x"`repobranch "$d"`" ]; then
|
||||
continue
|
||||
fi
|
||||
case "$UPSTREAM" in
|
||||
\[*)
|
||||
UPSTREAM=${UPSTREAM#\[}
|
||||
UPSTREAM=${UPSTREAM%\]}
|
||||
UPSTREAM=${UPSTREAM%:*}
|
||||
;;
|
||||
*)
|
||||
TEXT="$UPSTREAM $TEXT"
|
||||
UPSTREAM=
|
||||
;;
|
||||
esac
|
||||
if [ x"$REV" = x"->" ]; then
|
||||
continue
|
||||
fi
|
||||
@ -465,14 +454,7 @@ case "$cmd" in
|
||||
ID=`echo "$BRANCH" | tr -c "A-Za-z0-9." "_"`
|
||||
branches_list="$branches_list $BRANCH" # TEH SORT MAKEZ IT UNIEQ
|
||||
eval "r=\$branches_repos_$ID"
|
||||
case "$UPSTREAM" in
|
||||
'')
|
||||
r="$r $d"
|
||||
;;
|
||||
*)
|
||||
r="$r $d:$UPSTREAM"
|
||||
;;
|
||||
esac
|
||||
r="$r $d"
|
||||
eval "branches_repos_$ID=\$r"
|
||||
done
|
||||
echo -n "$branches_list" | xargs -n 1 echo | sort -u | while IFS= read -r BRANCH; do
|
||||
@ -912,23 +894,76 @@ case "$cmd" in
|
||||
;;
|
||||
clean)
|
||||
force=false
|
||||
if [ x"$1" = x"-f" ]; then
|
||||
force=true
|
||||
fi
|
||||
gotoupstream=false
|
||||
gotomaster=false
|
||||
rmuntracked=false
|
||||
killbranches=false
|
||||
# usage:
|
||||
# ./all clean [-m] [-f | -fu] [-r] [-D]
|
||||
while :; do
|
||||
if [ x"$1" = x"-f" ]; then
|
||||
force=true
|
||||
elif [ x"$1" = x"-u" ]; then
|
||||
gotoupstream=true
|
||||
elif [ x"$1" = x"-fu" ]; then
|
||||
force=true
|
||||
gotoupstream=true
|
||||
elif [ x"$1" = x"-m" ]; then
|
||||
gotomaster=true
|
||||
elif [ x"$1" = x"-r" ]; then
|
||||
rmuntracked=true
|
||||
elif [ x"$1" = x"-D" ]; then
|
||||
killbranches=true
|
||||
else
|
||||
break
|
||||
fi
|
||||
shift
|
||||
done
|
||||
for d in $repos; do
|
||||
verbose cd "$d0/$d"
|
||||
if $force; then
|
||||
if $gotoupstream; then
|
||||
if ! $force; then
|
||||
msg "Must also use -f (delete local changes) when using -u"
|
||||
exit 1
|
||||
fi
|
||||
if $gotomaster; then
|
||||
verbose git checkout -f "`repobranch "$d"`"
|
||||
git reset --hard origin/"`repobranch "$d"`"
|
||||
else
|
||||
r=`git symbolic-ref HEAD`
|
||||
r=${r#refs/heads/}
|
||||
rem=`git config "branch.$r.remote" || echo origin`
|
||||
bra=`git config "branch.$r.merge" || echo "$r"`
|
||||
upstream="$rem/${bra#refs/heads/}"
|
||||
if ! git rev-parse "$upstream" >/dev/null 2>&1; then
|
||||
upstream="origin/`repobranch "$d"`"
|
||||
fi
|
||||
verbose git reset --hard "$upstream"
|
||||
fi
|
||||
elif $gotomaster; then
|
||||
if $force; then
|
||||
verbose git checkout -f "`repobranch "$d"`"
|
||||
else
|
||||
verbose git checkout "`repobranch "$d"`"
|
||||
fi
|
||||
elif $force; then
|
||||
verbose git reset --hard
|
||||
#redundant# verbose git checkout-index -fa
|
||||
fi
|
||||
case "$d" in
|
||||
.)
|
||||
verbose git clean -df
|
||||
;;
|
||||
*)
|
||||
verbose git clean -xdf
|
||||
;;
|
||||
esac
|
||||
if $rmuntracked; then
|
||||
case "$d" in
|
||||
.)
|
||||
verbose git clean -df
|
||||
;;
|
||||
*)
|
||||
verbose git clean -xdf
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if $killbranches; then
|
||||
git for-each-ref --format='%(refname)' refs/heads/ | while IFS= read -r B; do
|
||||
git branch -D "${B#refs/heads/}" 2>/dev/null
|
||||
done
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user