[PATCH] Assorted changes to glossary
[git.git] / git-push-script
1 #!/bin/sh
2 . git-sh-setup-script || die "Not a git archive"
3
4 # Parse out parameters and then stop at remote, so that we can
5 # translate it using .git/branches information
6 has_all=
7 has_force=
8 has_exec=
9 remote=
10
11 while case "$#" in 0) break ;; esac
12 do
13         case "$1" in
14         --all)
15                 has_all=--all ;;
16         --force)
17                 has_force=--force ;;
18         --exec=*)
19                 has_exec="$1" ;;
20         -*)
21                 die "Unknown parameter $1" ;;
22         *)
23                 remote="$1"
24                 shift
25                 set x "$@"
26                 shift
27                 break ;;
28         esac
29         shift
30 done
31
32 case "$remote" in
33 *:* | /* | ../* | ./* )
34         # An URL, host:/path/to/git, absolute and relative paths.
35         ;;
36 * )
37         # Shorthand
38         if expr "$remote" : '..*/..*' >/dev/null
39         then
40                 # a short-hand followed by a trailing path
41                 shorthand=$(expr "$remote" : '\([^/]*\)')
42                 remainder=$(expr "$remote" : '[^/]*\(/.*\)$')
43         else
44                 shorthand="$remote"
45                 remainder=
46         fi
47         remote=$(sed -e 's/#.*//' "$GIT_DIR/branches/$remote") &&
48         expr "$remote" : '..*:' >/dev/null &&
49         remote="$remote$remainder" ||
50         die "Cannot parse remote $remote"
51         ;;
52 esac
53
54 case "$remote" in
55 http://* | https://* | git://* | rsync://* )
56         die "Cannot push to $remote" ;;
57 esac
58
59 set x "$remote" "$@"; shift
60 test "$has_all" && set x "$has_all" "$@" && shift
61 test "$has_force" && set x "$has_force" "$@" && shift
62 test "$has_exec" && set x "$has_exec" "$@" && shift
63
64 exec git-send-pack "$@"