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"
131 my ($mode, $sha1, $stage, $path) =
132 /^([0-7]+) ([0-9a-f]+) ([0-3]) (.*)$/;
133 $path_stage{$path} ||= 0;
134 $path_stage{$path} |= (1 << ($stage - 1));
137 while (my ($path, $bits) = each %path_stage) {
138 if ($bits == 3 || $bits == 5) {
139 push @to_remove, $path;
143 system(qw(git rm -f), @to_remove);
147 if ! git write-tree
2>/dev
/null
>/dev
/null
152 GIT_EDITOR
=: git commit
--no-verify
153 echo "Accepted previous resolution"
159 test -n "$stop_at_cut" && return
161 count_since_last_cut
=$
(( $count_since_last_cut + 1 ))
162 test -z "$prev_cut" && return
163 git commit
--allow-empty -m "$prev_cut"
168 if original_branch
=$
(git symbolic-ref HEAD
2>/dev
/null
)
170 original_branch
=${original_branch#refs/heads/}
171 git checkout
--quiet --detach
172 into
="--into $original_branch"
181 if test -n "$original_branch" && ! git symbolic-ref HEAD
2>/dev
/null
183 git checkout
--quiet -B "$original_branch"
192 cut_seen
=0 prev_cut
= count_since_last_cut
=0 cocci_count
=0
196 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
197 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
199 continue ;# slurp the remainder and skip
204 if test "$count_since_last_cut" = 0
208 echo >&2 "$branch $eh"
209 prev_cut
="$branch $eh"
210 count_since_last_cut
=0
214 if test -n "$no_cocci"
217 elif test 0 = "$cocci_count" && test -z "$force_cocci"
222 if test -n "$skip_cocci" && test -n "$eh"
224 git cherry-pick
--no-commit "$eh"
226 rm -f contrib
/coccinelle
/*.
patch
227 Meta
/Make
-j8 coccicheck
228 if grep coccicheck-pending Makefile
>/dev
/null
230 Meta
/Make
-j8 coccicheck-pending
232 cat contrib
/coccinelle
/*.
patch >cocci.
patch
233 if ! test -s cocci.
patch
237 git apply
--index -3 cocci.
patch || leave $?
239 git
diff --quiet HEAD
&& continue
241 git commit
-m "$cocci_mark" || leave $?
251 "" |
"#"* |
[0-9][0-9]-[0-9][0-9]*)
254 save
=$
(git rev-parse
--verify HEAD
) &&
255 tip
=$
(git rev-parse
--verify "$branch^0") &&
256 mb
=$
(git merge-base
"$tip" "$save") ||
259 test "$mb" = "$tip" && continue
262 cocci_count
=$
(( $cocci_count + 1 ))
264 rebuild
=$
(git config
"branch.$branch.rebuild" ||
:)
266 GIT_EDITOR
=: git merge
--no-ff $into $rebuild $accept_rerere --edit "$branch" ||
270 annotate_merge
"$branch" || leave $?
272 git commit
--amend || leave $?
274 this
=$
(git rev-parse
--verify HEAD
)
275 if test "$this" = "$save"
278 elif git show-ref
-q --verify "refs/merge-fix/$branch"
280 echo >&2 "Fixing up the merge"
281 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
282 git
diff --stat HEAD
&&
283 GIT_EDITOR
=: git commit
--amend -a || leave $?
291 git cherry-pick
"$branch" || leave $?
;;
292 *) echo >&2 "Eh? $branch $eh"; leave $?
;;
295 eval "$exec" || leave $?
301 if test -n "$update" && test $# = 0
303 set x $
(sed -n -e '2s/^# //p' <"$update") &&
307 # Generation (or updating)
309 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
310 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
316 "Merge branch '"*"'"*)
317 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
320 "Merge remote branch '"*"'"*)
321 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
325 echo 2>&1 "Huh?: $msg"
329 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
330 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
331 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
332 test "$merged" != undefined ||
{
333 other
=$
(git log
-1 --pretty='format:%s' $other) &&
334 merged
="$branch :rebased? $other"
344 merged
="$(git rev-parse --verify "$commit") pick $msg"
355 echo 'case "$#,$1" in'
357 echo " exec $PROGRAM" '"$1" "$0"'
359 echo "$PROGRAM" '"$@" <<\EOF'
360 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
363 while read commit msg
365 if other
=$
(git rev-parse
-q --verify "$commit^2")
368 elif test "$msg" = "$cocci_mark"
370 merged
="#cocci "$
(git rev-parse
"$commit^0")
379 series
="$merged$LF$series"
392 generate
"$0" "$@" |
diff -w -u "$update" -
395 echo >&2 "No changes."
397 echo >&2 -n "Update [y/N]? "
402 sed -e 's/ :rebased?.*//' >"$update" ;;
404 echo >&2 "No update then." ;;
408 generate
"$0" "$@" |
diff -w -u "$update" -