@@ -62,6 +62,11 @@ verify_cherries() {
62
62
# Check each commit in <current>..<upstream>
63
63
backport_sha=$( get_backport " $sha " )
64
64
65
+ if [[ " $backport_sha " == " nothing" ]]; then
66
+ echo " ✓ \` $sha \` backports nothing"
67
+ continue
68
+ fi
69
+
65
70
if [[ -z " $backport_sha " ]]; then
66
71
no_backports+=(" $sha " )
67
72
continue
@@ -88,8 +93,8 @@ verify_cherries() {
88
93
done
89
94
echo
90
95
echo " do not match any commits in \` $1 \` . If this was intended, add the text"
91
- echo ' \`backport-of: <SHA of a commit already in master>\` somewhere in the '
92
- echo ' message of each of these commits.'
96
+ echo ' \`backport-of: <SHA of a commit already in master>\`'
97
+ echo ' somewhere in the message of each of these commits.'
93
98
echo
94
99
failure=1
95
100
fi
@@ -112,12 +117,27 @@ verify_cherries() {
112
117
return $failure
113
118
}
114
119
115
- # Get the backport of a commit, or empty string if it does not exist.
120
+ # Get the backport of a commit. It echoes one of:
121
+ #
122
+ # 1. A SHA of the backported commit
123
+ # 2. The string "nothing"
124
+ # 3. An empty string
116
125
#
117
126
# $1 = <sha>
118
127
get_backport () {
128
+ # This regex is:
129
+ #
130
+ # ^.* - throw away any extra starting characters
131
+ # backport-of: - prefix
132
+ # \s\? - optional space
133
+ # \(\) - capture group
134
+ # [a-f0-9]\+\|nothing - a SHA or the text 'nothing'
135
+ # .* - throw away any extra ending characters
136
+ # \1 - replace it with the first match
137
+ # {s//\1/p;q} - print the first occurrence and quit
138
+ #
119
139
git show -s --format=%B " $1 " \
120
- | sed -n ' s /^.*backport-of:\s\?\([a-f0-9]\+\).*/\1/p'
140
+ | sed -n ' /^.*backport-of:\s\?\([a-f0-9]\+\|nothing\ ).*/{s// \1/p;q} '
121
141
}
122
142
123
143
# Check if a commit is in master.
0 commit comments