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='<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.'
12 OPTIONS_SPEC='git request-pull [options] start url [end]
14 p show patch text as well
23 while case "$#" in 0) break ;; esac
38 base=$1 url=$2 status=0
40 test -n "$base" && test -n "$url" || usage
42 baserev=$(git rev-parse --verify --quiet "$base"^0)
45 die "fatal: Not a valid revision: $base"
49 # $3 must be a symbolic ref, a unique ref, or
50 # a SHA object expression. It can also be of
51 # the format 'local-name:remote-name'.
56 pretty_remote=${remote#refs/}
57 pretty_remote=${pretty_remote#heads/}
58 head=$(git symbolic-ref -q "$local")
59 head=${head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)}
60 head=${head:-$(git rev-parse --quiet --verify "$local")}
62 # None of the above? Bad.
63 test -z "$head" && die "fatal: Not a valid revision: $local"
65 # This also verifies that the resulting head is unique:
66 # "git show-ref" could have shown multiple matching refs..
67 headrev=$(git rev-parse --verify --quiet "$head"^0)
68 test -z "$headrev" && die "fatal: Ambiguous revision: $local"
70 # Was it a branch with a description?
71 branch_name=${head#refs/heads/}
72 if test "z$branch_name" = "z$headref" ||
73 ! git config "branch.$branch_name.description" >/dev/null
78 merge_base=$(git merge-base $baserev $headrev) ||
79 die "fatal: No commits in common between $base and $head"
81 # $head is the refname from the command line.
82 # If a ref with the same name as $head exists at the remote
83 # and their values match, use that.
85 # Otherwise find a random ref that matches $headrev.
87 my ($head,$headrev) = (@ARGV);
92 my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
94 next unless ($sha1 eq $headrev);
100 if ($ref =~ /$pattern/) {
103 if ($sha1 eq $head) {
112 ref=$(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
116 echo "warn: No match for commit $headrev found at $url" >&2
117 echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
121 # Special case: turn "for_linus" to "tags/for_linus" when it is correct
122 if test "$ref" = "refs/tags/$pretty_remote"
124 pretty_remote=tags/$pretty_remote
127 url=$(git ls-remote --get-url "$url")
129 git show -s --format='The following changes since commit %H:
133 are available in the git repository at:
135 echo " $url $pretty_remote" &&
136 git show -s --format='
137 for you to fetch changes up to %H:
141 ----------------------------------------------------------------' $headrev &&
143 if test $(git cat-file -t "$head") = tag
145 git cat-file tag "$head" |
146 sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p
148 echo "----------------------------------------------------------------"
151 if test -n "$branch_name"
153 echo "(from the branch description for $branch_name local branch)"
155 git config "branch.$branch_name.description"
156 echo "----------------------------------------------------------------"
159 git shortlog ^$baserev $headrev &&
160 git diff -M --stat --summary $patch $merge_base..$headrev || status=1