Linus Torvalds | 51cb06c | 2005-07-08 14:24:25 -0700 | [diff] [blame] | 1 | #!/bin/sh |
freku045@student.liu.se | 806f36d | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 2 | |
Junio C Hamano | 42301e3 | 2006-01-15 23:27:34 -0800 | [diff] [blame] | 3 | USAGE='[--all] [--tags] [--force] <repository> [<refspec>...]' |
Junio C Hamano | ae2b0f1 | 2005-11-24 00:12:11 -0800 | [diff] [blame] | 4 | . git-sh-setup |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 5 | |
| 6 | # Parse out parameters and then stop at remote, so that we can |
| 7 | # translate it using .git/branches information |
| 8 | has_all= |
| 9 | has_force= |
| 10 | has_exec= |
Junio C Hamano | 84f11a4 | 2006-03-25 18:27:15 -0800 | [diff] [blame] | 11 | has_thin=--thin |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 12 | remote= |
Junio C Hamano | 9e9b267 | 2006-01-12 15:29:12 -0800 | [diff] [blame] | 13 | do_tags= |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 14 | |
| 15 | while case "$#" in 0) break ;; esac |
| 16 | do |
| 17 | case "$1" in |
| 18 | --all) |
| 19 | has_all=--all ;; |
Junio C Hamano | 9e9b267 | 2006-01-12 15:29:12 -0800 | [diff] [blame] | 20 | --tags) |
| 21 | do_tags=yes ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 22 | --force) |
| 23 | has_force=--force ;; |
| 24 | --exec=*) |
| 25 | has_exec="$1" ;; |
Junio C Hamano | a79a276 | 2006-02-20 00:09:41 -0800 | [diff] [blame] | 26 | --thin) |
Junio C Hamano | 84f11a4 | 2006-03-25 18:27:15 -0800 | [diff] [blame] | 27 | ;; # noop |
| 28 | --no-thin) |
| 29 | has_thin= ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 30 | -*) |
c.shoemaker@cox.net | c485104 | 2005-10-29 00:16:33 -0400 | [diff] [blame] | 31 | usage ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 32 | *) |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 33 | set x "$@" |
| 34 | shift |
| 35 | break ;; |
| 36 | esac |
| 37 | shift |
| 38 | done |
Junio C Hamano | 9a9cbb6 | 2005-08-26 10:37:17 -0700 | [diff] [blame] | 39 | case "$#" in |
| 40 | 0) |
c.shoemaker@cox.net | f9362de | 2005-10-29 00:17:17 -0400 | [diff] [blame] | 41 | echo "Where would you want to push today?" |
| 42 | usage ;; |
Junio C Hamano | 9a9cbb6 | 2005-08-26 10:37:17 -0700 | [diff] [blame] | 43 | esac |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 44 | |
Junio C Hamano | 215a7ad | 2005-09-07 17:26:23 -0700 | [diff] [blame] | 45 | . git-parse-remote |
Junio C Hamano | ac4b0cf | 2005-08-20 02:52:24 -0700 | [diff] [blame] | 46 | remote=$(get_remote_url "$@") |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 47 | |
Junio C Hamano | 42301e3 | 2006-01-15 23:27:34 -0800 | [diff] [blame] | 48 | case "$has_all" in |
| 49 | --all) |
| 50 | set x ;; |
| 51 | '') |
| 52 | case "$do_tags,$#" in |
| 53 | yes,1) |
| 54 | set x $(cd "$GIT_DIR/refs" && find tags -type f -print) ;; |
| 55 | yes,*) |
| 56 | set x $(cd "$GIT_DIR/refs" && find tags -type f -print) \ |
| 57 | $(get_remote_refs_for_push "$@") ;; |
| 58 | ,*) |
| 59 | set x $(get_remote_refs_for_push "$@") ;; |
| 60 | esac |
Junio C Hamano | 9e9b267 | 2006-01-12 15:29:12 -0800 | [diff] [blame] | 61 | esac |
| 62 | |
Junio C Hamano | 42301e3 | 2006-01-15 23:27:34 -0800 | [diff] [blame] | 63 | shift ;# away the initial 'x' |
| 64 | |
Junio C Hamano | 8e76c79 | 2006-01-21 12:36:12 -0800 | [diff] [blame] | 65 | # $# is now 0 if there was no explicit refspec on the command line |
| 66 | # and there was no defalt refspec to push from remotes/ file. |
| 67 | # we will let git-send-pack to do its "matching refs" thing. |
Junio C Hamano | 9e9b267 | 2006-01-12 15:29:12 -0800 | [diff] [blame] | 68 | |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 69 | case "$remote" in |
Nick Hengeveld | df8171c | 2005-11-02 11:19:31 -0800 | [diff] [blame] | 70 | git://*) |
c.shoemaker@cox.net | c485104 | 2005-10-29 00:16:33 -0400 | [diff] [blame] | 71 | die "Cannot use READ-ONLY transport to push to $remote" ;; |
| 72 | rsync://*) |
| 73 | die "Pushing with rsync transport is deprecated" ;; |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 74 | esac |
| 75 | |
| 76 | set x "$remote" "$@"; shift |
| 77 | test "$has_all" && set x "$has_all" "$@" && shift |
| 78 | test "$has_force" && set x "$has_force" "$@" && shift |
| 79 | test "$has_exec" && set x "$has_exec" "$@" && shift |
Junio C Hamano | a79a276 | 2006-02-20 00:09:41 -0800 | [diff] [blame] | 80 | test "$has_thin" && set x "$has_thin" "$@" && shift |
Junio C Hamano | 46b1c7c | 2005-08-07 22:55:45 -0700 | [diff] [blame] | 81 | |
Nick Hengeveld | df8171c | 2005-11-02 11:19:31 -0800 | [diff] [blame] | 82 | case "$remote" in |
| 83 | http://* | https://*) |
| 84 | exec git-http-push "$@";; |
| 85 | *) |
| 86 | exec git-send-pack "$@";; |
| 87 | esac |