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.

101 lines
3.5 KiB

  1. From dae8c59d08d60b32d2bddf367f3686ff87e7c87e Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Wed, 14 Dec 2016 16:44:45 +0100
  4. Subject: [PATCH 03/19] SCRIPTS: git-show-backports: add -H to use the hash of
  5. the commit message
  6. Sometimes certain commits don't contain useful tracking information but
  7. we'd still like to be able to report them. Here we implement a hash on
  8. the author's name, e-mail and date, the subject and the body before the
  9. first s-o-b or cherry-picked line. These parts are supposed to be
  10. reasonable invariant across backports and are usable to compute an
  11. invariant hash of a given commit. When we don't find ancestry in a
  12. commit, we try this method (if -H is specified) to compare commits
  13. hashes and we can report a match. The equivalent commit is reported
  14. as "XXXX+?" to indicate that it's an apparent backport but we don't
  15. know how far it goes.
  16. (cherry picked from commit 5e637e556d12cd4d8b97b4896448ef6f3396224b)
  17. ---
  18. scripts/git-show-backports | 26 ++++++++++++++++++++++++--
  19. 1 file changed, 24 insertions(+), 2 deletions(-)
  20. diff --git a/scripts/git-show-backports b/scripts/git-show-backports
  21. index ca7ad4f..1569701 100755
  22. --- a/scripts/git-show-backports
  23. +++ b/scripts/git-show-backports
  24. @@ -28,7 +28,7 @@
  25. # show-backports -q -m -r hapee-r2 hapee-r1
  26. -USAGE="Usage: ${0##*/} [-q] [-m] [-u] [-r reference] [-l logexpr] [-s subject] [-b base] {branch|range} [...]"
  27. +USAGE="Usage: ${0##*/} [-q] [-H] [-m] [-u] [-r reference] [-l logexpr] [-s subject] [-b base] {branch|range} [...]"
  28. BASES=( )
  29. BRANCHES=( )
  30. REF=master
  31. @@ -38,6 +38,7 @@ LOGEXPR=
  32. SUBJECT=
  33. MISSING=
  34. UPSTREAM=
  35. +BODYHASH=
  36. die() {
  37. [ "$#" -eq 0 ] || echo "$*" >&2
  38. @@ -75,10 +76,12 @@ dump_commit_matrix() {
  39. upstream="none"
  40. missing=0
  41. + refbhash=""
  42. line=""
  43. for branch in "${BRANCHES[@]}"; do
  44. set -- $(grep -m 1 $ref "$WORK/${branch//\//_}")
  45. newhash=$1 ; shift
  46. + bhash=""
  47. # count the number of cherry-picks after this one. Since we shift,
  48. # the result is in "$#"
  49. while [ -n "$1" -a "$1" != "$ref" ]; do
  50. @@ -108,6 +111,19 @@ dump_commit_matrix() {
  51. break
  52. fi
  53. done
  54. + if [ -z "$newhash" -a -n "$BODYHASH" ]; then
  55. + if [ -z "$refbhash" ]; then
  56. + refbhash=$(git log -1 --pretty="%an|%ae|%at|%B" "$ref" | sed -n '/^\(Signed-off-by\|(cherry picked\)/q;p' | md5sum)
  57. + fi
  58. +
  59. +
  60. + set -- $(grep -m 1 "H$refbhash\$" "$WORK/${branch//\//_}")
  61. + newhash=$1 ; shift
  62. + if [ -n "$newhash" ]; then
  63. + line="${line} $(short $newhash)+?"
  64. + break
  65. + fi
  66. + fi
  67. if [ -z "$newhash" ]; then
  68. line="${line} -"
  69. missing=1
  70. @@ -136,6 +152,7 @@ while [ -n "$1" -a -z "${1##-*}" ]; do
  71. -q) QUIET=1 ; shift ;;
  72. -m) MISSING=1 ; shift ;;
  73. -u) UPSTREAM=1 ; shift ;;
  74. + -H) BODYHASH=1 ; shift ;;
  75. -h|--help) quit "$USAGE" ;;
  76. *) die "$USAGE" ;;
  77. esac
  78. @@ -194,8 +211,13 @@ while [ $branch_num -lt "${#BRANCHES[@]}" ]; do
  79. base="${base:-$BASE}"
  80. rm -f "$WORK/${branch//\//_}"
  81. git log --reverse --pretty="%H %s" "$base".."$branch" | grep "${SUBJECT}" | while read h subject; do
  82. - echo "$h" $(git log -1 --pretty --format=%B "$h" | \
  83. + echo -n "$h" $(git log -1 --pretty --format=%B "$h" | \
  84. sed -n 's/^commit \([^)]*\) upstream\.$/\1/p;s/^(cherry picked from commit \([^)]*\))/\1/p')
  85. + if [ -n "$BODYHASH" ]; then
  86. + echo " H$(git log -1 --pretty="%an|%ae|%at|%B" "$h" | sed -n '/^\(Signed-off-by\|(cherry picked\)/q;p' | md5sum)"
  87. + else
  88. + echo
  89. + fi
  90. done > "$WORK/${branch//\//_}"
  91. (( branch_num++ ))
  92. done
  93. --
  94. 2.10.2