Adjust to ls-tree --full-name when run from a subdirectory.
[git.git] / git-push.sh
1 #!/bin/sh
2
3 USAGE='[--all] [--force] <repository> [<refspec>...]'
4 . git-sh-setup
5
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=
12
13 while case "$#" in 0) break ;; esac
14 do
15         case "$1" in
16         --all)
17                 has_all=--all ;;
18         --force)
19                 has_force=--force ;;
20         --exec=*)
21                 has_exec="$1" ;;
22         -*)
23                 usage ;;
24         *)
25                 set x "$@"
26                 shift
27                 break ;;
28         esac
29         shift
30 done
31 case "$#" in
32 0)
33         echo "Where would you want to push today?"
34         usage ;;
35 esac
36
37 . git-parse-remote
38 remote=$(get_remote_url "$@")
39 case "$has_all" in
40 --all) set x ;;
41 '')    set x $(get_remote_refs_for_push "$@") ;;
42 esac
43 shift
44
45 case "$remote" in
46 git://*)
47         die "Cannot use READ-ONLY transport to push to $remote" ;;
48 rsync://*)
49         die "Pushing with rsync transport is deprecated" ;;
50 esac
51
52 set x "$remote" "$@"; shift
53 test "$has_all" && set x "$has_all" "$@" && shift
54 test "$has_force" && set x "$has_force" "$@" && shift
55 test "$has_exec" && set x "$has_exec" "$@" && shift
56
57 case "$remote" in
58 http://* | https://*)
59         exec git-http-push "$@";;
60 *)
61         exec git-send-pack "$@";;
62 esac