Linus Torvalds | 51cb06c | 2005-07-08 14:24:25 -0700 | [diff] [blame] | 1 | #!/bin/sh |
Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 2 | . git-sh-setup || die "Not a git archive" |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 3 | |
c.shoemaker@cox.net | c485104 | 2005-10-29 00:16:33 -0400 | [diff] [blame] | 4 | usage () { |
| 5 | die "Usage: git push [--all] [--force] <repository> [<refspec>]" |
| 6 | } |
| 7 | |
| 8 | |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 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= |
| 15 | |
| 16 | while case "$#" in 0) break ;; esac |
| 17 | do |
| 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.net | c485104 | 2005-10-29 00:16:33 -0400 | [diff] [blame] | 26 | usage ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 27 | *) |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 28 | set x "$@" |
| 29 | shift |
| 30 | break ;; |
| 31 | esac |
| 32 | shift |
| 33 | done |
Junio C Hamano | 9a9cbb6 | 2005-08-26 10:37:17 -0700 | [diff] [blame] | 34 | case "$#" in |
| 35 | 0) |
c.shoemaker@cox.net | f9362de | 2005-10-29 00:17:17 -0400 | [diff] [blame] | 36 | echo "Where would you want to push today?" |
| 37 | usage ;; |
Junio C Hamano | 9a9cbb6 | 2005-08-26 10:37:17 -0700 | [diff] [blame] | 38 | esac |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 39 | |
Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 40 | . git-parse-remote |
Junio C Hamano | ac4b0cf | 2005-08-20 02:52:24 -0700 | [diff] [blame] | 41 | remote=$(get_remote_url "$@") |
| 42 | case "$has_all" in |
| 43 | --all) set x ;; |
| 44 | '') set x $(get_remote_refs_for_push "$@") ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 45 | esac |
Junio C Hamano | ac4b0cf | 2005-08-20 02:52:24 -0700 | [diff] [blame] | 46 | shift |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 47 | |
| 48 | case "$remote" in |
Nick Hengeveld | df8171c | 2005-11-02 11:19:31 -0800 | [diff] [blame] | 49 | git://*) |
c.shoemaker@cox.net | c485104 | 2005-10-29 00:16:33 -0400 | [diff] [blame] | 50 | die "Cannot use READ-ONLY transport to push to $remote" ;; |
| 51 | rsync://*) |
| 52 | die "Pushing with rsync transport is deprecated" ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 53 | esac |
| 54 | |
| 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 |
| 59 | |
Nick Hengeveld | df8171c | 2005-11-02 11:19:31 -0800 | [diff] [blame] | 60 | case "$remote" in |
| 61 | http://* | https://*) |
| 62 | exec git-http-push "$@";; |
| 63 | *) |
| 64 | exec git-send-pack "$@";; |
| 65 | esac |