3 accept_rerere
="--rerere-autoupdate" generate
=no update
= diff= edit
= stop_at_cut
=
4 while case "$#,$1" in 0,*) break;; *,-*) ;; esac
10 -c?
*) stop_at_cut
=${1#-c} ;;
11 -d) update
=${2?"diff with what?"}
15 -u) update
=${2?"update what?"}
25 test -f Meta
/whats-cooking.txt ||
return 0
30 if (/^Will (?:\S+ ){0,2}(fast-track|keep|merge|drop|discard|cook|kick|defer|be re-?rolled)[,. ]/ ||
31 /^Not urgent/ || /^Not ready/ || /^Waiting for / ||
33 /^Needs? / || /^Expecting / || /^May want to /) {
40 my ($fh, $branch) = @_;
41 my ($in_section, $in_desc);
49 last if (/^[-*\[]/ && $in_section);
50 next unless $in_section;
55 next unless ($in_section && $in_desc);
56 next if (/Originally merged to '\''next'\'' on ([-0-9]+)/);
57 next if (wildo_match($_));
60 return ($in_section, @msg);
63 my ($branch) = $ARGV[0];
64 my ($fh, $in_section, @msg);
65 if (open $fh, "<", "Meta/whats-cooking.txt") {
66 ($in_section, @msg) = read_message($fh, $branch);
70 qw(git -C Meta rev-list -32 HEAD -- whats-cooking.txt);
71 while (my $rev = <$revs>) {
74 qw(git -C Meta cat-file blob), "$rev:whats-cooking.txt";
75 ($in_section, @msg) = read_message($fh, $branch);
80 open(my $fh, "-|", qw(git cat-file commit HEAD));
81 my @original = (<$fh>);
87 $in_section = 1 if (/^$/);
90 if (/^Conflicts:$/ && $in_section == 2) {
94 if ($in_section == 3) {
98 if (/^$/ && $in_section == 1) {
104 open($fh, "|-", qw(git commit --amend -F -));
114 if ! git write-tree
2>/dev
/null
>/dev
/null
119 GIT_EDITOR
=: git commit
--no-verify
120 echo "Accepted previous resolution"
126 test -n "$stop_at_cut" && return
128 count_since_last_cut
=$
(( $count_since_last_cut + 1 ))
129 test -z "$prev_cut" && return
130 git commit
--allow-empty -m "$prev_cut"
134 cut_seen
=0 prev_cut
= count_since_last_cut
=0
137 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
138 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
140 continue ;# slurp the remainder and skip
145 if test "$count_since_last_cut" = 0
149 echo >&2 "$branch $eh"
150 prev_cut
="$branch $eh"
151 count_since_last_cut
=0
162 save
=$
(git rev-parse
--verify HEAD
) &&
163 tip
=$
(git rev-parse
--verify "$branch^0") &&
164 mb
=$
(git merge-base
"$tip" "$save") ||
167 test "$mb" = "$tip" && continue
171 rebuild
=$
(git config
"branch.$branch.rebuild" ||
:)
173 GIT_EDITOR
=: git merge
$rebuild $accept_rerere --edit "$branch" ||
177 annotate_merge
"$branch" ||
exit
179 git commit
--amend ||
exit
181 this
=$
(git rev-parse
--verify HEAD
)
182 if test "$this" = "$save"
185 elif git show-ref
-q --verify "refs/merge-fix/$branch"
187 echo >&2 "Fixing up the merge"
188 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
189 git
diff --stat HEAD
&&
190 GIT_EDITOR
=: git commit
--amend -a ||
exit
198 git cherry-pick
"$branch" ||
exit ;;
199 *) echo >&2 "Eh? $branch $eh"; exit ;;
205 if test -n "$update" && test $# = 0
207 set x $
(sed -n -e '2s/^# //p' <"$update") &&
211 # Generation (or updating)
213 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
214 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
220 "Merge branch '"*"'"*)
221 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
224 "Merge remote branch '"*"'"*)
225 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
229 echo 2>&1 "Huh?: $msg"
233 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
234 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
235 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
236 test "$merged" != undefined ||
{
237 other
=$
(git log
-1 --pretty='format:%s' $other) &&
238 merged
="$branch :rebased? $other"
248 merged
="$(git rev-parse --verify "$commit") pick $msg"
259 echo 'case "$#,$1" in'
261 echo " exec $PROGRAM" '"$1" "$0"'
263 echo "$PROGRAM" '"$@" <<\EOF'
264 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
267 while read commit msg
269 if other
=$
(git rev-parse
-q --verify "$commit^2")
280 series
="$merged$LF$series"
293 generate
"$0" "$@" |
diff -w -u "$update" -
296 echo >&2 "No changes."
298 echo >&2 -n "Update [y/N]? "
303 sed -e 's/ :rebased?.*//' >"$update" ;;
305 echo >&2 "No update then." ;;
309 generate
"$0" "$@" |
diff -w -u "$update" -