blob: 630ceddf0356429f7ff71d280ee1056a2eb939c6 [file] [log] [blame]
Ryan Andersonab421d22005-07-26 03:30:36 -04001#!/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
Stefan Naewe3eb91bf2008-11-17 09:57:19 +01007USAGE='<start> <url> [<end>]'
8LONG_USAGE='Summarizes the changes between two commits to the standard output,
9and includes the given URL in the generated summary.'
freku045@student.liu.se806f36d2005-12-13 23:30:31 +010010SUBDIRECTORY_OK='Yes'
Junio C Hamano133cfae2009-07-27 14:27:47 -070011OPTIONS_SPEC='git request-pull [options] start url [end]
12--
13p show patch text as well
14'
15
freku045@student.liu.se806f36d2005-12-13 23:30:31 +010016. git-sh-setup
Shawn O. Pearceff06c742007-05-01 02:08:23 -040017. git-parse-remote
Ryan Andersonab421d22005-07-26 03:30:36 -040018
Michal Marek653a31c2009-07-01 11:40:30 +020019GIT_PAGER=
20export GIT_PAGER
21
Junio C Hamano133cfae2009-07-27 14:27:47 -070022patch=
23while case "$#" in 0) break ;; esac
24do
25 case "$1" in
26 -p)
27 patch=-p ;;
28 --)
29 shift; break ;;
30 -*)
31 usage ;;
32 *)
33 break ;;
34 esac
35 shift
36done
37
Shawn O. Pearceff06c742007-05-01 02:08:23 -040038base=$1
Junio C Hamano9969b642005-07-26 11:47:31 -070039url=$2
40head=${3-HEAD}
Ryan Andersonab421d22005-07-26 03:30:36 -040041
Shawn O. Pearceff06c742007-05-01 02:08:23 -040042[ "$base" ] || usage
Ryan Andersonab421d22005-07-26 03:30:36 -040043[ "$url" ] || usage
44
Junio C Hamano5be60072007-07-02 22:52:14 -070045baserev=`git rev-parse --verify "$base"^0` &&
46headrev=`git rev-parse --verify "$head"^0` || exit
Ryan Andersonab421d22005-07-26 03:30:36 -040047
Shawn O. Pearceff06c742007-05-01 02:08:23 -040048merge_base=`git merge-base $baserev $headrev` ||
49die "fatal: No commits in common between $base and $head"
50
Ramsay Jones74982052008-07-09 00:32:15 +010051branch=$(git ls-remote "$url" \
Shawn O. Pearceff06c742007-05-01 02:08:23 -040052 | sed -n -e "/^$headrev refs.heads./{
53 s/^.* refs.heads.//
54 p
55 q
Ralf Wildenhuesb5e960b2007-11-08 22:47:36 +010056 }")
Tom Grennan33016c42009-07-28 18:30:02 -070057url=$(get_remote_url "$url")
Shawn O. Pearceff06c742007-05-01 02:08:23 -040058if [ -z "$branch" ]; then
59 echo "warn: No branch of $url is at:" >&2
Michal Marek653a31c2009-07-01 11:40:30 +020060 git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2
Shawn O. Pearceff06c742007-05-01 02:08:23 -040061 echo "warn: Are you sure you pushed $head there?" >&2
62 echo >&2
63 echo >&2
64 branch=..BRANCH.NOT.VERIFIED..
65 status=1
66fi
67
Junio C Hamano9969b642005-07-26 11:47:31 -070068echo "The following changes since commit $baserev:"
Shawn O. Pearceff06c742007-05-01 02:08:23 -040069git shortlog --max-count=1 $baserev | sed -e 's/^\(.\)/ \1/'
Ryan Andersonab421d22005-07-26 03:30:36 -040070
Shawn O. Pearceff06c742007-05-01 02:08:23 -040071echo "are available in the git repository at:"
Junio C Hamano9969b642005-07-26 11:47:31 -070072echo
Shawn O. Pearceff06c742007-05-01 02:08:23 -040073echo " $url $branch"
Junio C Hamano9969b642005-07-26 11:47:31 -070074echo
Ryan Andersonab421d22005-07-26 03:30:36 -040075
Shawn O. Pearceff06c742007-05-01 02:08:23 -040076git shortlog ^$baserev $headrev
Junio C Hamano133cfae2009-07-27 14:27:47 -070077git diff -M --stat --summary $patch $merge_base..$headrev
Shawn O. Pearceff06c742007-05-01 02:08:23 -040078exit $status