Improve request-pull to handle non-rebased branches
[git/git.git] / git-request-pull.sh
CommitLineData
ab421d2c
RA
1#!/bin/sh -e
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
806f36d4
FK
7USAGE='<commit> <url> [<head>]'
8LONG_USAGE='Summarizes the changes since <commit> to the standard output,
9and includes <url> in the message generated.'
10SUBDIRECTORY_OK='Yes'
11. git-sh-setup
ff06c743 12. git-parse-remote
ab421d2c 13
ff06c743 14base=$1
9969b649
JH
15url=$2
16head=${3-HEAD}
ab421d2c 17
ff06c743 18[ "$base" ] || usage
ab421d2c
RA
19[ "$url" ] || usage
20
ff06c743 21baserev=`git-rev-parse --verify "$base"^0` &&
ff84d327 22headrev=`git-rev-parse --verify "$head"^0` || exit
ab421d2c 23
ff06c743
SP
24merge_base=`git merge-base $baserev $headrev` ||
25die "fatal: No commits in common between $base and $head"
26
27url="`get_remote_url "$url"`"
28branch=`git peek-remote "$url" \
29 | sed -n -e "/^$headrev refs.heads./{
30 s/^.* refs.heads.//
31 p
32 q
33 }"`
34if [ -z "$branch" ]; then
35 echo "warn: No branch of $url is at:" >&2
36 git log --max-count=1 --pretty='format:warn: %h: %s' $headrev >&2
37 echo "warn: Are you sure you pushed $head there?" >&2
38 echo >&2
39 echo >&2
40 branch=..BRANCH.NOT.VERIFIED..
41 status=1
42fi
43
44PAGER=
45export PAGER
9969b649 46echo "The following changes since commit $baserev:"
ff06c743 47git shortlog --max-count=1 $baserev | sed -e 's/^\(.\)/ \1/'
ab421d2c 48
ff06c743 49echo "are available in the git repository at:"
9969b649 50echo
ff06c743 51echo " $url $branch"
9969b649 52echo
ab421d2c 53
ff06c743
SP
54git shortlog ^$baserev $headrev
55git diff -M --stat --summary $merge_base $headrev
56exit $status