3 accept_rerere
="--rerere-autoupdate"
6 update
= diff= edit
= stop_at_cut
= skip_cocci
= force_cocci
= no_cocci
=
7 while case "$#,$1" in 0,*) break;; *,-*) ;; esac
13 -c?
*) stop_at_cut
=${1#-c} ;;
14 -d) update
=${2?"diff with what?"}
18 -u) update
=${2?"update what?"}
21 -x) exec=${2?exec}; shift ;;
33 test -f Meta
/whats-cooking.txt ||
return 0
35 # NEEDSWORK: unify with cook::wildo_match
39 if (/^Will (?:\S+ ){0,2}(fast-track|hold|keep|merge|drop|discard|cook|kick|defer|eject|be re-?rolled|wait)[,. ]/ ||
40 /^Not urgent/ || /^Not ready/ || /^Waiting for / ||
41 /^Can wait in / || /^Still / || /^Stuck / || /^On hold/ || /^Breaks / ||
42 /^Needs? / || /^Expecting / || /^May want to / || /^Under review/) {
49 my ($fh, $branch) = @_;
50 my ($in_section, $in_desc);
54 if (/^\* \Q$branch\E /) {
58 last if (/^[-*\[]/ && $in_section);
59 next unless $in_section;
64 next unless ($in_section && $in_desc);
65 next if (/Originally merged to '\''next'\'' on ([-0-9]+)/);
66 next if (/^source: /);
67 last if (wildo_match($_));
70 return ($in_section, @msg);
73 my ($branch) = $ARGV[0];
74 my ($fh, $in_section, @msg);
75 if (open $fh, "<", "Meta/whats-cooking.txt") {
76 ($in_section, @msg) = read_message($fh, $branch);
80 qw(git -C Meta rev-list -32 HEAD -- whats-cooking.txt);
81 while (my $rev = <$revs>) {
84 qw(git -C Meta cat-file blob), "$rev:whats-cooking.txt";
85 ($in_section, @msg) = read_message($fh, $branch);
90 open(my $fh, "-|", qw(git cat-file commit HEAD));
91 my @original = (<$fh>);
97 $in_section = 1 if (/^$/);
100 if (/^Conflicts:$/ && $in_section == 2) {
104 if ($in_section == 3) {
108 if (/^$/ && $in_section == 1) {
114 open($fh, "|-", qw(git commit --amend -F -));
121 cocci_mark
="treewide: apply cocci patch"
126 if ! git write-tree
2>/dev
/null
>/dev
/null
131 GIT_EDITOR
=: git commit
--no-verify
132 echo "Accepted previous resolution"
138 test -n "$stop_at_cut" && return
140 count_since_last_cut
=$
(( $count_since_last_cut + 1 ))
141 test -z "$prev_cut" && return
142 git commit
--allow-empty -m "$prev_cut"
146 cut_seen
=0 prev_cut
= count_since_last_cut
=0 cocci_count
=0
149 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
150 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
152 continue ;# slurp the remainder and skip
157 if test "$count_since_last_cut" = 0
161 echo >&2 "$branch $eh"
162 prev_cut
="$branch $eh"
163 count_since_last_cut
=0
167 if test -n "$no_cocci"
170 elif test 0 = "$cocci_count" && test -z "$force_cocci"
175 if test -n "$skip_cocci" && test -n "$eh"
177 git cherry-pick
--no-commit "$eh"
179 rm -f contrib
/coccinelle
/*.
patch
180 Meta
/Make
-j8 coccicheck
181 if grep coccicheck-pending Makefile
>/dev
/null
183 Meta
/Make
-j8 coccicheck-pending
185 cat contrib
/coccinelle
/*.
patch >cocci.
patch
186 if ! test -s cocci.
patch
190 git apply
--index -3 cocci.
patch ||
exit
192 git
diff --quiet HEAD
&& continue
194 git commit
-m "$cocci_mark" ||
exit
204 "" |
"#"* |
[0-9][0-9]-[0-9][0-9]*)
207 save
=$
(git rev-parse
--verify HEAD
) &&
208 tip
=$
(git rev-parse
--verify "$branch^0") &&
209 mb
=$
(git merge-base
"$tip" "$save") ||
212 test "$mb" = "$tip" && continue
215 cocci_count
=$
(( $cocci_count + 1 ))
217 rebuild
=$
(git config
"branch.$branch.rebuild" ||
:)
219 GIT_EDITOR
=: git merge
--no-ff $rebuild $accept_rerere --edit "$branch" ||
223 annotate_merge
"$branch" ||
exit
225 git commit
--amend ||
exit
227 this
=$
(git rev-parse
--verify HEAD
)
228 if test "$this" = "$save"
231 elif git show-ref
-q --verify "refs/merge-fix/$branch"
233 echo >&2 "Fixing up the merge"
234 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
235 git
diff --stat HEAD
&&
236 GIT_EDITOR
=: git commit
--amend -a ||
exit
244 git cherry-pick
"$branch" ||
exit ;;
245 *) echo >&2 "Eh? $branch $eh"; exit ;;
253 if test -n "$update" && test $# = 0
255 set x $
(sed -n -e '2s/^# //p' <"$update") &&
259 # Generation (or updating)
261 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
262 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
268 "Merge branch '"*"'"*)
269 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
272 "Merge remote branch '"*"'"*)
273 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
277 echo 2>&1 "Huh?: $msg"
281 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
282 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
283 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
284 test "$merged" != undefined ||
{
285 other
=$
(git log
-1 --pretty='format:%s' $other) &&
286 merged
="$branch :rebased? $other"
296 merged
="$(git rev-parse --verify "$commit") pick $msg"
307 echo 'case "$#,$1" in'
309 echo " exec $PROGRAM" '"$1" "$0"'
311 echo "$PROGRAM" '"$@" <<\EOF'
312 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
315 while read commit msg
317 if other
=$
(git rev-parse
-q --verify "$commit^2")
320 elif test "$msg" = "$cocci_mark"
322 merged
="#cocci "$
(git rev-parse
"$commit^0")
331 series
="$merged$LF$series"
344 generate
"$0" "$@" |
diff -w -u "$update" -
347 echo >&2 "No changes."
349 echo >&2 -n "Update [y/N]? "
354 sed -e 's/ :rebased?.*//' >"$update" ;;
356 echo >&2 "No update then." ;;
360 generate
"$0" "$@" |
diff -w -u "$update" -