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
28 my ($branch) = $ARGV[0];
29 my ($in_section, $in_desc);
37 last if (/^[-*\[]/ && $in_section);
38 next unless $in_section;
43 next unless ($in_section && $in_desc);
47 if ($in_section && @msg) {
48 open(my $fh, "-|", qw(git cat-file commit HEAD));
49 my @original = (<$fh>);
54 $in_section = 1 if (/^$/);
58 if (/^$/ && $in_section == 1) {
65 open($fh, "|-", qw(git commit --amend -F -));
69 ' <Meta
/whats-cooking.txt
"$1"
75 if ! git write-tree
2>/dev
/null
>/dev
/null
80 EDITOR
=: git commit
--no-verify
81 echo "Accepted previous resolution"
87 test -n "$stop_at_cut" && return
89 count_since_last_cut
=$
(( $count_since_last_cut + 1 ))
90 test -z "$prev_cut" && return
91 git commit
--allow-empty -m "$prev_cut"
95 cut_seen
=0 prev_cut
= count_since_last_cut
=0
98 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
99 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
101 continue ;# slurp the remainder and skip
106 if test "$count_since_last_cut" = 0
110 echo >&2 "$branch $eh"
111 prev_cut
="$branch $eh"
112 count_since_last_cut
=0
123 save
=$
(git rev-parse
--verify HEAD
)
124 tip
=$
(git rev-parse
--verify "$branch^0")
125 mb
=$
(git merge-base
"$tip" "$save")
126 test "$mb" = "$tip" && continue
130 EDITOR
=: git merge
$accept_rerere --edit "$branch" ||
134 annotate_merge
"$branch" ||
exit
136 git commit
--amend ||
exit
138 this
=$
(git rev-parse
--verify HEAD
)
139 if test "$this" = "$save"
142 elif git show-ref
-q --verify "refs/merge-fix/$branch"
144 echo >&2 "Fixing up the merge"
145 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
146 EDITOR
=: git commit
--amend -a ||
exit
154 git cherry-pick
"$branch" ||
exit ;;
155 *) echo >&2 "Eh? $branch $eh"; exit ;;
161 if test -n "$update" && test $# = 0
163 set x $
(sed -n -e '2s/^# //p' <"$update") &&
167 # Generation (or updating)
169 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
170 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
176 "Merge branch '"*"'"*)
177 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
180 "Merge remote branch '"*"'"*)
181 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
185 echo 2>&1 "Huh?: $msg"
189 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
190 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
191 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
192 test "$merged" != undefined ||
{
193 other
=$
(git log
-1 --pretty='format:%s' $other) &&
194 merged
="$branch :rebased? $other"
204 merged
="$(git rev-parse --verify "$commit") pick $msg"
215 echo 'case "$#,$1" in'
217 echo " exec $PROGRAM" '"$1" "$0"'
219 echo "$PROGRAM" '"$@" <<\EOF'
220 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
223 while read commit msg
225 if other
=$
(git rev-parse
-q --verify "$commit^2")
236 series
="$merged$LF$series"
249 generate
"$0" "$@" |
diff -u "$update" -
252 echo >&2 "No changes."
254 echo >&2 -n "Update [y/N]? "
259 sed -e 's/ :rebased?.*//' >"$update" ;;
261 echo >&2 "No update then." ;;
265 generate
"$0" "$@" |
diff -u "$update" -