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
52 head=$
(git symbolic-ref
-q "${3-HEAD}")
53 head=${head:-$(git show-ref "${3-HEAD}" | cut -d' ' -f2)}
54 head=${head:-$(git rev-parse --quiet --verify "$3")}
56 # None of the above? Bad.
57 test -z "$head" && die
"fatal: Not a valid revision: $3"
59 # This also verifies that the resulting head is unique:
60 # "git show-ref" could have shown multiple matching refs..
61 headrev
=$
(git rev-parse
--verify --quiet "$head"^
0)
62 test -z "$headrev" && die
"fatal: Ambiguous revision: $3"
64 # Was it a branch with a description?
65 branch_name
=${head#refs/heads/}
66 if test "z$branch_name" = "z$headref" ||
67 ! git config
"branch.$branch_name.description" >/dev
/null
72 prettyhead
=${head#refs/}
73 prettyhead
=${prettyhead#heads/}
75 merge_base
=$
(git merge-base
$baserev $headrev) ||
76 die
"fatal: No commits in common between $base and $head"
78 # $head is the refname from the command line.
79 # If a ref with the same name as $head exists at the remote
80 # and their values match, use that.
82 # Otherwise find a random ref that matches $headrev.
86 my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
87 next unless ($sha1 eq $ARGV[1]);
88 if ($ref eq $ARGV[0]) {
91 if ($sha1 eq $ARGV[0]) {
102 ref
=$
(git ls-remote
"$url" | @@PERL@@
-e "$find_matching_ref" "$head" "$headrev")
106 echo "warn: No match for $prettyhead found at $url" >&2
107 echo "warn: Are you sure you pushed '$prettyhead' there?" >&2
111 url
=$
(git ls-remote
--get-url "$url")
113 git show
-s --format='The following changes since commit %H:
117 are available in the git repository at:
119 echo " $url $prettyhead" &&
120 git show
-s --format='
121 for you to fetch changes up to %H:
125 ----------------------------------------------------------------' $headrev &&
127 if test -n "$branch_name"
129 echo "(from the branch description for $branch_name local branch)"
131 git config
"branch.$branch_name.description"
132 echo "----------------------------------------------------------------"
135 git shortlog ^
$baserev $headrev &&
136 git
diff -M --stat --summary $patch $merge_base..
$headrev || status
=1