blob: 74238b031370a02d8456aeee9003977f001bd9c7 [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'
Jonathan Nieder50ab6552010-04-24 07:15:37 -050011OPTIONS_KEEPDASHDASH=
Junio C Hamano133cfae2009-07-27 14:27:47 -070012OPTIONS_SPEC='git request-pull [options] start url [end]
13--
14p show patch text as well
15'
16
freku045@student.liu.se806f36d2005-12-13 23:30:31 +010017. git-sh-setup
Shawn O. Pearceff06c742007-05-01 02:08:23 -040018. git-parse-remote
Ryan Andersonab421d22005-07-26 03:30:36 -040019
Michal Marek653a31c2009-07-01 11:40:30 +020020GIT_PAGER=
21export GIT_PAGER
22
Junio C Hamano133cfae2009-07-27 14:27:47 -070023patch=
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
Shawn O. Pearceff06c742007-05-01 02:08:23 -040039base=$1
Junio C Hamano9969b642005-07-26 11:47:31 -070040url=$2
41head=${3-HEAD}
Ryan Andersonab421d22005-07-26 03:30:36 -040042
Shawn O. Pearceff06c742007-05-01 02:08:23 -040043[ "$base" ] || usage
Ryan Andersonab421d22005-07-26 03:30:36 -040044[ "$url" ] || usage
45
Junio C Hamano5be60072007-07-02 22:52:14 -070046baserev=`git rev-parse --verify "$base"^0` &&
47headrev=`git rev-parse --verify "$head"^0` || exit
Ryan Andersonab421d22005-07-26 03:30:36 -040048
Shawn O. Pearceff06c742007-05-01 02:08:23 -040049merge_base=`git merge-base $baserev $headrev` ||
50die "fatal: No commits in common between $base and $head"
51
Ramsay Jones74982052008-07-09 00:32:15 +010052branch=$(git ls-remote "$url" \
Shawn O. Pearceff06c742007-05-01 02:08:23 -040053 | sed -n -e "/^$headrev refs.heads./{
54 s/^.* refs.heads.//
55 p
56 q
Ralf Wildenhuesb5e960b2007-11-08 22:47:36 +010057 }")
Tom Grennan33016c42009-07-28 18:30:02 -070058url=$(get_remote_url "$url")
Shawn O. Pearceff06c742007-05-01 02:08:23 -040059if [ -z "$branch" ]; then
60 echo "warn: No branch of $url is at:" >&2
Michal Marek653a31c2009-07-01 11:40:30 +020061 git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2
Shawn O. Pearceff06c742007-05-01 02:08:23 -040062 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
Miklos Vajna10eb0002010-01-29 15:17:59 +010069git show -s --format='The following changes since commit %H:
Ryan Andersonab421d22005-07-26 03:30:36 -040070
Miklos Vajna10eb0002010-01-29 15:17:59 +010071 %s (%ci)
72
73are available in the git repository at:' $baserev
Shawn O. Pearceff06c742007-05-01 02:08:23 -040074echo " $url $branch"
Junio C Hamano9969b642005-07-26 11:47:31 -070075echo
Ryan Andersonab421d22005-07-26 03:30:36 -040076
Shawn O. Pearceff06c742007-05-01 02:08:23 -040077git shortlog ^$baserev $headrev
Junio C Hamano133cfae2009-07-27 14:27:47 -070078git diff -M --stat --summary $patch $merge_base..$headrev
Shawn O. Pearceff06c742007-05-01 02:08:23 -040079exit $status