git-push.shon commit Merge fixes up to GIT 1.1.4 (949964c)
   1#!/bin/sh
   2
   3USAGE='[--all] [--tags] [--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
   8has_all=
   9has_force=
  10has_exec=
  11remote=
  12do_tags=
  13
  14while case "$#" in 0) break ;; esac
  15do
  16        case "$1" in
  17        --all)
  18                has_all=--all ;;
  19        --tags)
  20                do_tags=yes ;;
  21        --force)
  22                has_force=--force ;;
  23        --exec=*)
  24                has_exec="$1" ;;
  25        -*)
  26                usage ;;
  27        *)
  28                set x "$@"
  29                shift
  30                break ;;
  31        esac
  32        shift
  33done
  34case "$#" in
  350)
  36        echo "Where would you want to push today?"
  37        usage ;;
  38esac
  39
  40. git-parse-remote
  41remote=$(get_remote_url "$@")
  42
  43case "$has_all" in
  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
  56esac
  57
  58shift ;# away the initial 'x'
  59
  60# Now we have explicit refs from the command line or from remotes/
  61# shorthand, or --tags.  Falling back on the current branch if we still
  62# do not have any may be an alternative, but prevent mistakes for now.
  63
  64case "$#,$has_all" in
  650,)
  66        die "No refs given to be pushed." ;;
  67esac
  68
  69case "$remote" in
  70git://*)
  71        die "Cannot use READ-ONLY transport to push to $remote" ;;
  72rsync://*)
  73        die "Pushing with rsync transport is deprecated" ;;
  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
  80
  81case "$remote" in
  82http://* | https://*)
  83        exec git-http-push "$@";;
  84*)
  85        exec git-send-pack "$@";;
  86esac