git-request-pull.shon commit Merge branch 'kb/maint-status-cquote' (905ffa4)
   1#!/bin/sh
   2# Copyright 2005, Ryan Anderson <ryan@michonline.com>
   3#
   4# This file is licensed under the GPL v2, or a later version
   5# at the discretion of Linus Torvalds.
   6
   7USAGE='<start> <url> [<end>]'
   8LONG_USAGE='Summarizes the changes between two commits to the standard output,
   9and includes the given URL in the generated summary.'
  10SUBDIRECTORY_OK='Yes'
  11OPTIONS_KEEPDASHDASH=
  12OPTIONS_SPEC='git request-pull [options] start url [end]
  13--
  14p    show patch text as well
  15'
  16
  17. git-sh-setup
  18. git-parse-remote
  19
  20GIT_PAGER=
  21export GIT_PAGER
  22
  23patch=
  24while   case "$#" in 0) break ;; esac
  25do
  26        case "$1" in
  27        -p)
  28                patch=-p ;;
  29        --)
  30                shift; break ;;
  31        -*)
  32                usage ;;
  33        *)
  34                break ;;
  35        esac
  36        shift
  37done
  38
  39base=$1
  40url=$2
  41head=${3-HEAD}
  42
  43[ "$base" ] || usage
  44[ "$url" ] || usage
  45
  46baserev=`git rev-parse --verify "$base"^0` &&
  47headrev=`git rev-parse --verify "$head"^0` || exit
  48
  49merge_base=`git merge-base $baserev $headrev` ||
  50die "fatal: No commits in common between $base and $head"
  51
  52branch=$(git ls-remote "$url" \
  53        | sed -n -e "/^$headrev refs.heads./{
  54                s/^.*   refs.heads.//
  55                p
  56                q
  57        }")
  58url=$(get_remote_url "$url")
  59if [ -z "$branch" ]; then
  60        echo "warn: No branch of $url is at:" >&2
  61        git log --max-count=1 --pretty='tformat:warn:   %h: %s' $headrev >&2
  62        echo "warn: Are you sure you pushed $head there?" >&2
  63        echo >&2
  64        echo >&2
  65        branch=..BRANCH.NOT.VERIFIED..
  66        status=1
  67fi
  68
  69git show -s --format='The following changes since commit %H:
  70
  71  %s (%ci)
  72
  73are available in the git repository at:' $baserev &&
  74echo "  $url $branch" &&
  75echo &&
  76
  77git shortlog ^$baserev $headrev &&
  78git diff -M --stat --summary $patch $merge_base..$headrev || exit
  79exit $status