Merge branches 'jc/sb' and 'jc/mb'
[git/gitweb.git] / git-push.sh
blobedc0b8317a6d566895c4a2df6a3f7d86773ca138
1 #!/bin/sh
2 . git-sh-setup || die "Not a git archive"
4 usage () {
5 die "Usage: git push [--all] [--force] <repository> [<refspec>]"
9 # Parse out parameters and then stop at remote, so that we can
10 # translate it using .git/branches information
11 has_all=
12 has_force=
13 has_exec=
14 remote=
16 while case "$#" in 0) break ;; esac
18 case "$1" in
19 --all)
20 has_all=--all ;;
21 --force)
22 has_force=--force ;;
23 --exec=*)
24 has_exec="$1" ;;
25 -*)
26 usage ;;
28 set x "$@"
29 shift
30 break ;;
31 esac
32 shift
33 done
34 case "$#" in
36 echo "Where would you want to push today?"
37 usage ;;
38 esac
40 . git-parse-remote
41 remote=$(get_remote_url "$@")
42 case "$has_all" in
43 --all) set x ;;
44 '') set x $(get_remote_refs_for_push "$@") ;;
45 esac
46 shift
48 case "$remote" in
49 git://*)
50 die "Cannot use READ-ONLY transport to push to $remote" ;;
51 rsync://*)
52 die "Pushing with rsync transport is deprecated" ;;
53 esac
55 set x "$remote" "$@"; shift
56 test "$has_all" && set x "$has_all" "$@" && shift
57 test "$has_force" && set x "$has_force" "$@" && shift
58 test "$has_exec" && set x "$has_exec" "$@" && shift
60 case "$remote" in
61 http://* | https://*)
62 exec git-http-push "$@";;
64 exec git-send-pack "$@";;
65 esac