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