Meta/Reintegrate: do not apply cocci unless the tip advances

Junio C Hamano committed Oct 26, 2018 at 16:53 UTC 1531073078c00f6ca862930db7e40d89114006d4
1 file changed +13 -3
Reintegrate
+13 -3
@@ -3,7 +3,7 @@
3 accept_rerere="--rerere-autoupdate"
4 generate=no
5 exec=:
6 -update= diff= edit= stop_at_cut= skip_cocci=
6 +update= diff= edit= stop_at_cut= skip_cocci= force_cocci= no_cocci=
7 while case "$#,$1" in 0,*) break;; *,-*) ;; esac
8 do
9 case "$1" in
@@ -21,6 +21,8 @@ do
21 -x) exec=${2?exec}; shift ;;
22 -x?*) exec=${1#-x} ;;
23 -ss) skip_cocci=t ;;
24 + -fs) force_cocci=t ;;
25 + -ns) no_cocci=t ;;
26 *) generate=yes
27 break ;;
28 esac
@@ -139,7 +141,7 @@ no)
141 prev_cut=
142 }
143
142 - cut_seen=0 prev_cut= count_since_last_cut=0
144 + cut_seen=0 prev_cut= count_since_last_cut=0 cocci_count=0
145 while read branch eh
146 do
147 case "$branch" in '###') cut_seen=$(( $cut_seen + 1 )) ;; esac
@@ -160,6 +162,14 @@ no)
162 fi
163 continue ;;
164 '#cocci')
165 + if test -n "$no_cocci"
166 + then
167 + continue
168 + elif test 0 = "$cocci_count" && test -z "$force_cocci"
169 + then
170 + continue
171 + fi
172 +
173 if test -n "$skip_cocci" && test -n "$eh"
174 then
175 git cherry-pick --no-commit "$eh"
@@ -173,7 +183,6 @@ no)
183 git commit -m "$cocci_mark" || exit
184
185 mark_cut
176 -
186 continue
187 ;;
188 '#'* | '')
@@ -192,6 +201,7 @@ no)
201 test "$mb" = "$tip" && continue
202
203 mark_cut
204 + cocci_count=$(( $cocci_count + 1 ))
205
206 rebuild=$(git config "branch.$branch.rebuild" || :)
207