#!/bin/sh # Copyright 2005, Ryan Anderson # # This file is licensed under the GPL v2, or a later version # at the discretion of Linus Torvalds. setglobal USAGE = '' []'' setglobal LONG_USAGE = ''Summarizes the changes between two commits to the standard output, and includes the given URL in the generated summary.'' setglobal SUBDIRECTORY_OK = ''Yes'' setglobal OPTIONS_KEEPDASHDASH = '' setglobal OPTIONS_STUCKLONG = '' setglobal OPTIONS_SPEC = ''git request-pull [options] start url [end] -- p show patch text as well '' source git-sh-setup setglobal GIT_PAGER = '' export GIT_PAGER setglobal patch = '' while case "$#" in 0) break ;; esac { match $1 { with -p setglobal patch = '-p' with -- shift; break with -* usage with * break } shift } setglobal base = $1, url = $2, status = '0' test -n $base && test -n $url || usage setglobal baserev = $[git rev-parse --verify --quiet "$base"^0] if test -z $baserev { die "fatal: Not a valid revision: $base" } # # $3 must be a symbolic ref, a unique ref, or # a SHA object expression. It can also be of # the format 'local-name:remote-name'. # setglobal local = $(3%:*) setglobal local = $(local:-HEAD) setglobal remote = $(3#*:) setglobal pretty_remote = $(remote#refs/) setglobal pretty_remote = $(pretty_remote#heads/) setglobal head = $[git symbolic-ref -q $local] setglobal head = $(head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)) setglobal head = $(head:-$(git rev-parse --quiet --verify "$local")) # None of the above? Bad. test -z $head && die "fatal: Not a valid revision: $local" # This also verifies that the resulting head is unique: # "git show-ref" could have shown multiple matching refs.. setglobal headrev = $[git rev-parse --verify --quiet "$head"^0] test -z $headrev && die "fatal: Ambiguous revision: $local" # Was it a branch with a description? setglobal branch_name = $(head#refs/heads/) if test "z$branch_name" = "z$headref" || ! git config "branch.$branch_name.description" >/dev/null { setglobal branch_name = '' } setglobal merge_base = $[git merge-base $baserev $headrev] || die "fatal: No commits in common between $base and $head" # $head is the refname from the command line. # If a ref with the same name as $head exists at the remote # and their values match, use that. # # Otherwise find a random ref that matches $headrev. setglobal find_matching_ref = '' my ($head,$headrev) = (@ARGV); my ($found); while () { chomp; my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/; my ($pattern); next unless ($sha1 eq $headrev); $pattern="/$head\$"; if ($ref eq $head) { $found = $ref; } if ($ref =~ /$pattern/) { $found = $ref; } if ($sha1 eq $head) { $found = $sha1; } } if ($found) { print "$found\n"; } '' setglobal ref = $[git ls-remote $url | @@PERL@@ -e $find_matching_ref $(remote:-HEAD) $headrev] if test -z $ref { echo "warn: No match for commit $headrev found at $url" > !2 echo "warn: Are you sure you pushed '$(remote:-HEAD)' there?" > !2 setglobal status = '1' } # Special case: turn "for_linus" to "tags/for_linus" when it is correct if test $ref = "refs/tags/$pretty_remote" { setglobal pretty_remote = "tags/$pretty_remote" } setglobal url = $[git ls-remote --get-url $url] git show -s --format='The following changes since commit %H: %s (%ci) are available in the git repository at: ' $merge_base && echo " $url $pretty_remote" && git show -s --format=' for you to fetch changes up to %H: %s (%ci) ----------------------------------------------------------------' $headrev && if test $[git cat-file -t $head] = tag { git cat-file tag $head | sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p echo echo "----------------------------------------------------------------" } && if test -n $branch_name { echo "(from the branch description for $branch_name local branch)" echo git config "branch.$branch_name.description" echo "----------------------------------------------------------------" } && git shortlog ^$baserev $headrev && git diff -M --stat --summary $patch $merge_base..$headrev || setglobal status = '1' exit $status