]>
Commit | Line | Data |
---|---|---|
51cb06c3 | 1 | #!/bin/sh |
c4851047 | 2 | |
42301e34 | 3 | USAGE='[--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 | |
8 | has_all= | |
9 | has_force= | |
10 | has_exec= | |
11 | remote= | |
9e9b2675 | 12 | do_tags= |
46b1c7c0 JH |
13 | |
14 | while case "$#" in 0) break ;; esac | |
15 | do | |
16 | case "$1" in | |
17 | --all) | |
18 | has_all=--all ;; | |
9e9b2675 JH |
19 | --tags) |
20 | do_tags=yes ;; | |
46b1c7c0 JH |
21 | --force) |
22 | has_force=--force ;; | |
23 | --exec=*) | |
24 | has_exec="$1" ;; | |
25 | -*) | |
c4851047 | 26 | usage ;; |
46b1c7c0 | 27 | *) |
46b1c7c0 JH |
28 | set x "$@" |
29 | shift | |
30 | break ;; | |
31 | esac | |
32 | shift | |
33 | done | |
9a9cbb6e JH |
34 | case "$#" in |
35 | 0) | |
f9362de9 CS |
36 | echo "Where would you want to push today?" |
37 | usage ;; | |
9a9cbb6e | 38 | esac |
46b1c7c0 | 39 | |
215a7ad1 | 40 | . git-parse-remote |
ac4b0cff | 41 | remote=$(get_remote_url "$@") |
42301e34 | 42 | |
ac4b0cff | 43 | case "$has_all" in |
42301e34 JH |
44 | --all) |
45 | set x ;; | |
46 | '') | |
47 | case "$do_tags,$#" in | |
48 | yes,1) | |
49 | set x $(cd "$GIT_DIR/refs" && find tags -type f -print) ;; | |
50 | yes,*) | |
51 | set x $(cd "$GIT_DIR/refs" && find tags -type f -print) \ | |
52 | $(get_remote_refs_for_push "$@") ;; | |
53 | ,*) | |
54 | set x $(get_remote_refs_for_push "$@") ;; | |
55 | esac | |
46b1c7c0 JH |
56 | esac |
57 | ||
42301e34 | 58 | shift ;# away the initial 'x' |
9e9b2675 | 59 | |
8e76c79f JH |
60 | # $# is now 0 if there was no explicit refspec on the command line |
61 | # and there was no defalt refspec to push from remotes/ file. | |
62 | # we will let git-send-pack to do its "matching refs" thing. | |
9e9b2675 | 63 | |
46b1c7c0 | 64 | case "$remote" in |
df8171cc | 65 | git://*) |
c4851047 CS |
66 | die "Cannot use READ-ONLY transport to push to $remote" ;; |
67 | rsync://*) | |
68 | die "Pushing with rsync transport is deprecated" ;; | |
46b1c7c0 JH |
69 | esac |
70 | ||
71 | set x "$remote" "$@"; shift | |
72 | test "$has_all" && set x "$has_all" "$@" && shift | |
73 | test "$has_force" && set x "$has_force" "$@" && shift | |
74 | test "$has_exec" && set x "$has_exec" "$@" && shift | |
75 | ||
df8171cc NH |
76 | case "$remote" in |
77 | http://* | https://*) | |
78 | exec git-http-push "$@";; | |
79 | *) | |
80 | exec git-send-pack "$@";; | |
81 | esac |