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.
10 OPTIONS_SPEC
='git request-pull [options] start url [end]
12 p show patch text as well
21 while case "$#" in 0) break ;; esac
36 base
=$1 url
=$2 status
=0
38 test -n "$base" && test -n "$url" || usage
40 baserev
=$
(git rev-parse
--verify --quiet "$base"^
0)
43 die
"fatal: Not a valid revision: $base"
47 # $3 must be a symbolic ref, a unique ref, or
48 # a SHA object expression. It can also be of
49 # the format 'local-name:remote-name'.
54 pretty_remote
=${remote#refs/}
55 pretty_remote
=${pretty_remote#heads/}
56 head=$
(git symbolic-ref
-q "$local")
57 head=${head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)}
58 head=${head:-$(git rev-parse --quiet --verify "$local")}
60 # None of the above? Bad.
61 test -z "$head" && die
"fatal: Not a valid revision: $local"
63 # This also verifies that the resulting head is unique:
64 # "git show-ref" could have shown multiple matching refs..
65 headrev
=$
(git rev-parse
--verify --quiet "$head"^
0)
66 test -z "$headrev" && die
"fatal: Ambiguous revision: $local"
68 local_sha1
=$
(git rev-parse
--verify --quiet "$head")
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 # Find a ref with the same name as $head that exists at the remote
83 # and points to the same commit as the local object.
85 my ($head,$headrev) = (@ARGV);
86 my $pattern = qr{/\Q$head\E$};
87 my ($remote_sha1, $found);
91 my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
94 $found = $remote_sha1 = $sha1;
98 if ($ref eq $head || $ref =~ $pattern) {
100 # Remember the matching object on the remote side
101 $remote_sha1 = $sha1;
103 if ($sha1 eq $headrev) {
110 $remote_sha1 = $headrev if ! defined $remote_sha1;
111 print "$remote_sha1 $found\n";
115 set fnord $
(git ls-remote
"$url" | @@PERL@@
-e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
121 echo "warn: No match for commit $headrev found at $url" >&2
122 echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
124 elif test "$local_sha1" != "$remote_sha1"
126 echo "warn: $head found at $url but points to a different object" >&2
127 echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
131 # Special case: turn "for_linus" to "tags/for_linus" when it is correct
132 if test "$ref" = "refs/tags/$pretty_remote"
134 pretty_remote
=tags
/$pretty_remote
137 url
=$
(git ls-remote
--get-url "$url")
139 git show
-s --format='The following changes since commit %H:
143 are available in the Git repository at:
145 echo " $url $pretty_remote" &&
146 git show
-s --format='
147 for you to fetch changes up to %H:
151 ----------------------------------------------------------------' $headrev &&
153 if test $
(git cat-file
-t "$head") = tag
155 git cat-file tag
"$head" |
156 sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p
158 echo "----------------------------------------------------------------"
161 if test -n "$branch_name"
163 echo "(from the branch description for $branch_name local branch)"
165 git config
"branch.$branch_name.description"
166 echo "----------------------------------------------------------------"
169 git shortlog ^
$baserev $headrev &&
170 git
diff -M --stat --summary $patch $merge_base..
$headrev || status
=1