1#!/bin/sh
23
USAGE='[--all] [--tags] [--force] <repository> [<refspec>...]'
4. git-sh-setup
56
# 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=
11remote=
12do_tags=
1314
while case "$#" in 0) break ;; esac
15do
16case "$1" in
17--all)
18has_all=--all ;;
19--tags)
20do_tags=yes ;;
21--force)
22has_force=--force ;;
23--exec=*)
24has_exec="$1" ;;
25-*)
26usage ;;
27*)
28set x "$@"
29shift
30break ;;
31esac
32shift
33done
34case "$#" in
350)
36echo "Where would you want to push today?"
37usage ;;
38esac
3940
. git-parse-remote
41remote=$(get_remote_url "$@")
4243
case "$has_all" in
44--all)
45set x ;;
46'')
47case "$do_tags,$#" in
48yes,1)
49set x $(cd "$GIT_DIR/refs" && find tags -type f -print) ;;
50yes,*)
51set x $(cd "$GIT_DIR/refs" && find tags -type f -print) \
52$(get_remote_refs_for_push "$@") ;;
53,*)
54set x $(get_remote_refs_for_push "$@") ;;
55esac
56esac
5758
shift ;# away the initial 'x'
5960
# Now we have explicit refs from the command line or from remotes/
61# shorthand, or --tags. Falling back on the current branch if we still
62# do not have any may be an alternative, but prevent mistakes for now.
6364
case "$#,$has_all" in
650,)
66die "No refs given to be pushed." ;;
67esac
6869
case "$remote" in
70git://*)
71die "Cannot use READ-ONLY transport to push to $remote" ;;
72rsync://*)
73die "Pushing with rsync transport is deprecated" ;;
74esac
7576
set 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
8081
case "$remote" in
82http://* | https://*)
83exec git-http-push "$@";;
84*)
85exec git-send-pack "$@";;
86esac