logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

git-request-pull (4171B)


  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. function endswith(s, t) {
  72. n = length(s)
  73. m = length(t)
  74. return m <= n && substr(s, n - m + 1) == t
  75. }
  76. {
  77. sha1 = $1
  78. ref = $2
  79. if (sha1 == head) {
  80. found = remote_sha1 = sha1
  81. exit
  82. }
  83. deref = index(ref, "^")
  84. if (deref)
  85. ref = substr(ref, 1, deref - 1)
  86. if (ref == head || endswith(ref, "/" head)) {
  87. if (!deref) {
  88. # Remember the matching object on the remote side
  89. remote_sha1 = sha1
  90. }
  91. if (sha1 == headrev) {
  92. found = ref
  93. exit
  94. }
  95. }
  96. }
  97. END {
  98. if (found) {
  99. if (!remote_sha1)
  100. remote_sha1 = headrev
  101. print remote_sha1 " " found
  102. }
  103. }
  104. '
  105. set fnord $(git ls-remote "$url" | awk -v "head=${remote:-HEAD}" -v "headrev=$headrev" "$find_matching_ref")
  106. remote_sha1=$2
  107. ref=$3
  108. if test -z "$ref"
  109. then
  110. echo "warn: No match for commit $headrev found at $url" >&2
  111. echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
  112. status=1
  113. elif test "$local_sha1" != "$remote_sha1"
  114. then
  115. echo "warn: $head found at $url but points to a different object" >&2
  116. echo "warn: Are you sure you pushed '${remote:-HEAD}' there?" >&2
  117. status=1
  118. fi
  119. # Special case: turn "for_linus" to "tags/for_linus" when it is correct
  120. if test "$ref" = "refs/tags/$pretty_remote"
  121. then
  122. pretty_remote=tags/$pretty_remote
  123. fi
  124. url=$(git ls-remote --get-url "$url")
  125. git show -s --format='The following changes since commit %H:
  126. %s (%ci)
  127. are available in the Git repository at:
  128. ' $merge_base &&
  129. echo " $url $pretty_remote" &&
  130. git show -s --format='
  131. for you to fetch changes up to %H:
  132. %s (%ci)
  133. ----------------------------------------------------------------' $headrev &&
  134. if test $(git cat-file -t "$head") = tag
  135. then
  136. git cat-file tag "$head" |
  137. sed -n -e '1,/^$/d' -e '/^-----BEGIN \(PGP\|SSH\|SIGNED\) /q' -e p
  138. echo
  139. echo "----------------------------------------------------------------"
  140. fi &&
  141. if test -n "$branch_name"
  142. then
  143. echo "(from the branch description for $branch_name local branch)"
  144. echo
  145. git config "branch.$branch_name.description"
  146. echo "----------------------------------------------------------------"
  147. fi &&
  148. git shortlog ^$baserev $headrev &&
  149. git diff -M --stat --summary $patch $merge_base..$headrev || status=1
  150. exit $status