Meta/pushall: make it safer to rewind next
Junio C Hamano committed
Dec 15, 2014 at 12:41 UTC
cf7ee947c35ca502b35d1947db883fed6f6ab6a0
1 file changed
+30
-16
pushall
+30
-16
@@ -1,26 +1,40 @@
1
#!/bin/sh
2
3
sites='ko repo github2 sfjp sf.net gph '
4
+nexts='ko repo gph github2'
5
5
-while :
6
-do
7
- failed=
8
- for remote in $sites
6
+push_retry () {
7
+ sites=$1
8
+ shift
9
+ while :
10
do
10
- printf "%s: " "$remote"
11
- git push --follow-tags "$remote" "$@" || failed="$failed$remote "
11
+ failed=
12
+ for remote in $sites
13
+ do
14
+ printf "%s: " "$remote"
15
+ git push --follow-tags "$remote" "$@" || failed="$failed$remote "
16
+ done
17
+
18
+ if test -z "$failed"
19
+ then
20
+ break
21
+ elif test "x$sites" = "x$failed"
22
+ then
23
+ echo >&2 "Failed to push to: $sites"
24
+ exit 1
25
+ fi
26
+ sites="$failed"
27
done
28
+}
29
+
30
+case " $* " in
31
+*' +next '*)
32
+ push_retry "$nexts" "$@"
33
+ exit $?
34
+ ;;
35
+esac
36
14
- if test -z "$failed"
15
- then
16
- break
17
- elif test "x$sites" = "x$failed"
18
- then
19
- echo >&2 "Failed to push to: $sites"
20
- exit 1
21
- fi
22
- sites="$failed"
23
-done
37
+push_retry "$sites" "$@"
38
39
case "$#,$*" in
40
0,* | 1,-n)