blob: f10cadbf159bcd63af0c3834bd7cd2fab6cce57c [file] [log] [blame]
Linus Torvalds51cb06c2005-07-08 14:24:25 -07001#!/bin/sh
freku045@student.liu.se806f36d2005-12-13 23:30:31 +01002
Junio C Hamano42301e32006-01-15 23:27:34 -08003USAGE='[--all] [--tags] [--force] <repository> [<refspec>...]'
Junio C Hamanoae2b0f12005-11-24 00:12:11 -08004. git-sh-setup
Junio C Hamano46b1c7c2005-08-07 22:55:45 -07005
6# Parse out parameters and then stop at remote, so that we can
7# translate it using .git/branches information
8has_all=
9has_force=
10has_exec=
Junio C Hamano84f11a42006-03-25 18:27:15 -080011has_thin=--thin
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070012remote=
Junio C Hamano9e9b2672006-01-12 15:29:12 -080013do_tags=
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070014
15while case "$#" in 0) break ;; esac
16do
17 case "$1" in
18 --all)
19 has_all=--all ;;
Junio C Hamano9e9b2672006-01-12 15:29:12 -080020 --tags)
21 do_tags=yes ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070022 --force)
23 has_force=--force ;;
24 --exec=*)
25 has_exec="$1" ;;
Junio C Hamanoa79a2762006-02-20 00:09:41 -080026 --thin)
Junio C Hamano84f11a42006-03-25 18:27:15 -080027 ;; # noop
28 --no-thin)
29 has_thin= ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070030 -*)
c.shoemaker@cox.netc4851042005-10-29 00:16:33 -040031 usage ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070032 *)
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070033 set x "$@"
34 shift
35 break ;;
36 esac
37 shift
38done
Junio C Hamano9a9cbb62005-08-26 10:37:17 -070039case "$#" in
400)
c.shoemaker@cox.netf9362de2005-10-29 00:17:17 -040041 echo "Where would you want to push today?"
42 usage ;;
Junio C Hamano9a9cbb62005-08-26 10:37:17 -070043esac
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070044
Junio C Hamano215a7ad2005-09-07 17:26:23 -070045. git-parse-remote
Junio C Hamanoac4b0cf2005-08-20 02:52:24 -070046remote=$(get_remote_url "$@")
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070047
Junio C Hamano42301e32006-01-15 23:27:34 -080048case "$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 Hamano9e9b2672006-01-12 15:29:12 -080061esac
62
Junio C Hamano42301e32006-01-15 23:27:34 -080063shift ;# away the initial 'x'
64
Junio C Hamano8e76c792006-01-21 12:36:12 -080065# $# 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 Hamano9e9b2672006-01-12 15:29:12 -080068
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070069case "$remote" in
Nick Hengevelddf8171c2005-11-02 11:19:31 -080070git://*)
c.shoemaker@cox.netc4851042005-10-29 00:16:33 -040071 die "Cannot use READ-ONLY transport to push to $remote" ;;
72rsync://*)
73 die "Pushing with rsync transport is deprecated" ;;
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070074esac
75
76set x "$remote" "$@"; shift
77test "$has_all" && set x "$has_all" "$@" && shift
78test "$has_force" && set x "$has_force" "$@" && shift
79test "$has_exec" && set x "$has_exec" "$@" && shift
Junio C Hamanoa79a2762006-02-20 00:09:41 -080080test "$has_thin" && set x "$has_thin" "$@" && shift
Junio C Hamano46b1c7c2005-08-07 22:55:45 -070081
Nick Hengevelddf8171c2005-11-02 11:19:31 -080082case "$remote" in
83http://* | https://*)
84 exec git-http-push "$@";;
85*)
86 exec git-send-pack "$@";;
87esac