Browse Source

[sde-update-tree] Enhanced to try to detect a branch for rebasing if none set

karasz/new-early
Alejandro Mery 16 years ago
parent
commit
bed86172c8
1 changed files with 44 additions and 1 deletions
  1. +44
    -1
      bin/sde-update-tree

+ 44
- 1
bin/sde-update-tree

@ -62,6 +62,49 @@ cd "$SDEROOT"
tree="${SDEROOT##*/}"
update_git()
{
local branch=$( git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||' )
local remote=$( git config branch.$branch.remote )
local remote_list=$( git remote )
local remote_branch= remote_branch_list=
if [ -z "$remote_list" ]; then
echo "no remotes set"
return 0
elif [ -n "$remote" -a -z "$( echo "$remote_list" | grep "^$remote\$" )" ]; then
echo "$remote: what?! remote is gone!"
return 1
elif [ -z "$remote" ]; then
# uhm, get a good remote
if [ "$( echo "$remote_list" | grep "^origin$" )" ]; then
remote=origin
else
remote="$( echo "$remote_list" | head -n 1 )"
fi
# and it's list of branches
remote_branch_list=$( git branch -r | sed -n -e "s|^ $remote/||p" | grep -v '^HEAD$' )
if [ -z "$remote_branch_list" ]; then
echo "no remote set, and couldn't guess".
return 1
elif [ "$( echo "$remote_branch_list" | grep "^$branch$" )" ]; then
remote_branch="$branch"
elif [ "$( echo "$remote_branch_list" | grep "^master$" )" ]; then
remote_branch=master
else
remote_branch="$( echo "$remote_branch_list" | head -n 1 )"
fi
echo "no remote set, assuming $remote/$remote_branch."
git config branch.$branch.remote "$remote"
git config branch.$branch.merge "refs/heads/$remote_branch"
fi
git reset && git pull --rebase
}
# hunt for the roots of the sub-working trees
#
for x in . package $( ls -1d package/* target/* 2> /dev/null ); do
@ -81,7 +124,7 @@ for x in . package $( ls -1d package/* target/* 2> /dev/null ); do
elif [ -d "$x/.git" ]; then
cd "$x";
echo "$tree/$x:"
( git reset && git pull --rebase ) 2>&1 | indent_output
update_git 2>&1 | indent_output
cd - > /dev/null
elif [ -d "$x/.svn" ]; then
cd "$x";

Loading…
Cancel
Save