blob: edc0b8317a6d566895c4a2df6a3f7d86773ca138 [file] [log] [blame]
Linus Torvalds51cb06c2005-07-08 14:24:25 -07001#!/bin/sh
Junio C Hamano215a7ad2005-09-07 17:26:23 -07002. git-sh-setup || die "Not a git archive"
Junio C Hamano46b1c7c2005-08-07 22:55:45 -07003
c.shoemaker@cox.netc4851042005-10-29 00:16:33 -04004usage () {
5 die "Usage: git push [--all] [--force] <repository> [<refspec>]"
6}
7
8
Junio C Hamano46b1c7c2005-08-07 22:55:45 -07009# Parse out parameters and then stop at remote, so that we can
10# translate it using .git/branches information
11has_all=
12has_force=
13has_exec=
14remote=
15
16while case "$#" in 0) break ;; esac
17do
18 case "$1" in
19 --all)
20 has_all=--all ;;
21 --force)
22 has_force=--force ;;
23 --exec=*)
24 has_exec="$1" ;;
25 -*)
c.shoemaker@cox.netc4851042005-10-29 00:16:33 -040026 usage ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070027 *)
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070028 set x "$@"
29 shift
30 break ;;
31 esac
32 shift
33done
Junio C Hamano9a9cbb62005-08-26 10:37:17 -070034case "$#" in
350)
c.shoemaker@cox.netf9362de2005-10-29 00:17:17 -040036 echo "Where would you want to push today?"
37 usage ;;
Junio C Hamano9a9cbb62005-08-26 10:37:17 -070038esac
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070039
Junio C Hamano215a7ad2005-09-07 17:26:23 -070040. git-parse-remote
Junio C Hamanoac4b0cf2005-08-20 02:52:24 -070041remote=$(get_remote_url "$@")
42case "$has_all" in
43--all) set x ;;
44'') set x $(get_remote_refs_for_push "$@") ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070045esac
Junio C Hamanoac4b0cf2005-08-20 02:52:24 -070046shift
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070047
48case "$remote" in
Nick Hengevelddf8171c2005-11-02 11:19:31 -080049git://*)
c.shoemaker@cox.netc4851042005-10-29 00:16:33 -040050 die "Cannot use READ-ONLY transport to push to $remote" ;;
51rsync://*)
52 die "Pushing with rsync transport is deprecated" ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070053esac
54
55set x "$remote" "$@"; shift
56test "$has_all" && set x "$has_all" "$@" && shift
57test "$has_force" && set x "$has_force" "$@" && shift
58test "$has_exec" && set x "$has_exec" "$@" && shift
59
Nick Hengevelddf8171c2005-11-02 11:19:31 -080060case "$remote" in
61http://* | https://*)
62 exec git-http-push "$@";;
63*)
64 exec git-send-pack "$@";;
65esac