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")
145 test "$mb" = "$tip" && continue
149 EDITOR
=: git merge
$accept_rerere --edit "$branch" ||
153 annotate_merge
"$branch" ||
exit
155 git commit
--amend ||
exit
157 this
=$
(git rev-parse
--verify HEAD
)
158 if test "$this" = "$save"
161 elif git show-ref
-q --verify "refs/merge-fix/$branch"
163 echo >&2 "Fixing up the merge"
164 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
165 EDITOR
=: git commit
--amend -a ||
exit
173 git cherry-pick
"$branch" ||
exit ;;
174 *) echo >&2 "Eh? $branch $eh"; exit ;;
180 if test -n "$update" && test $# = 0
182 set x $
(sed -n -e '2s/^# //p' <"$update") &&
186 # Generation (or updating)
188 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
189 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
195 "Merge branch '"*"'"*)
196 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
199 "Merge remote branch '"*"'"*)
200 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
204 echo 2>&1 "Huh?: $msg"
208 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
209 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
210 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
211 test "$merged" != undefined ||
{
212 other
=$
(git log
-1 --pretty='format:%s' $other) &&
213 merged
="$branch :rebased? $other"
223 merged
="$(git rev-parse --verify "$commit") pick $msg"
234 echo 'case "$#,$1" in'
236 echo " exec $PROGRAM" '"$1" "$0"'
238 echo "$PROGRAM" '"$@" <<\EOF'
239 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
242 while read commit msg
244 if other
=$
(git rev-parse
-q --verify "$commit^2")
255 series
="$merged$LF$series"
268 generate
"$0" "$@" |
diff -u "$update" -
271 echo >&2 "No changes."
273 echo >&2 -n "Update [y/N]? "
278 sed -e 's/ :rebased?.*//' >"$update" ;;
280 echo >&2 "No update then." ;;
284 generate
"$0" "$@" |
diff -u "$update" -