417
esac
418
}
419
420
+do_pick () {
421
+ if test "$(git rev-parse HEAD)" = "$squash_onto"
422
+ then
423
+ # Set the correct commit message and author info on the
424
+ # sentinel root before cherry-picking the original changes
425
+ # without committing (-n). Finally, update the sentinel again
426
+ # to include these changes. If the cherry-pick results in a
427
+ # conflict, this means our behaviour is similar to a standard
428
+ # failed cherry-pick during rebase, with a dirty index to
429
+ # resolve before manually running git commit --amend then git
430
+ # rebase --continue.
431
+ git commit --allow-empty --allow-empty-message --amend \
432
+ --no-post-rewrite -n -q -C $1 &&
433
+ pick_one -n $1 &&
434
+ git commit --allow-empty --allow-empty-message \
435
+ --amend --no-post-rewrite -n -q -C $1 ||
436
+ die_with_patch $1 "Could not apply $1... $2"
437
+ else
438
+ pick_one $1 ||
439
+ die_with_patch $1 "Could not apply $1... $2"
440
+ fi
441
+}
442
+
443
do_next () {
444
rm -f "$msg" "$author_script" "$amend" || exit
445
read -r command sha1 rest < "$todo"
451
comment_for_reflog pick
452
453
mark_action_done
431
- pick_one $sha1 ||
432
- die_with_patch $sha1 "Could not apply $sha1... $rest"
454
+ do_pick $sha1 "$rest"
455
record_in_rewritten $sha1
456
;;
457
reword|r)
458
comment_for_reflog reword
459
460
mark_action_done
439
- pick_one $sha1 ||
440
- die_with_patch $sha1 "Could not apply $sha1... $rest"
461
+ do_pick $sha1 "$rest"
462
git commit --amend --no-post-rewrite || {
463
warn "Could not amend commit after successfully picking $sha1... $rest"
464
warn "This is most likely due to an empty commit message, or the pre-commit hook"
472
comment_for_reflog edit
473
474
mark_action_done
454
- pick_one $sha1 ||
455
- die_with_patch $sha1 "Could not apply $sha1... $rest"
475
+ do_pick $sha1 "$rest"
476
warn "Stopped at $sha1... $rest"
477
exit_with_patch $sha1 0
478
;;