builtin-blame: set up the work_tree before the first file access
[git/debian.git] / git-request-pull.sh
blob95ad66630f39effead53598a650dec0ab7b90289
1 #!/bin/sh -e
2 # Copyright 2005, Ryan Anderson <ryan@michonline.com>
4 # This file is licensed under the GPL v2, or a later version
5 # at the discretion of Linus Torvalds.
7 USAGE='<commit> <url> [<head>]'
8 LONG_USAGE='Summarizes the changes since <commit> to the standard output,
9 and includes <url> in the message generated.'
10 SUBDIRECTORY_OK='Yes'
11 . git-sh-setup
12 . git-parse-remote
14 base=$1
15 url=$2
16 head=${3-HEAD}
18 [ "$base" ] || usage
19 [ "$url" ] || usage
21 baserev=`git rev-parse --verify "$base"^0` &&
22 headrev=`git rev-parse --verify "$head"^0` || exit
24 merge_base=`git merge-base $baserev $headrev` ||
25 die "fatal: No commits in common between $base and $head"
27 url=$(get_remote_url "$url")
28 branch=$(git peek-remote "$url" \
29 | sed -n -e "/^$headrev refs.heads./{
30 s/^.* refs.heads.//
33 }")
34 if [ -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
44 PAGER=
45 export PAGER
46 echo "The following changes since commit $baserev:"
47 git shortlog --max-count=1 $baserev | sed -e 's/^\(.\)/ \1/'
49 echo "are available in the git repository at:"
50 echo
51 echo " $url $branch"
52 echo
54 git shortlog ^$baserev $headrev
55 git diff -M --stat --summary $merge_base $headrev
56 exit $status