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 / ||
32 /^Needs? / || /^Expecting / || /^May want to /) {
38 my ($branch) = $ARGV[0];
39 my ($in_section, $in_desc);
47 last if (/^[-*\[]/ && $in_section);
48 next unless $in_section;
53 next unless ($in_section && $in_desc);
54 next if (/Originally merged to '\''next'\'' on ([-0-9]+)/);
55 next if (wildo_match($_));
59 if ($in_section && @msg) {
60 open(my $fh, "-|", qw(git cat-file commit HEAD));
61 my @original = (<$fh>);
67 $in_section = 1 if (/^$/);
70 if (/^Conflicts:$/ && $in_section == 2) {
74 if ($in_section == 3) {
78 if (/^$/ && $in_section == 1) {
84 open($fh, "|-", qw(git commit --amend -F -));
88 ' <Meta
/whats-cooking.txt
"$1"
94 if ! git write-tree
2>/dev
/null
>/dev
/null
99 EDITOR
=: git commit
--no-verify
100 echo "Accepted previous resolution"
106 test -n "$stop_at_cut" && return
108 count_since_last_cut
=$
(( $count_since_last_cut + 1 ))
109 test -z "$prev_cut" && return
110 git commit
--allow-empty -m "$prev_cut"
114 cut_seen
=0 prev_cut
= count_since_last_cut
=0
117 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
118 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
120 continue ;# slurp the remainder and skip
125 if test "$count_since_last_cut" = 0
129 echo >&2 "$branch $eh"
130 prev_cut
="$branch $eh"
131 count_since_last_cut
=0
142 save
=$
(git rev-parse
--verify HEAD
) &&
143 tip
=$
(git rev-parse
--verify "$branch^0") &&
144 mb
=$
(git merge-base
"$tip" "$save") ||
147 test "$mb" = "$tip" && continue
151 EDITOR
=: git merge
$accept_rerere --edit "$branch" ||
155 annotate_merge
"$branch" ||
exit
157 git commit
--amend ||
exit
159 this
=$
(git rev-parse
--verify HEAD
)
160 if test "$this" = "$save"
163 elif git show-ref
-q --verify "refs/merge-fix/$branch"
165 echo >&2 "Fixing up the merge"
166 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
167 EDITOR
=: git commit
--amend -a ||
exit
175 git cherry-pick
"$branch" ||
exit ;;
176 *) echo >&2 "Eh? $branch $eh"; exit ;;
182 if test -n "$update" && test $# = 0
184 set x $
(sed -n -e '2s/^# //p' <"$update") &&
188 # Generation (or updating)
190 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
191 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
197 "Merge branch '"*"'"*)
198 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
201 "Merge remote branch '"*"'"*)
202 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
206 echo 2>&1 "Huh?: $msg"
210 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
211 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
212 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
213 test "$merged" != undefined ||
{
214 other
=$
(git log
-1 --pretty='format:%s' $other) &&
215 merged
="$branch :rebased? $other"
225 merged
="$(git rev-parse --verify "$commit") pick $msg"
236 echo 'case "$#,$1" in'
238 echo " exec $PROGRAM" '"$1" "$0"'
240 echo "$PROGRAM" '"$@" <<\EOF'
241 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
244 while read commit msg
246 if other
=$
(git rev-parse
-q --verify "$commit^2")
257 series
="$merged$LF$series"
270 generate
"$0" "$@" |
diff -w -u "$update" -
273 echo >&2 "No changes."
275 echo >&2 -n "Update [y/N]? "
280 sed -e 's/ :rebased?.*//' >"$update" ;;
282 echo >&2 "No update then." ;;
286 generate
"$0" "$@" |
diff -w -u "$update" -