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 /) {
39 my ($branch) = $ARGV[0];
40 my ($in_section, $in_desc);
48 last if (/^[-*\[]/ && $in_section);
49 next unless $in_section;
54 next unless ($in_section && $in_desc);
55 next if (/Originally merged to '\''next'\'' on ([-0-9]+)/);
56 next if (wildo_match($_));
60 if ($in_section && @msg) {
61 open(my $fh, "-|", qw(git cat-file commit HEAD));
62 my @original = (<$fh>);
68 $in_section = 1 if (/^$/);
71 if (/^Conflicts:$/ && $in_section == 2) {
75 if ($in_section == 3) {
79 if (/^$/ && $in_section == 1) {
85 open($fh, "|-", qw(git commit --amend -F -));
89 ' <Meta
/whats-cooking.txt
"$1"
95 if ! git write-tree
2>/dev
/null
>/dev
/null
100 EDITOR
=: git commit
--no-verify
101 echo "Accepted previous resolution"
107 test -n "$stop_at_cut" && return
109 count_since_last_cut
=$
(( $count_since_last_cut + 1 ))
110 test -z "$prev_cut" && return
111 git commit
--allow-empty -m "$prev_cut"
115 cut_seen
=0 prev_cut
= count_since_last_cut
=0
118 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
119 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
121 continue ;# slurp the remainder and skip
126 if test "$count_since_last_cut" = 0
130 echo >&2 "$branch $eh"
131 prev_cut
="$branch $eh"
132 count_since_last_cut
=0
143 save
=$
(git rev-parse
--verify HEAD
) &&
144 tip
=$
(git rev-parse
--verify "$branch^0") &&
145 mb
=$
(git merge-base
"$tip" "$save") ||
148 test "$mb" = "$tip" && continue
152 EDITOR
=: git merge
$accept_rerere --edit "$branch" ||
156 annotate_merge
"$branch" ||
exit
158 git commit
--amend ||
exit
160 this
=$
(git rev-parse
--verify HEAD
)
161 if test "$this" = "$save"
164 elif git show-ref
-q --verify "refs/merge-fix/$branch"
166 echo >&2 "Fixing up the merge"
167 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
168 EDITOR
=: git commit
--amend -a ||
exit
176 git cherry-pick
"$branch" ||
exit ;;
177 *) echo >&2 "Eh? $branch $eh"; exit ;;
183 if test -n "$update" && test $# = 0
185 set x $
(sed -n -e '2s/^# //p' <"$update") &&
189 # Generation (or updating)
191 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
192 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
198 "Merge branch '"*"'"*)
199 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
202 "Merge remote branch '"*"'"*)
203 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
207 echo 2>&1 "Huh?: $msg"
211 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
212 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
213 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
214 test "$merged" != undefined ||
{
215 other
=$
(git log
-1 --pretty='format:%s' $other) &&
216 merged
="$branch :rebased? $other"
226 merged
="$(git rev-parse --verify "$commit") pick $msg"
237 echo 'case "$#,$1" in'
239 echo " exec $PROGRAM" '"$1" "$0"'
241 echo "$PROGRAM" '"$@" <<\EOF'
242 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
245 while read commit msg
247 if other
=$
(git rev-parse
-q --verify "$commit^2")
258 series
="$merged$LF$series"
271 generate
"$0" "$@" |
diff -w -u "$update" -
274 echo >&2 "No changes."
276 echo >&2 -n "Update [y/N]? "
281 sed -e 's/ :rebased?.*//' >"$update" ;;
283 echo >&2 "No update then." ;;
287 generate
"$0" "$@" |
diff -w -u "$update" -