summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xswitch_all_submodules_to_head_and_clean19
1 files changed, 14 insertions, 5 deletions
diff --git a/switch_all_submodules_to_head_and_clean b/switch_all_submodules_to_head_and_clean
index 2c136fd..661ff8d 100755
--- a/switch_all_submodules_to_head_and_clean
+++ b/switch_all_submodules_to_head_and_clean
@@ -33,7 +33,7 @@ if [[ -z "$remote" ]]; then
fi
# get git user
-echobd "Preparing $(git rev-parse --show-toplevel | xargs -r basename) $branch branch for development use"
+echobd "Preparing $(git rev-parse --show-toplevel | xargs -r basename) on $branch branch for development use"
if [[ $1 == "" ]]; then
gituser=`git config --local remote.$remote.url | sed -n "s|\(https\?://\)\?\([^@]*\)@.*|\2|p" | grep -v "\(anonymous\|system\)"`
else
@@ -48,6 +48,10 @@ if [[ $gituser == "" ]]; then
gituser="anonymous"
fi
+if [[ -n "$(git config --get user.signingkey)" ]]; then
+ GIT_SIGN="-S"
+fi
+
# check git abilities
if [[ -n "`git status --help 2>/dev/null|grep -- '--ignore-submodules'`" ]]; then
GIT_IGNORE_SUBMODULES="--ignore-submodules"
@@ -76,9 +80,13 @@ updateModule() {
fi
git remote |
while read REMOTE; do
- REPO_SERVER=$(git config remote."$REMOTE".url |
+ REPO_URL=$(git config remote."$REMOTE".url)
+ REPO_SERVER=$(echo "$REPO_URL" |
sed -n "s|^http[^/]*/*\([^@]*@\)\?\([^/]*\)/.*|\2|p")
- if [ -x /usr/bin/fping ] && [ -n "$REPO_SERVER" ]; then
+ if [ -x /usr/bin/curl ] && [ "${REPO_URL}" != "${REPO_URL#http}" ]; then
+ curl --silent --connect-timeout 10 --max-time 15 --location --netrc \
+ $REPO_URL/info/refs?service=git-upload-pack >/dev/null || continue
+ elif [ -x /usr/bin/fping ] && [ -n "$REPO_SERVER" ]; then
fping -q -r1 "$REPO_SERVER" || continue
fi
echo Fetching $REMOTE
@@ -88,7 +96,7 @@ updateModule() {
git checkout $branch
remote=`git config branch."$branch".remote`
[[ -n "$remote" ]] || return
- git rebase $remote/$branch $branch
+ git rebase $GIT_SIGN $remote/$branch $branch
if [[ ! -z "`git status --porcelain $GIT_IGNORE_SUBMODULES`" ]]; then
git reset --hard HEAD
git clean -dxff
@@ -135,8 +143,9 @@ updateModule() {
cd $REPO_LOCALTREE &&
git fetch &&
git worktree prune &&
- git worktree add $PARENTDIR/$MODULE$submodule $branch &&
+ git worktree add $PARENTDIR/$MODULE$submodule origin/$branch &&
cd $PARENTDIR/$MODULE$submodule &&
+ git checkout $branch &&
git branch --set-upstream-to=origin/$branch
) || continue
fi