forked from kollerma/git-submodule-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-rpush
executable file
·53 lines (46 loc) · 1.52 KB
/
git-rpush
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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
## from the git mailinglist:
function git
{
LC_MESSAGES=C command git "$@"
}
export git
## 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 "$@"