]> git.ipfire.org Git - thirdparty/git.git/blame - git-push.sh
cvsserver: avoid warning about active db handles
[thirdparty/git.git] / git-push.sh
CommitLineData
51cb06c3 1#!/bin/sh
c4851047 2
42301e34 3USAGE='[--all] [--tags] [--force] <repository> [<refspec>...]'
806f36d4 4. git-sh-setup
c4851047 5
46b1c7c0
JH
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=
84f11a43 11has_thin=--thin
46b1c7c0 12remote=
9e9b2675 13do_tags=
46b1c7c0
JH
14
15while case "$#" in 0) break ;; esac
16do
17 case "$1" in
18 --all)
19 has_all=--all ;;
9e9b2675
JH
20 --tags)
21 do_tags=yes ;;
46b1c7c0
JH
22 --force)
23 has_force=--force ;;
24 --exec=*)
25 has_exec="$1" ;;
a79a2763 26 --thin)
84f11a43
JH
27 ;; # noop
28 --no-thin)
29 has_thin= ;;
46b1c7c0 30 -*)
c4851047 31 usage ;;
46b1c7c0 32 *)
46b1c7c0
JH
33 set x "$@"
34 shift
35 break ;;
36 esac
37 shift
38done
9a9cbb6e
JH
39case "$#" in
400)
f9362de9
CS
41 echo "Where would you want to push today?"
42 usage ;;
9a9cbb6e 43esac
46b1c7c0 44
215a7ad1 45. git-parse-remote
ac4b0cff 46remote=$(get_remote_url "$@")
42301e34 47
ac4b0cff 48case "$has_all" in
42301e34
JH
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
46b1c7c0
JH
61esac
62
42301e34 63shift ;# away the initial 'x'
9e9b2675 64
8e76c79f 65# $# is now 0 if there was no explicit refspec on the command line
82e5a82f 66# and there was no default refspec to push from remotes/ file.
8e76c79f 67# we will let git-send-pack to do its "matching refs" thing.
9e9b2675 68
46b1c7c0 69case "$remote" in
df8171cc 70git://*)
c4851047
CS
71 die "Cannot use READ-ONLY transport to push to $remote" ;;
72rsync://*)
73 die "Pushing with rsync transport is deprecated" ;;
46b1c7c0
JH
74esac
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
a79a2763 80test "$has_thin" && set x "$has_thin" "$@" && shift
46b1c7c0 81
df8171cc
NH
82case "$remote" in
83http://* | https://*)
84 exec git-http-push "$@";;
85*)
86 exec git-send-pack "$@";;
87esac