Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 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 | |
Stefan Naewe | 3eb91bf | 2008-11-17 09:57:19 +0100 | [diff] [blame] | 7 | USAGE='<start> <url> [<end>]' |
| 8 | LONG_USAGE='Summarizes the changes between two commits to the standard output, |
| 9 | and includes the given URL in the generated summary.' |
freku045@student.liu.se | 806f36d | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 10 | SUBDIRECTORY_OK='Yes' |
Junio C Hamano | 133cfae | 2009-07-27 14:27:47 -0700 | [diff] [blame] | 11 | OPTIONS_SPEC='git request-pull [options] start url [end] |
| 12 | -- |
| 13 | p show patch text as well |
| 14 | ' |
| 15 | |
freku045@student.liu.se | 806f36d | 2005-12-13 23:30:31 +0100 | [diff] [blame] | 16 | . git-sh-setup |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 17 | . git-parse-remote |
Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 18 | |
Michal Marek | 653a31c | 2009-07-01 11:40:30 +0200 | [diff] [blame] | 19 | GIT_PAGER= |
| 20 | export GIT_PAGER |
| 21 | |
Junio C Hamano | 133cfae | 2009-07-27 14:27:47 -0700 | [diff] [blame] | 22 | patch= |
| 23 | while case "$#" in 0) break ;; esac |
| 24 | do |
| 25 | case "$1" in |
| 26 | -p) |
| 27 | patch=-p ;; |
| 28 | --) |
| 29 | shift; break ;; |
| 30 | -*) |
| 31 | usage ;; |
| 32 | *) |
| 33 | break ;; |
| 34 | esac |
| 35 | shift |
| 36 | done |
| 37 | |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 38 | base=$1 |
Junio C Hamano | 9969b64 | 2005-07-26 11:47:31 -0700 | [diff] [blame] | 39 | url=$2 |
| 40 | head=${3-HEAD} |
Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 41 | |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 42 | [ "$base" ] || usage |
Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 43 | [ "$url" ] || usage |
| 44 | |
Junio C Hamano | 5be6007 | 2007-07-02 22:52:14 -0700 | [diff] [blame] | 45 | baserev=`git rev-parse --verify "$base"^0` && |
| 46 | headrev=`git rev-parse --verify "$head"^0` || exit |
Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 47 | |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 48 | merge_base=`git merge-base $baserev $headrev` || |
| 49 | die "fatal: No commits in common between $base and $head" |
| 50 | |
Ramsay Jones | 7498205 | 2008-07-09 00:32:15 +0100 | [diff] [blame] | 51 | branch=$(git ls-remote "$url" \ |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 52 | | sed -n -e "/^$headrev refs.heads./{ |
| 53 | s/^.* refs.heads.// |
| 54 | p |
| 55 | q |
Ralf Wildenhues | b5e960b | 2007-11-08 22:47:36 +0100 | [diff] [blame] | 56 | }") |
Tom Grennan | 33016c4 | 2009-07-28 18:30:02 -0700 | [diff] [blame] | 57 | url=$(get_remote_url "$url") |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 58 | if [ -z "$branch" ]; then |
| 59 | echo "warn: No branch of $url is at:" >&2 |
Michal Marek | 653a31c | 2009-07-01 11:40:30 +0200 | [diff] [blame] | 60 | git log --max-count=1 --pretty='tformat:warn: %h: %s' $headrev >&2 |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 61 | echo "warn: Are you sure you pushed $head there?" >&2 |
| 62 | echo >&2 |
| 63 | echo >&2 |
| 64 | branch=..BRANCH.NOT.VERIFIED.. |
| 65 | status=1 |
| 66 | fi |
| 67 | |
Junio C Hamano | 9969b64 | 2005-07-26 11:47:31 -0700 | [diff] [blame] | 68 | echo "The following changes since commit $baserev:" |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 69 | git shortlog --max-count=1 $baserev | sed -e 's/^\(.\)/ \1/' |
Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 70 | |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 71 | echo "are available in the git repository at:" |
Junio C Hamano | 9969b64 | 2005-07-26 11:47:31 -0700 | [diff] [blame] | 72 | echo |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 73 | echo " $url $branch" |
Junio C Hamano | 9969b64 | 2005-07-26 11:47:31 -0700 | [diff] [blame] | 74 | echo |
Ryan Anderson | ab421d2 | 2005-07-26 03:30:36 -0400 | [diff] [blame] | 75 | |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 76 | git shortlog ^$baserev $headrev |
Junio C Hamano | 133cfae | 2009-07-27 14:27:47 -0700 | [diff] [blame] | 77 | git diff -M --stat --summary $patch $merge_base..$headrev |
Shawn O. Pearce | ff06c74 | 2007-05-01 02:08:23 -0400 | [diff] [blame] | 78 | exit $status |