git-request-pull.sh 1.34 KB
Newer Older
1 2 3 4 5 6
#!/bin/sh -e
# Copyright 2005, Ryan Anderson <[email protected]>
#
# This file is licensed under the GPL v2, or a later version
# at the discretion of Linus Torvalds.

7 8 9 10
USAGE='<commit> <url> [<head>]'
LONG_USAGE='Summarizes the changes since <commit> to the standard output,
and includes <url> in the message generated.'
SUBDIRECTORY_OK='Yes'
11
OPTIONS_SPEC=
12
. git-sh-setup
13
. git-parse-remote
14

15
base=$1
Junio C Hamano's avatar
Junio C Hamano committed
16 17
url=$2
head=${3-HEAD}
18

19
[ "$base" ] || usage
20 21
[ "$url" ] || usage

22 23
baserev=`git rev-parse --verify "$base"^0` &&
headrev=`git rev-parse --verify "$head"^0` || exit
24

25 26 27
merge_base=`git merge-base $baserev $headrev` ||
die "fatal: No commits in common between $base and $head"

28
url=$(get_remote_url "$url")
29
branch=$(git ls-remote "$url" \
30 31 32 33
	| sed -n -e "/^$headrev	refs.heads./{
		s/^.*	refs.heads.//
		p
		q
34
	}")
35 36 37 38 39 40 41 42 43 44 45 46
if [ -z "$branch" ]; then
	echo "warn: No branch of $url is at:" >&2
	git log --max-count=1 --pretty='format:warn:   %h: %s' $headrev >&2
	echo "warn: Are you sure you pushed $head there?" >&2
	echo >&2
	echo >&2
	branch=..BRANCH.NOT.VERIFIED..
	status=1
fi

PAGER=
export PAGER
Junio C Hamano's avatar
Junio C Hamano committed
47
echo "The following changes since commit $baserev:"
48
git shortlog --max-count=1 $baserev | sed -e 's/^\(.\)/  \1/'
49

50
echo "are available in the git repository at:"
Junio C Hamano's avatar
Junio C Hamano committed
51
echo
52
echo "  $url $branch"
Junio C Hamano's avatar
Junio C Hamano committed
53
echo
54

55 56 57
git shortlog ^$baserev $headrev
git diff -M --stat --summary $merge_base $headrev
exit $status