Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 47 lines (40 sloc) 1.43 KB
#!/bin/bash -e
## Do a recursive push
## accepts the same argumenta as push
## read input, display help if necessary
if [[ "$@" == *--help* ]]; then
cat<<EOF
Recursive push
This command executes git-cpush recursively. It starts with
the innermost submodules and then works its way back. Only accepts
two levels of submodules. The push is only executed if all
submodules are on remote-tracking branches.
Usage:
git rpush ...
...: same arguments as git-push
EOF
exit 0;
fi
## check for modified content and uncommitted changes
git check-clean --ignore-submodules=untracked --unstaged --uncommitted --unmerged || exit 1
## check for untracked files
if ! git check-clean --untracked --unstaged --exit-code; then
cat >&2 <<EOF
Warning: Untracked files in submodules. Add them to .gitignore
in the respective submodules or remove them.
Use "git status" to see where they are.
Continuing anyway...
EOF
fi
## check for non remote tracking branches and fail
## TODO: if not --all
if [ -f $(git rev-parse --show-toplevel)/.gitmodules ]; then
#git submodule --quiet foreach --recursive "git check-branch" || exit 1
git submodule --quiet foreach --recursive 'echo "$toplevel/$path"' |
xargs -r -n1 -P5 bash -c 'cd "$1"; git check-branch' xargs || exit 1
fi
## TODO: check for unpulled changes: fetch, then check
# git fetch -q
# git submodule --quiet foreach --recursive "git fetch -q"
## push super rep.
git cpush -q "$@"