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 -z "$prev_cut" && return
88 git commit
--allow-empty -m "$prev_cut"
95 case "$branch" in '###') cut_seen
=$
(( $cut_seen + 1 )) ;; esac
96 if test -n "$stop_at_cut" && test $stop_at_cut -le $cut_seen
98 continue ;# slurp the remainder and skip
103 echo >&2 "$branch $eh"
104 prev_cut
="$branch $eh"
114 save
=$
(git rev-parse
--verify HEAD
)
115 tip
=$
(git rev-parse
--verify "$branch^0")
116 mb
=$
(git merge-base
"$tip" "$save")
117 test "$mb" = "$tip" && continue
121 EDITOR
=: git merge
$accept_rerere --edit "$branch" ||
125 annotate_merge
"$branch" ||
exit
127 git commit
--amend ||
exit
129 this
=$
(git rev-parse
--verify HEAD
)
130 if test "$this" = "$save"
133 elif git show-ref
-q --verify "refs/merge-fix/$branch"
135 echo >&2 "Fixing up the merge"
136 git cherry-pick
--no-commit "refs/merge-fix/$branch" &&
137 EDITOR
=: git commit
--amend -a ||
exit
145 git cherry-pick
"$branch" ||
exit ;;
146 *) echo >&2 "Eh? $branch $eh"; exit ;;
152 if test -n "$update" && test $# = 0
154 set x $
(sed -n -e '2s/^# //p' <"$update") &&
158 # Generation (or updating)
160 x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
161 x40
="$x40$x40$x40$x40$x40$x40$x40$x40"
167 "Merge branch '"*"'"*)
168 branch
=$
(expr "$msg" : "Merge branch '\(.*\)'")
171 "Merge remote branch '"*"'"*)
172 branch
=$
(expr "$msg" : "Merge remote branch '\(.*\)'")
176 echo 2>&1 "Huh?: $msg"
180 tip
=$
(git rev-parse
--verify "refs/$merge_hier$branch" 2>/dev
/null
) &&
181 merged
=$
(git name-rev
--refs="refs/$merge_hier$branch" "$other" 2>/dev
/null
) &&
182 merged
=$
(expr "$merged" : "$x40 \(.*\)") &&
183 test "$merged" != undefined ||
{
184 other
=$
(git log
-1 --pretty='format:%s' $other) &&
185 merged
="$branch :rebased? $other"
195 merged
="$(git rev-parse --verify "$commit") pick $msg"
206 echo 'case "$#,$1" in'
208 echo " exec $PROGRAM" '"$1" "$0"'
210 echo "$PROGRAM" '"$@" <<\EOF'
211 git log
--no-decorate --pretty=oneline
--first-parent "$1" |
214 while read commit msg
216 if other
=$
(git rev-parse
-q --verify "$commit^2")
227 series
="$merged$LF$series"
240 generate
"$0" "$@" |
diff -u "$update" -
243 echo >&2 "No changes."
245 echo >&2 -n "Update [y/N]? "
250 sed -e 's/ :rebased?.*//' >"$update" ;;
252 echo >&2 "No update then." ;;
256 generate
"$0" "$@" |
diff -u "$update" -