THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
4.0KB

  1. #!/bin/sh
  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. SUBDIRECTORY_OK='Yes'
  7. OPTIONS_KEEPDASHDASH=
  8. OPTIONS_STUCKLONG=
  9. OPTIONS_SPEC='git request-pull [options] start url [end]
  10. --
  11. p show patch text as well
  12. '
  13. . git-sh-setup
  14. GIT_PAGER=
  15. export GIT_PAGER
  16. patch=
  17. while case "$#" in 0) break ;; esac
  18. do
  19. case "$1" in
  20. -p)
  21. patch=-p ;;
  22. --)
  23. shift; break ;;
  24. -*)
  25. usage ;;
  26. *)
  27. break ;;
  28. esac
  29. shift
  30. done
  31. base=$1 url=$2 status=0
  32. test -n "$base" && test -n "$url" || usage
  33. baserev=$(git rev-parse --verify --quiet "$base"^0)
  34. if test -z "$baserev"
  35. then
  36. die "fatal: Not a valid revision: $base"
  37. fi
  38. #
  39. # $3 must be a symbolic ref, a unique ref, or
  40. # a SHA object expression. It can also be of
  41. # the format 'local-name:remote-name'.
  42. #
  43. local=${3%:*}
  44. local=${local:-HEAD}
  45. remote=${3#*:}
  46. pretty_remote=${remote#refs/}
  47. pretty_remote=${pretty_remote#heads/}
  48. head=$(git symbolic-ref -q "$local")
  49. head=${head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)}
  50. head=${head:-$(git rev-parse --quiet --verify "$local")}
  51. # None of the above? Bad.
  52. test -z "$head" && die "fatal: Not a valid revision: $local"
  53. # This also verifies that the resulting head is unique:
  54. # "git show-ref" could have shown multiple matching refs..
  55. headrev=$(git rev-parse --verify --quiet "$head"^0)
  56. test -z "$headrev" && die "fatal: Ambiguous revision: $local"
  57. local_sha1=$(git rev-parse --verify --quiet "$head")
  58. # Was it a branch with a description?
  59. branch_name=${head#refs/heads/}
  60. if test "z$branch_name" = "z$headref" ||
  61. ! git config "branch.$branch_name.description" >/dev/null
  62. then
  63. branch_name=
  64. fi
  65. merge_base=$(git merge-base $baserev $headrev) ||
  66. die "fatal: No commits in common between $base and $head"
  67. # $head is the refname from the command line.
  68. # Find a ref with the same name as $head that exists at the remote
  69. # and points to the same commit as the local object.
  70. find_matching_ref='
  71. my ($head,$headrev) = (@ARGV);
  72. my $pattern = qr{/\Q$head\E$};
  73. my ($remote_sha1, $found);
  74. while (<STDIN>) {
  75. chomp;
  76. my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
  77. if ($sha1 eq $head) {
  78. $found = $remote_sha1 = $sha1;
  79. break;
  80. }
  81. if ($ref eq $head || $ref =~ $pattern) {
  82. if ($deref eq "") {
  83. # Remember the matching object on the remote side
  84. $remote_sha1 = $sha1;
  85. }
  86. if ($sha1 eq $headrev) {
  87. $found = $ref;
  88. break;
  89. }
  90. }
  91. }
  92. if ($found) {
  93. $remote_sha1 = $headrev if ! defined $remote_sha1;
  94. print "$remote_sha1 $found\n";
  95. }
  96. '
  97. set fnord $(git ls-remote "$url" | @@PERL@@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
  98. remote_sha1=$2
  99. ref=$3
  100. if test -z "$ref"
  101. then
  102. echo "warn: No match for commit $headrev found at $url" >&2
  103. echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
  104. status=1
  105. elif test "$local_sha1" != "$remote_sha1"
  106. then
  107. echo "warn: $head found at $url but points to a different object" >&2
  108. echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
  109. status=1
  110. fi
  111. # Special case: turn "for_linus" to "tags/for_linus" when it is correct
  112. if test "$ref" = "refs/tags/$pretty_remote"
  113. then
  114. pretty_remote=tags/$pretty_remote
  115. fi
  116. url=$(git ls-remote --get-url "$url")
  117. git show -s --format='The following changes since commit %H:
  118. %s (%ci)
  119. are available in the Git repository at:
  120. ' $merge_base &&
  121. echo " $url $pretty_remote" &&
  122. git show -s --format='
  123. for you to fetch changes up to %H:
  124. %s (%ci)
  125. ----------------------------------------------------------------' $headrev &&
  126. if test $(git cat-file -t "$head") = tag
  127. then
  128. git cat-file tag "$head" |
  129. sed -n -e '1,/^$/d' -e '/^-----BEGIN PGP /q' -e p
  130. echo
  131. echo "----------------------------------------------------------------"
  132. fi &&
  133. if test -n "$branch_name"
  134. then
  135. echo "(from the branch description for $branch_name local branch)"
  136. echo
  137. git config "branch.$branch_name.description"
  138. echo "----------------------------------------------------------------"
  139. fi &&
  140. git shortlog ^$baserev $headrev &&
  141. git diff -M --stat --summary $patch $merge_base..$headrev || status=1
  142. exit $status