3 # Copyright (c) 2006 Johannes E. Schindelin
7 # This script makes it easy to fix up commits in the middle of a series,
8 # and rearrange commits.
10 # The original idea comes from Eric W. Biederman, in
11 # http://article.gmane.org/gmane.comp.version-control.git/22407
15 git-rebase [-i] [options] [--] <upstream> [<branch>]
16 git-rebase [-i] (--continue | --abort | --skip)
19 v,verbose display a diffstat of what changed upstream
20 onto= rebase onto given branch instead of upstream
21 p,preserve-merges try to recreate merges instead of ignoring them
22 s,strategy= use the given merge strategy
23 m,merge always used (no-op)
24 i,interactive always used (no-op)
26 continue continue rebasing process
27 abort abort rebasing process and restore original branch
28 skip skip current patch and continue rebasing process
29 no-verify override pre-rebase hook from stopping the operation
30 root rebase all reachable commmits up to the root(s)
31 autosquash move commits that begin with squash!/fixup! under -i
37 DOTEST
="$GIT_DIR/rebase-merge"
39 # The file containing rebase commands, comments, and empty lines.
40 # This file is created by "git rebase -i" then edited by the user. As
41 # the lines are processed, they are removed from the front of this
42 # file and written to the tail of $DONE.
43 TODO
="$DOTEST"/git-rebase-todo
45 # The rebase command lines that have already been processed. A line
46 # is moved here when it is first handled, before any associated user
50 # The commit message that is planned to be used for any changes that
51 # need to be committed following a user interaction.
54 # The file into which is accumulated the suggested commit message for
55 # squash/fixup commands. When the first of a series of squash/fixups
56 # is seen, the file is created and the commit message from the
57 # previous commit and from the first squash/fixup commit are written
58 # to it. The commit message for each subsequent squash/fixup commit
59 # is appended to the file as it is processed.
61 # The first line of the file is of the form
62 # # This is a combination of $COUNT commits.
63 # where $COUNT is the number of commits whose messages have been
64 # written to the file so far (including the initial "pick" commit).
65 # Each time that a commit message is processed, this line is read and
66 # updated. It is deleted just before the combined commit is made.
67 SQUASH_MSG
="$DOTEST"/message-squash
69 # If the current series of squash/fixups has not yet included a squash
70 # command, then this file exists and holds the commit message of the
71 # original "pick" commit. (If the series ends without a "squash"
72 # command, then this can be used as the commit message of the combined
73 # commit without opening the editor.)
74 FIXUP_MSG
="$DOTEST"/message-fixup
76 # $REWRITTEN is the name of a directory containing files for each
77 # commit that is reachable by at least one merge base of $HEAD and
78 # $UPSTREAM. They are not necessarily rewritten, but their children
79 # might be. This ensures that commits on merged, but otherwise
80 # unrelated side branches are left alone. (Think "X" in the man page's
82 REWRITTEN
="$DOTEST"/rewritten
84 DROPPED
="$DOTEST"/dropped
86 # A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
87 # GIT_AUTHOR_DATE that will be used for the commit that is currently
89 AUTHOR_SCRIPT
="$DOTEST"/author-script
91 # When an "edit" rebase command is being processed, the SHA1 of the
92 # commit to be edited is recorded in this file. When "git rebase
93 # --continue" is executed, if there are any staged changes then they
94 # will be amended to the HEAD commit, but only provided the HEAD
95 # commit is still the commit to be edited. When any other rebase
96 # command is processed, this file is deleted.
103 OK_TO_SKIP_PRE_REBASE
=
107 GIT_CHERRY_PICK_HELP
=" After resolving the conflicts,
108 mark the corrected paths with 'git add <paths>', and
109 run 'git rebase --continue'"
110 export GIT_CHERRY_PICK_HELP
121 test $status != 0 && printf "%s\n" "$output"
130 # Output the commit message for the specified commit.
132 git cat-file commit
"$1" |
sed "1,/^$/d"
135 run_pre_rebase_hook
() {
136 if test -z "$OK_TO_SKIP_PRE_REBASE" &&
137 test -x "$GIT_DIR/hooks/pre-rebase"
139 "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} ||
{
140 echo >&2 "The pre-rebase hook refused to rebase."
146 require_clean_work_tree
() {
147 # test if working tree is dirty
148 git rev-parse
--verify HEAD
> /dev
/null
&&
149 git update-index
--ignore-submodules --refresh &&
150 git diff-files
--quiet --ignore-submodules &&
151 git diff-index
--cached --quiet HEAD
--ignore-submodules -- ||
152 die
"Working tree is dirty"
155 ORIG_REFLOG_ACTION
="$GIT_REFLOG_ACTION"
157 comment_for_reflog
() {
158 case "$ORIG_REFLOG_ACTION" in
160 GIT_REFLOG_ACTION
="rebase -i ($1)"
161 export GIT_REFLOG_ACTION
166 peek_next_command
() {
167 sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$TODO"
170 # expects the original commit name(s) in "$REWRITTEN"/original
171 # records the current HEAD as the rewritten commit
173 test ! -d "$REWRITTEN" && return
174 rewritten
=$
(git rev-parse
--verify HEAD
) &&
175 for original
in $
(cat "$REWRITTEN"/original
)
177 original
=$
(git rev-parse
--verify "$original") &&
178 echo $rewritten > "$REWRITTEN"/$original ||
break
180 case "$(peek_next_command)" in
181 squash|s
) ;; # do nothing
182 *) rm "$REWRITTEN"/original
;;
184 die
"Could not store information about rewritten commit"
187 # if the given commit name ends in an apostrophe, returns the rewritten commit
191 rewritten
=$
(git rev-parse
--verify ${1%\'}) || die
192 while test -f "$REWRITTEN"/$rewritten -o -f "$DROPPED"/$rewritten
194 test -f "$REWRITTEN"/$rewritten &&
195 new_rewritten
=$
(cat "$REWRITTEN"/$rewritten) ||
196 new_rewritten
=$
(cat "$DROPPED"/$rewritten) ||
break
197 test $rewritten = $new_rewritten && break
198 rewritten
=$new_rewritten
203 git rev-parse
--verify $1 || die
209 mark_action_done
() {
210 sed -e 1q
< "$TODO" >> "$DONE"
211 sed -e 1d
< "$TODO" >> "$TODO".new
212 mv -f "$TODO".new
"$TODO"
213 count
=$
(sane_grep
-c '^[^#]' < "$DONE")
214 total
=$
(($count+$
(sane_grep
-c '^[^#]' < "$TODO")))
215 if test "$last_count" != "$count"
218 printf "Rebasing (%d/%d)\r" $count $total
219 test -z "$VERBOSE" ||
echo
224 sha1_and_parents
="$(git rev-list --parents -1 "$1")"
225 case "$sha1_and_parents" in
227 git
diff --cc $sha1_and_parents
230 git diff-tree
-p "$1^!"
235 esac > "$DOTEST"/patch
237 commit_message
"$1" > "$MSG"
238 test -f "$AUTHOR_SCRIPT" ||
239 get_author_ident_from_commit
"$1" > "$AUTHOR_SCRIPT"
254 sane_grep
'^[^#]' "$1" >/dev
/null
257 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
258 # GIT_AUTHOR_DATE exported from the current environment.
261 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
268 case "$1" in -n) sha1
=$2; no_ff
=t
;; *) sha1
=$1 ;; esac
269 output git rev-parse
--verify $sha1 || die
"Invalid commit name: $sha1"
270 test -d "$REWRITTEN" &&
271 pick_one_preserving_merges
"$@" && return
272 if test -n "$REBASE_ROOT"
274 output git cherry-pick
"$@"
277 parent_sha1
=$
(git rev-parse
--verify $sha1^
) ||
278 die
"Could not get the parent of $sha1"
279 current_sha1
=$
(git rev-parse
--verify HEAD
)
280 if test -z "$no_ff" && test "$current_sha1" = "$parent_sha1"
282 output git
reset --hard $sha1
283 output warn Fast-forward to $
(git rev-parse
--short $sha1)
285 output git cherry-pick
"$@"
289 pick_one_preserving_merges
() {
300 sha1
=$
(git rev-parse
$sha1)
302 if test -f "$DOTEST"/current-commit
304 if test "$fast_forward" = t
306 cat "$DOTEST"/current-commit |
while read current_commit
308 git rev-parse HEAD
> "$REWRITTEN"/$current_commit
310 rm "$DOTEST"/current-commit ||
311 die
"Cannot write current commit's replacement sha1"
315 echo $sha1 >> "$DOTEST"/current-commit
317 # rewrite parents; if none were rewritten, we can fast-forward.
319 pend
=" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)"
320 if test "$pend" = " "
324 while [ "$pend" != "" ]
326 p
=$
(expr "$pend" : ' \([^ ]*\)')
329 if test -f "$REWRITTEN"/$p
331 new_p
=$
(cat "$REWRITTEN"/$p)
333 # If the todo reordered commits, and our parent is marked for
334 # rewriting, but hasn't been gotten to yet, assume the user meant to
335 # drop it on top of the current HEAD
338 new_p
=$
(git rev-parse HEAD
)
341 test $p != $new_p && fast_forward
=f
342 case "$new_parents" in
344 ;; # do nothing; that parent is already there
346 new_parents
="$new_parents $new_p"
350 if test -f "$DROPPED"/$p
353 replacement
="$(cat "$DROPPED"/$p)"
354 test -z "$replacement" && replacement
=root
355 pend
=" $replacement$pend"
357 new_parents
="$new_parents $p"
361 case $fast_forward in
363 output warn
"Fast-forward to $sha1"
364 output git
reset --hard $sha1 ||
365 die
"Cannot fast-forward to $sha1"
368 first_parent
=$
(expr "$new_parents" : ' \([^ ]*\)')
372 # detach HEAD to current parent
373 output git checkout
$first_parent 2> /dev
/null ||
374 die
"Cannot move HEAD to $first_parent"
377 case "$new_parents" in
379 test "a$1" = a-n
&& die
"Refusing to squash a merge: $sha1"
382 author_script
=$
(get_author_ident_from_commit
$sha1)
383 eval "$author_script"
384 msg
="$(commit_message $sha1)"
385 # No point in merging the first parent, that's HEAD
386 new_parents
=${new_parents# $first_parent}
387 if ! do_with_author output \
388 git merge
$STRATEGY -m "$msg" $new_parents
390 printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
391 die_with_patch
$sha1 "Error redoing merge $sha1"
395 output git cherry-pick
"$@" ||
396 die_with_patch
$sha1 "Could not pick $sha1"
405 *1[0-9]|
*[04-9]) echo "$1"th
;;
412 update_squash_messages
() {
413 if test -f "$SQUASH_MSG"; then
414 mv "$SQUASH_MSG" "$SQUASH_MSG".bak ||
exit
416 -e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
417 -e "q" < "$SQUASH_MSG".bak
)+1))
419 echo "# This is a combination of $COUNT commits."
420 sed -e 1d
-e '2,/^./{
422 }' <"$SQUASH_MSG".bak
425 commit_message HEAD
> "$FIXUP_MSG" || die
"Cannot write $FIXUP_MSG"
428 echo "# This is a combination of 2 commits."
429 echo "# The first commit's message is:"
438 echo "# This is the $(nth_string $COUNT) commit message:"
444 echo "# The $(nth_string $COUNT) commit message will be skipped:"
446 commit_message
$2 |
sed -e 's/^/# /'
451 # A squash/fixup has failed. Prepare the long version of the squash
452 # commit message, then die_with_patch. This code path requires the
453 # user to edit the combined commit message for all commits that have
454 # been squashed/fixedup so far. So also erase the old squash
455 # messages, effectively causing the combined commit to be used as the
456 # new basis for any further squash/fixups. Args: sha1 rest
457 die_failed_squash
() {
458 mv "$SQUASH_MSG" "$MSG" ||
exit
460 cp "$MSG" "$GIT_DIR"/MERGE_MSG ||
exit
462 warn
"Could not apply $1... $2"
467 rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" ||
exit
468 read command sha1 rest
< "$TODO"
474 comment_for_reflog pick
478 die_with_patch
$sha1 "Could not apply $sha1... $rest"
481 comment_for_reflog reword
485 die_with_patch
$sha1 "Could not apply $sha1... $rest"
489 comment_for_reflog edit
493 die_with_patch
$sha1 "Could not apply $sha1... $rest"
495 git rev-parse
--verify HEAD
> "$AMEND"
496 warn
"Stopped at $sha1... $rest"
497 warn
"You can amend the commit now, with"
499 warn
" git commit --amend"
501 warn
"Once you are satisfied with your changes, run"
503 warn
" git rebase --continue"
516 comment_for_reflog
$squash_style
518 test -f "$DONE" && has_action
"$DONE" ||
519 die
"Cannot '$squash_style' without a previous commit"
522 update_squash_messages
$squash_style $sha1
523 author_script
=$
(get_author_ident_from_commit HEAD
)
524 echo "$author_script" > "$AUTHOR_SCRIPT"
525 eval "$author_script"
526 output git
reset --soft HEAD^
527 pick_one
-n $sha1 || die_failed_squash
$sha1 "$rest"
528 case "$(peek_next_command)" in
530 # This is an intermediate commit; its message will only be
531 # used in case of trouble. So use the long version:
532 do_with_author output git commit
--no-verify -F "$SQUASH_MSG" ||
533 die_failed_squash
$sha1 "$rest"
536 # This is the final command of this squash/fixup group
537 if test -f "$FIXUP_MSG"
539 do_with_author git commit
--no-verify -F "$FIXUP_MSG" ||
540 die_failed_squash
$sha1 "$rest"
542 cp "$SQUASH_MSG" "$GIT_DIR"/SQUASH_MSG ||
exit
543 rm -f "$GIT_DIR"/MERGE_MSG
544 do_with_author git commit
--no-verify -e ||
545 die_failed_squash
$sha1 "$rest"
547 rm -f "$SQUASH_MSG" "$FIXUP_MSG"
552 comment_for_reflog goto
554 output git
reset --hard $
(parse_commit
$sha1) ||
555 die
"Could not reset to $sha1"
558 warn
"Unknown command: $command $sha1 $rest"
559 if git rev-parse
--verify -q "$sha1" >/dev
/null
561 die_with_patch
$sha1 "Please fix this in the file $TODO."
563 die
"Please fix this in the file $TODO."
567 test -s "$TODO" && return
569 comment_for_reflog finish
&&
570 HEADNAME
=$
(cat "$DOTEST"/head-name
) &&
571 OLDHEAD
=$
(cat "$DOTEST"/head) &&
572 SHORTONTO
=$
(git rev-parse
--short $
(cat "$DOTEST"/onto
)) &&
573 NEWHEAD
=$
(git rev-parse HEAD
) &&
576 message
="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO" &&
577 git update-ref
-m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
578 git symbolic-ref HEAD
$HEADNAME
581 test ! -f "$DOTEST"/verbose ||
582 git diff-tree
--stat $
(cat "$DOTEST"/head)..HEAD
586 warn
"Successfully rebased and updated $HEADNAME."
598 # skip picking commits whose parents are unchanged
599 skip_unnecessary_picks
() {
601 while read command sha1 rest
603 # fd=3 means we skip the command
604 case "$fd,$command,$(git rev-parse --verify --quiet $sha1^)" in
605 3,pick
,"$ONTO"*|
3,p
,"$ONTO"*)
606 # pick a commit whose parent is current $ONTO -> skip
616 echo "$command${sha1:+ }$sha1${rest:+ }$rest" >&$fd
617 done <"$TODO" >"$TODO.new" 3>>"$DONE" &&
618 mv -f "$TODO".new
"$TODO" ||
619 die
"Could not skip unnecessary pick commands"
622 # check if no other options are set
624 test $# -eq 2 -a "$2" = '--' &&
626 test -z "$PRESERVE_MERGES" &&
627 test -z "$STRATEGY" &&
631 get_saved_options
() {
632 test -d "$REWRITTEN" && PRESERVE_MERGES
=t
633 test -f "$DOTEST"/strategy
&& STRATEGY
="$(cat "$DOTEST"/strategy)"
634 test -f "$DOTEST"/verbose
&& VERBOSE
=t
635 test -f "$DOTEST"/rebase-root
&& REBASE_ROOT
=t
638 # Rearrange the todo list that has both "pick sha1 msg" and
639 # "pick sha1 fixup!/squash! msg" appears in it so that the latter
640 # comes immediately after the former, and change "pick" to
642 rearrange_squash
() {
643 sed -n -e 's/^pick \([0-9a-f]*\) \(squash\)! /\1 \2 /p' \
644 -e 's/^pick \([0-9a-f]*\) \(fixup\)! /\1 \2 /p' \
646 test -s "$1.sq" ||
return
649 while read pick sha1 message
652 *" $sha1 "*) continue ;;
654 echo "$pick $sha1 $message"
655 while read squash action msg
659 echo "$action $squash $action! $msg"
664 done >"$1.rearranged" <"$1"
665 cat "$1.rearranged" >"$1"
666 rm -f "$1.sq" "$1.rearranged"
674 if left
=${1%...*} right
=${1#*...} &&
675 onto
=$
(git merge-base
--all ${left:-HEAD} ${right:-HEAD})
685 git rev-parse
--verify "$1^0"
692 OK_TO_SKIP_PRE_REBASE
=yes
697 is_standalone
"$@" || usage
699 comment_for_reflog
continue
701 test -d "$DOTEST" || die
"No interactive rebase running"
704 git rev-parse
--verify HEAD
>/dev
/null ||
705 die
"Cannot read HEAD"
706 git update-index
--ignore-submodules --refresh &&
707 git diff-files
--quiet --ignore-submodules ||
708 die
"Working tree is dirty"
710 # do we have anything to commit?
711 if git diff-index
--cached --quiet --ignore-submodules HEAD
--
713 : Nothing to commit
-- skip this
715 .
"$AUTHOR_SCRIPT" ||
716 die
"Cannot find the author identity"
720 amend
=$
(git rev-parse
--verify HEAD
)
721 test "$amend" = $
(cat "$AMEND") ||
723 You have uncommitted changes in your working tree. Please, commit them
724 first and then run 'git rebase --continue' again."
725 git
reset --soft HEAD^ ||
726 die
"Cannot rewind the HEAD"
728 do_with_author git commit
--no-verify -F "$MSG" -e ||
{
729 test -n "$amend" && git
reset --soft $amend
730 die
"Could not commit staged changes."
734 require_clean_work_tree
738 is_standalone
"$@" || usage
740 comment_for_reflog abort
743 test -d "$DOTEST" || die
"No interactive rebase running"
745 HEADNAME
=$
(cat "$DOTEST"/head-name
)
746 HEAD
=$
(cat "$DOTEST"/head)
749 git symbolic-ref HEAD
$HEADNAME
752 output git
reset --hard $HEAD &&
757 is_standalone
"$@" || usage
759 comment_for_reflog skip
762 test -d "$DOTEST" || die
"No interactive rebase running"
764 output git
reset --hard && do_rest
769 STRATEGY
="-s "$
(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
778 # we use merge anyway
797 ONTO
=$
(parse_onto
"$1") ||
798 die
"Does not point to a valid commit: $1"
802 test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
803 test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
805 die
"Interactive rebase already started"
807 git var GIT_COMMITTER_IDENT
>/dev
/null ||
808 die
"You need to set your committer info first"
810 if test -z "$REBASE_ROOT"
813 UPSTREAM
=$
(git rev-parse
--verify "$1") ||
815 test -z "$ONTO" && ONTO
=$UPSTREAM
821 die
"You must specify --onto when using --root"
824 run_pre_rebase_hook
"$UPSTREAM_ARG" "$@"
826 comment_for_reflog start
828 require_clean_work_tree
832 output git show-ref
--verify --quiet "refs/heads/$1" ||
833 die
"Invalid branchname: $1"
834 output git checkout
"$1" ||
835 die
"Could not checkout $1"
838 HEAD
=$
(git rev-parse
--verify HEAD
) || die
"No HEAD?"
839 mkdir
"$DOTEST" || die
"Could not create temporary $DOTEST"
841 : > "$DOTEST"/interactive || die
"Could not mark as interactive"
842 git symbolic-ref HEAD
> "$DOTEST"/head-name
2> /dev
/null ||
843 echo "detached HEAD" > "$DOTEST"/head-name
845 echo $HEAD > "$DOTEST"/head
846 test -z "$REBASE_ROOT" ||
: >"$DOTEST"/rebase-root
847 echo $ONTO > "$DOTEST"/onto
848 test -z "$STRATEGY" ||
echo "$STRATEGY" > "$DOTEST"/strategy
849 test t
= "$VERBOSE" && : > "$DOTEST"/verbose
850 if test t
= "$PRESERVE_MERGES"
852 if test -z "$REBASE_ROOT"
854 mkdir
"$REWRITTEN" &&
855 for c
in $
(git merge-base
--all $HEAD $UPSTREAM)
857 echo $ONTO > "$REWRITTEN"/$c ||
858 die
"Could not init rewritten commits"
861 mkdir
"$REWRITTEN" &&
862 echo $ONTO > "$REWRITTEN"/root ||
863 die
"Could not init rewritten commits"
865 # No cherry-pick because our first pass is to determine
866 # parents to rewrite and skipping dropped commits would
867 # prematurely end our probe
869 first_after_upstream
="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
871 MERGES_OPTION
="--no-merges --cherry-pick"
874 SHORTHEAD
=$
(git rev-parse
--short $HEAD)
875 SHORTONTO
=$
(git rev-parse
--short $ONTO)
876 SHORTUPSTREAM
=$
(git rev-parse
--short $UPSTREAM)
877 REVISIONS
=$UPSTREAM...
$HEAD
878 SHORTREVISIONS
=$SHORTUPSTREAM..
$SHORTHEAD
879 git rev-list
$MERGES_OPTION --pretty=oneline
--abbrev-commit \
880 --abbrev=7 --reverse --left-right --topo-order \
882 sed -n "s/^>//p" |
while read shortsha1 rest
884 if test t
!= "$PRESERVE_MERGES"
886 echo "pick $shortsha1 $rest" >> "$TODO"
888 sha1
=$
(git rev-parse
$shortsha1)
889 if test -z "$REBASE_ROOT"
892 for p
in $
(git rev-list
--parents -1 $sha1 | cut
-d' ' -s -f2-)
894 if test -f "$REWRITTEN"/$p -a \
( $p != $ONTO -o $sha1 = $first_after_upstream \
)
902 if test f
= "$preserve"
904 touch "$REWRITTEN"/$sha1
905 echo "pick $shortsha1 $rest" >> "$TODO"
910 # Watch for commits that been dropped by --cherry-pick
911 if test t
= "$PRESERVE_MERGES"
914 # Save all non-cherry-picked changes
915 git rev-list
$REVISIONS --left-right --cherry-pick | \
916 sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
917 # Now all commits and note which ones are missing in
918 # not-cherry-picks and hence being dropped
919 git rev-list
$REVISIONS |
922 if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
924 # Use -f2 because if rev-list is telling us this commit is
925 # not worthwhile, we don't want to track its multiple heads,
926 # just the history of its first-parent for others that will
927 # be rebasing on top of it
928 git rev-list
--parents -1 $rev | cut
-d' ' -s -f2 > "$DROPPED"/$rev
929 short
=$
(git rev-list
-1 --abbrev-commit --abbrev=7 $rev)
930 sane_grep
-v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
936 test -s "$TODO" ||
echo noop
>> "$TODO"
937 test -n "$AUTOSQUASH" && rearrange_squash
"$TODO"
938 cat >> "$TODO" << EOF
940 # Rebase $SHORTREVISIONS onto $SHORTONTO
943 # p, pick = use commit
944 # r, reword = use commit, but edit the commit message
945 # e, edit = use commit, but stop for amending
946 # s, squash = use commit, but meld into previous commit
947 # f, fixup = like "squash", but discard this commit's log message
948 # g, goto = reset the current state to the given commit
950 # If you remove a line here THAT COMMIT WILL BE LOST.
951 # However, if you remove everything, the rebase will be aborted.
955 has_action
"$TODO" ||
956 die_abort
"Nothing to do"
958 cp "$TODO" "$TODO".backup
959 git_editor
"$TODO" ||
960 die_abort
"Could not execute editor"
962 has_action
"$TODO" ||
963 die_abort
"Nothing to do"
965 test -d "$REWRITTEN" || skip_unnecessary_picks
967 git update-ref ORIG_HEAD
$HEAD
968 output git checkout
$ONTO && do_rest