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.
99 # For the post-rewrite hook, we make a list of rewritten commits and
100 # their new sha1s. The rewritten-pending list keeps the sha1s of
101 # commits that have been processed, but not committed yet,
102 # e.g. because they are waiting for a 'squash' command.
103 REWRITTEN_LIST
="$DOTEST"/rewritten-list
104 REWRITTEN_PENDING
="$DOTEST"/rewritten-pending
110 OK_TO_SKIP_PRE_REBASE
=
114 GIT_CHERRY_PICK_HELP
=" After resolving the conflicts,
115 mark the corrected paths with 'git add <paths>', and
116 run 'git rebase --continue'"
117 export GIT_CHERRY_PICK_HELP
128 test $status != 0 && printf "%s\n" "$output"
137 # Output the commit message for the specified commit.
139 git cat-file commit
"$1" |
sed "1,/^$/d"
142 run_pre_rebase_hook
() {
143 if test -z "$OK_TO_SKIP_PRE_REBASE" &&
144 test -x "$GIT_DIR/hooks/pre-rebase"
146 "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} ||
{
147 echo >&2 "The pre-rebase hook refused to rebase."
153 require_clean_work_tree
() {
154 # test if working tree is dirty
155 git rev-parse
--verify HEAD
> /dev
/null
&&
156 git update-index
--ignore-submodules --refresh &&
157 git diff-files
--quiet --ignore-submodules &&
158 git diff-index
--cached --quiet HEAD
--ignore-submodules -- ||
159 die
"Working tree is dirty"
162 ORIG_REFLOG_ACTION
="$GIT_REFLOG_ACTION"
164 comment_for_reflog
() {
165 case "$ORIG_REFLOG_ACTION" in
167 GIT_REFLOG_ACTION
="rebase -i ($1)"
168 export GIT_REFLOG_ACTION
174 mark_action_done
() {
175 sed -e 1q
< "$TODO" >> "$DONE"
176 sed -e 1d
< "$TODO" >> "$TODO".new
177 mv -f "$TODO".new
"$TODO"
178 count
=$
(sane_grep
-c '^[^#]' < "$DONE")
179 total
=$
(($count+$
(sane_grep
-c '^[^#]' < "$TODO")))
180 if test "$last_count" != "$count"
183 printf "Rebasing (%d/%d)\r" $count $total
184 test -z "$VERBOSE" ||
echo
189 sha1_and_parents
="$(git rev-list --parents -1 "$1")"
190 case "$sha1_and_parents" in
192 git
diff --cc $sha1_and_parents
195 git diff-tree
-p "$1^!"
200 esac > "$DOTEST"/patch
202 commit_message
"$1" > "$MSG"
203 test -f "$AUTHOR_SCRIPT" ||
204 get_author_ident_from_commit
"$1" > "$AUTHOR_SCRIPT"
208 echo "$1" > "$DOTEST"/stopped-sha
220 sane_grep
'^[^#]' "$1" >/dev
/null
223 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
224 # GIT_AUTHOR_DATE exported from the current environment.
227 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
234 case "$1" in -n) sha1
=$2; ff
= ;; *) sha1
=$1 ;; esac
235 output git rev-parse
--verify $sha1 || die
"Invalid commit name: $sha1"
236 test -d "$REWRITTEN" &&
237 pick_one_preserving_merges
"$@" && return
238 if test -n "$REBASE_ROOT"
240 output git cherry-pick
"$@"
243 output git cherry-pick
$ff "$@"
246 pick_one_preserving_merges
() {
257 sha1
=$
(git rev-parse
$sha1)
259 if test -f "$DOTEST"/current-commit
261 if test "$fast_forward" = t
263 cat "$DOTEST"/current-commit |
while read current_commit
265 git rev-parse HEAD
> "$REWRITTEN"/$current_commit
267 rm "$DOTEST"/current-commit ||
268 die
"Cannot write current commit's replacement sha1"
272 echo $sha1 >> "$DOTEST"/current-commit
274 # rewrite parents; if none were rewritten, we can fast-forward.
276 pend
=" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)"
277 if test "$pend" = " "
281 while [ "$pend" != "" ]
283 p
=$
(expr "$pend" : ' \([^ ]*\)')
286 if test -f "$REWRITTEN"/$p
288 new_p
=$
(cat "$REWRITTEN"/$p)
290 # If the todo reordered commits, and our parent is marked for
291 # rewriting, but hasn't been gotten to yet, assume the user meant to
292 # drop it on top of the current HEAD
295 new_p
=$
(git rev-parse HEAD
)
298 test $p != $new_p && fast_forward
=f
299 case "$new_parents" in
301 ;; # do nothing; that parent is already there
303 new_parents
="$new_parents $new_p"
307 if test -f "$DROPPED"/$p
310 replacement
="$(cat "$DROPPED"/$p)"
311 test -z "$replacement" && replacement
=root
312 pend
=" $replacement$pend"
314 new_parents
="$new_parents $p"
318 case $fast_forward in
320 output warn
"Fast-forward to $sha1"
321 output git
reset --hard $sha1 ||
322 die
"Cannot fast-forward to $sha1"
325 first_parent
=$
(expr "$new_parents" : ' \([^ ]*\)')
329 # detach HEAD to current parent
330 output git checkout
$first_parent 2> /dev
/null ||
331 die
"Cannot move HEAD to $first_parent"
334 case "$new_parents" in
336 test "a$1" = a-n
&& die
"Refusing to squash a merge: $sha1"
339 author_script
=$
(get_author_ident_from_commit
$sha1)
340 eval "$author_script"
341 msg
="$(commit_message $sha1)"
342 # No point in merging the first parent, that's HEAD
343 new_parents
=${new_parents# $first_parent}
344 if ! do_with_author output \
345 git merge
$STRATEGY -m "$msg" $new_parents
347 printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
348 die_with_patch
$sha1 "Error redoing merge $sha1"
350 echo "$sha1 $(git rev-parse HEAD^0)" >> "$REWRITTEN_LIST"
353 output git cherry-pick
"$@" ||
354 die_with_patch
$sha1 "Could not pick $sha1"
363 *1[0-9]|
*[04-9]) echo "$1"th
;;
370 update_squash_messages
() {
371 if test -f "$SQUASH_MSG"; then
372 mv "$SQUASH_MSG" "$SQUASH_MSG".bak ||
exit
374 -e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
375 -e "q" < "$SQUASH_MSG".bak
)+1))
377 echo "# This is a combination of $COUNT commits."
378 sed -e 1d
-e '2,/^./{
380 }' <"$SQUASH_MSG".bak
383 commit_message HEAD
> "$FIXUP_MSG" || die
"Cannot write $FIXUP_MSG"
386 echo "# This is a combination of 2 commits."
387 echo "# The first commit's message is:"
396 echo "# This is the $(nth_string $COUNT) commit message:"
402 echo "# The $(nth_string $COUNT) commit message will be skipped:"
404 commit_message
$2 |
sed -e 's/^/# /'
409 peek_next_command
() {
410 sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$TODO"
413 # A squash/fixup has failed. Prepare the long version of the squash
414 # commit message, then die_with_patch. This code path requires the
415 # user to edit the combined commit message for all commits that have
416 # been squashed/fixedup so far. So also erase the old squash
417 # messages, effectively causing the combined commit to be used as the
418 # new basis for any further squash/fixups. Args: sha1 rest
419 die_failed_squash
() {
420 mv "$SQUASH_MSG" "$MSG" ||
exit
422 cp "$MSG" "$GIT_DIR"/MERGE_MSG ||
exit
424 warn
"Could not apply $1... $2"
428 flush_rewritten_pending
() {
429 test -s "$REWRITTEN_PENDING" ||
return
430 newsha1
="$(git rev-parse HEAD^0)"
431 sed "s/$/ $newsha1/" < "$REWRITTEN_PENDING" >> "$REWRITTEN_LIST"
432 rm -f "$REWRITTEN_PENDING"
435 record_in_rewritten
() {
436 oldsha1
="$(git rev-parse $1)"
437 echo "$oldsha1" >> "$REWRITTEN_PENDING"
439 case "$(peek_next_command)" in
443 flush_rewritten_pending
449 rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" ||
exit
450 read command sha1 rest
< "$TODO"
456 comment_for_reflog pick
460 die_with_patch
$sha1 "Could not apply $sha1... $rest"
461 record_in_rewritten
$sha1
464 comment_for_reflog reword
468 die_with_patch
$sha1 "Could not apply $sha1... $rest"
469 git commit
--amend --no-post-rewrite
470 record_in_rewritten
$sha1
473 comment_for_reflog edit
477 die_with_patch
$sha1 "Could not apply $sha1... $rest"
478 echo "$sha1" > "$DOTEST"/stopped-sha
480 git rev-parse
--verify HEAD
> "$AMEND"
481 warn
"Stopped at $sha1... $rest"
482 warn
"You can amend the commit now, with"
484 warn
" git commit --amend"
486 warn
"Once you are satisfied with your changes, run"
488 warn
" git rebase --continue"
501 comment_for_reflog
$squash_style
503 test -f "$DONE" && has_action
"$DONE" ||
504 die
"Cannot '$squash_style' without a previous commit"
507 update_squash_messages
$squash_style $sha1
508 author_script
=$
(get_author_ident_from_commit HEAD
)
509 echo "$author_script" > "$AUTHOR_SCRIPT"
510 eval "$author_script"
511 output git
reset --soft HEAD^
512 pick_one
-n $sha1 || die_failed_squash
$sha1 "$rest"
513 case "$(peek_next_command)" in
515 # This is an intermediate commit; its message will only be
516 # used in case of trouble. So use the long version:
517 do_with_author output git commit
--no-verify -F "$SQUASH_MSG" ||
518 die_failed_squash
$sha1 "$rest"
521 # This is the final command of this squash/fixup group
522 if test -f "$FIXUP_MSG"
524 do_with_author git commit
--no-verify -F "$FIXUP_MSG" ||
525 die_failed_squash
$sha1 "$rest"
527 cp "$SQUASH_MSG" "$GIT_DIR"/SQUASH_MSG ||
exit
528 rm -f "$GIT_DIR"/MERGE_MSG
529 do_with_author git commit
--no-verify -e ||
530 die_failed_squash
$sha1 "$rest"
532 rm -f "$SQUASH_MSG" "$FIXUP_MSG"
535 record_in_rewritten
$sha1
538 warn
"Unknown command: $command $sha1 $rest"
539 if git rev-parse
--verify -q "$sha1" >/dev
/null
541 die_with_patch
$sha1 "Please fix this in the file $TODO."
543 die
"Please fix this in the file $TODO."
547 test -s "$TODO" && return
549 comment_for_reflog finish
&&
550 HEADNAME
=$
(cat "$DOTEST"/head-name
) &&
551 OLDHEAD
=$
(cat "$DOTEST"/head) &&
552 SHORTONTO
=$
(git rev-parse
--short $
(cat "$DOTEST"/onto
)) &&
553 NEWHEAD
=$
(git rev-parse HEAD
) &&
556 message
="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO" &&
557 git update-ref
-m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
558 git symbolic-ref HEAD
$HEADNAME
561 test ! -f "$DOTEST"/verbose ||
562 git diff-tree
--stat $
(cat "$DOTEST"/head)..HEAD
565 git notes copy
--for-rewrite=rebase
< "$REWRITTEN_LIST" ||
566 true
# we don't care if this copying failed
568 if test -x "$GIT_DIR"/hooks
/post-rewrite
&&
569 test -s "$REWRITTEN_LIST"; then
570 "$GIT_DIR"/hooks
/post-rewrite rebase
< "$REWRITTEN_LIST"
571 true
# we don't care if this hook failed
575 warn
"Successfully rebased and updated $HEADNAME."
587 # skip picking commits whose parents are unchanged
588 skip_unnecessary_picks
() {
590 while read command sha1 rest
592 # fd=3 means we skip the command
593 case "$fd,$command,$(git rev-parse --verify --quiet $sha1^)" in
594 3,pick
,"$ONTO"*|
3,p
,"$ONTO"*)
595 # pick a commit whose parent is current $ONTO -> skip
605 echo "$command${sha1:+ }$sha1${rest:+ }$rest" >&$fd
606 done <"$TODO" >"$TODO.new" 3>>"$DONE" &&
607 mv -f "$TODO".new
"$TODO" &&
608 case "$(peek_next_command)" in
610 record_in_rewritten
"$ONTO"
613 die
"Could not skip unnecessary pick commands"
616 # check if no other options are set
618 test $# -eq 2 -a "$2" = '--' &&
620 test -z "$PRESERVE_MERGES" &&
621 test -z "$STRATEGY" &&
625 get_saved_options
() {
626 test -d "$REWRITTEN" && PRESERVE_MERGES
=t
627 test -f "$DOTEST"/strategy
&& STRATEGY
="$(cat "$DOTEST"/strategy)"
628 test -f "$DOTEST"/verbose
&& VERBOSE
=t
629 test -f "$DOTEST"/rebase-root
&& REBASE_ROOT
=t
632 # Rearrange the todo list that has both "pick sha1 msg" and
633 # "pick sha1 fixup!/squash! msg" appears in it so that the latter
634 # comes immediately after the former, and change "pick" to
636 rearrange_squash
() {
637 sed -n -e 's/^pick \([0-9a-f]*\) \(squash\)! /\1 \2 /p' \
638 -e 's/^pick \([0-9a-f]*\) \(fixup\)! /\1 \2 /p' \
640 test -s "$1.sq" ||
return
643 while read pick sha1 message
646 *" $sha1 "*) continue ;;
648 echo "$pick $sha1 $message"
649 while read squash action msg
653 echo "$action $squash $action! $msg"
658 done >"$1.rearranged" <"$1"
659 cat "$1.rearranged" >"$1"
660 rm -f "$1.sq" "$1.rearranged"
668 if left
=${1%...*} right
=${1#*...} &&
669 onto
=$
(git merge-base
--all ${left:-HEAD} ${right:-HEAD})
679 git rev-parse
--verify "$1^0"
686 OK_TO_SKIP_PRE_REBASE
=yes
691 is_standalone
"$@" || usage
693 comment_for_reflog
continue
695 test -d "$DOTEST" || die
"No interactive rebase running"
698 git rev-parse
--verify HEAD
>/dev
/null ||
699 die
"Cannot read HEAD"
700 git update-index
--ignore-submodules --refresh &&
701 git diff-files
--quiet --ignore-submodules ||
702 die
"Working tree is dirty"
704 # do we have anything to commit?
705 if git diff-index
--cached --quiet --ignore-submodules HEAD
--
707 : Nothing to commit
-- skip this
709 .
"$AUTHOR_SCRIPT" ||
710 die
"Cannot find the author identity"
714 amend
=$
(git rev-parse
--verify HEAD
)
715 test "$amend" = $
(cat "$AMEND") ||
717 You have uncommitted changes in your working tree. Please, commit them
718 first and then run 'git rebase --continue' again."
719 git
reset --soft HEAD^ ||
720 die
"Cannot rewind the HEAD"
722 do_with_author git commit
--no-verify -F "$MSG" -e ||
{
723 test -n "$amend" && git
reset --soft $amend
724 die
"Could not commit staged changes."
728 record_in_rewritten
"$(cat "$DOTEST"/stopped-sha)"
730 require_clean_work_tree
734 is_standalone
"$@" || usage
736 comment_for_reflog abort
739 test -d "$DOTEST" || die
"No interactive rebase running"
741 HEADNAME
=$
(cat "$DOTEST"/head-name
)
742 HEAD
=$
(cat "$DOTEST"/head)
745 git symbolic-ref HEAD
$HEADNAME
748 output git
reset --hard $HEAD &&
753 is_standalone
"$@" || usage
755 comment_for_reflog skip
758 test -d "$DOTEST" || die
"No interactive rebase running"
760 output git
reset --hard && do_rest
765 STRATEGY
="-s "$
(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
774 # we use merge anyway
793 ONTO
=$
(parse_onto
"$1") ||
794 die
"Does not point to a valid commit: $1"
798 test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
799 test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
801 die
"Interactive rebase already started"
803 git var GIT_COMMITTER_IDENT
>/dev
/null ||
804 die
"You need to set your committer info first"
806 if test -z "$REBASE_ROOT"
809 UPSTREAM
=$
(git rev-parse
--verify "$1") || die
"Invalid base"
810 test -z "$ONTO" && ONTO
=$UPSTREAM
816 die
"You must specify --onto when using --root"
818 run_pre_rebase_hook
"$UPSTREAM_ARG" "$@"
820 comment_for_reflog start
822 require_clean_work_tree
826 output git checkout
"$1" ||
827 die
"Could not checkout $1"
830 HEAD
=$
(git rev-parse
--verify HEAD
) || die
"No HEAD?"
831 mkdir
"$DOTEST" || die
"Could not create temporary $DOTEST"
833 : > "$DOTEST"/interactive || die
"Could not mark as interactive"
834 git symbolic-ref HEAD
> "$DOTEST"/head-name
2> /dev
/null ||
835 echo "detached HEAD" > "$DOTEST"/head-name
837 echo $HEAD > "$DOTEST"/head
838 case "$REBASE_ROOT" in
840 rm -f "$DOTEST"/rebase-root
;;
842 : >"$DOTEST"/rebase-root
;;
844 echo $ONTO > "$DOTEST"/onto
845 test -z "$STRATEGY" ||
echo "$STRATEGY" > "$DOTEST"/strategy
846 test t
= "$VERBOSE" && : > "$DOTEST"/verbose
847 if test t
= "$PRESERVE_MERGES"
849 if test -z "$REBASE_ROOT"
851 mkdir
"$REWRITTEN" &&
852 for c
in $
(git merge-base
--all $HEAD $UPSTREAM)
854 echo $ONTO > "$REWRITTEN"/$c ||
855 die
"Could not init rewritten commits"
858 mkdir
"$REWRITTEN" &&
859 echo $ONTO > "$REWRITTEN"/root ||
860 die
"Could not init rewritten commits"
862 # No cherry-pick because our first pass is to determine
863 # parents to rewrite and skipping dropped commits would
864 # prematurely end our probe
866 first_after_upstream
="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
868 MERGES_OPTION
="--no-merges --cherry-pick"
871 SHORTHEAD
=$
(git rev-parse
--short $HEAD)
872 SHORTONTO
=$
(git rev-parse
--short $ONTO)
873 if test -z "$REBASE_ROOT"
874 # this is now equivalent to ! -z "$UPSTREAM"
876 SHORTUPSTREAM
=$
(git rev-parse
--short $UPSTREAM)
877 REVISIONS
=$UPSTREAM...
$HEAD
878 SHORTREVISIONS
=$SHORTUPSTREAM..
$SHORTHEAD
880 REVISIONS
=$ONTO...
$HEAD
881 SHORTREVISIONS
=$SHORTHEAD
883 git rev-list
$MERGES_OPTION --pretty=oneline
--abbrev-commit \
884 --abbrev=7 --reverse --left-right --topo-order \
886 sed -n "s/^>//p" |
while read shortsha1 rest
888 if test t
!= "$PRESERVE_MERGES"
890 echo "pick $shortsha1 $rest" >> "$TODO"
892 sha1
=$
(git rev-parse
$shortsha1)
893 if test -z "$REBASE_ROOT"
896 for p
in $
(git rev-list
--parents -1 $sha1 | cut
-d' ' -s -f2-)
898 if test -f "$REWRITTEN"/$p -a \
( $p != $ONTO -o $sha1 = $first_after_upstream \
)
906 if test f
= "$preserve"
908 touch "$REWRITTEN"/$sha1
909 echo "pick $shortsha1 $rest" >> "$TODO"
914 # Watch for commits that been dropped by --cherry-pick
915 if test t
= "$PRESERVE_MERGES"
918 # Save all non-cherry-picked changes
919 git rev-list
$REVISIONS --left-right --cherry-pick | \
920 sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
921 # Now all commits and note which ones are missing in
922 # not-cherry-picks and hence being dropped
923 git rev-list
$REVISIONS |
926 if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
928 # Use -f2 because if rev-list is telling us this commit is
929 # not worthwhile, we don't want to track its multiple heads,
930 # just the history of its first-parent for others that will
931 # be rebasing on top of it
932 git rev-list
--parents -1 $rev | cut
-d' ' -s -f2 > "$DROPPED"/$rev
933 short
=$
(git rev-list
-1 --abbrev-commit --abbrev=7 $rev)
934 sane_grep
-v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
940 test -s "$TODO" ||
echo noop
>> "$TODO"
941 test -n "$AUTOSQUASH" && rearrange_squash
"$TODO"
942 cat >> "$TODO" << EOF
944 # Rebase $SHORTREVISIONS onto $SHORTONTO
947 # p, pick = use commit
948 # r, reword = use commit, but edit the commit message
949 # e, edit = use commit, but stop for amending
950 # s, squash = use commit, but meld into previous commit
951 # f, fixup = like "squash", but discard this commit's log message
953 # If you remove a line here THAT COMMIT WILL BE LOST.
954 # However, if you remove everything, the rebase will be aborted.
958 has_action
"$TODO" ||
959 die_abort
"Nothing to do"
961 cp "$TODO" "$TODO".backup
962 git_editor
"$TODO" ||
963 die_abort
"Could not execute editor"
965 has_action
"$TODO" ||
966 die_abort
"Nothing to do"
968 test -d "$REWRITTEN" || skip_unnecessary_picks
970 git update-ref ORIG_HEAD
$HEAD
971 output git checkout
$ONTO && do_rest