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