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
"$@"
291 test "$1" = parents
&& shift
293 while test "original" != "$1"
295 parents
="$parents $(parse_commit $1)"
299 test "original" != "$1" &&
300 die
"Could not determine original merge commit from $cmd"
302 sha1
=$2; shift; shift
304 # the command was "merge parents ...", so "parents" was recorded
305 # TODO: detect non-fast-forwards properly
306 ORIGINAL_HEAD
=$
(git rev-parse HEAD
) &&
307 git merge
$parents &&
308 if test $ORIGINAL_HEAD = "$(git rev-parse HEAD^)"
310 git commit
--amend -m "$*" &&
311 echo "$sha1" > "$REWRITTEN"/original
&&
314 die_with_patch
$sha1 "Could not redo merge $sha1 with parents $parents"
317 pick_one_preserving_merges
() {
328 sha1
=$
(git rev-parse
$sha1)
330 if test -f "$DOTEST"/current-commit
332 if test "$fast_forward" = t
334 cat "$DOTEST"/current-commit |
while read current_commit
336 git rev-parse HEAD
> "$REWRITTEN"/$current_commit
338 rm "$DOTEST"/current-commit ||
339 die
"Cannot write current commit's replacement sha1"
343 echo $sha1 >> "$DOTEST"/current-commit
345 # rewrite parents; if none were rewritten, we can fast-forward.
347 pend
=" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)"
348 if test "$pend" = " "
352 while [ "$pend" != "" ]
354 p
=$
(expr "$pend" : ' \([^ ]*\)')
357 if test -f "$REWRITTEN"/$p
359 new_p
=$
(cat "$REWRITTEN"/$p)
361 # If the todo reordered commits, and our parent is marked for
362 # rewriting, but hasn't been gotten to yet, assume the user meant to
363 # drop it on top of the current HEAD
366 new_p
=$
(git rev-parse HEAD
)
369 test $p != $new_p && fast_forward
=f
370 case "$new_parents" in
372 ;; # do nothing; that parent is already there
374 new_parents
="$new_parents $new_p"
378 if test -f "$DROPPED"/$p
381 replacement
="$(cat "$DROPPED"/$p)"
382 test -z "$replacement" && replacement
=root
383 pend
=" $replacement$pend"
385 new_parents
="$new_parents $p"
389 case $fast_forward in
391 output warn
"Fast-forward to $sha1"
392 output git
reset --hard $sha1 ||
393 die
"Cannot fast-forward to $sha1"
396 first_parent
=$
(expr "$new_parents" : ' \([^ ]*\)')
400 # detach HEAD to current parent
401 output git checkout
$first_parent 2> /dev
/null ||
402 die
"Cannot move HEAD to $first_parent"
405 case "$new_parents" in
407 test "a$1" = a-n
&& die
"Refusing to squash a merge: $sha1"
410 author_script
=$
(get_author_ident_from_commit
$sha1)
411 eval "$author_script"
412 msg
="$(commit_message $sha1)"
413 # No point in merging the first parent, that's HEAD
414 new_parents
=${new_parents# $first_parent}
415 if ! do_with_author output \
416 git merge
$STRATEGY -m "$msg" $new_parents
418 printf "%s\n" "$msg" > "$GIT_DIR"/MERGE_MSG
419 die_with_patch
$sha1 "Error redoing merge $sha1"
423 output git cherry-pick
"$@" ||
424 die_with_patch
$sha1 "Could not pick $sha1"
433 *1[0-9]|
*[04-9]) echo "$1"th
;;
440 update_squash_messages
() {
441 if test -f "$SQUASH_MSG"; then
442 mv "$SQUASH_MSG" "$SQUASH_MSG".bak ||
exit
444 -e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
445 -e "q" < "$SQUASH_MSG".bak
)+1))
447 echo "# This is a combination of $COUNT commits."
448 sed -e 1d
-e '2,/^./{
450 }' <"$SQUASH_MSG".bak
453 commit_message HEAD
> "$FIXUP_MSG" || die
"Cannot write $FIXUP_MSG"
456 echo "# This is a combination of 2 commits."
457 echo "# The first commit's message is:"
466 echo "# This is the $(nth_string $COUNT) commit message:"
472 echo "# The $(nth_string $COUNT) commit message will be skipped:"
474 commit_message
$2 |
sed -e 's/^/# /'
479 # A squash/fixup has failed. Prepare the long version of the squash
480 # commit message, then die_with_patch. This code path requires the
481 # user to edit the combined commit message for all commits that have
482 # been squashed/fixedup so far. So also erase the old squash
483 # messages, effectively causing the combined commit to be used as the
484 # new basis for any further squash/fixups. Args: sha1 rest
485 die_failed_squash
() {
486 mv "$SQUASH_MSG" "$MSG" ||
exit
488 cp "$MSG" "$GIT_DIR"/MERGE_MSG ||
exit
490 warn
"Could not apply $1... $2"
495 rm -f "$MSG" "$AUTHOR_SCRIPT" "$AMEND" ||
exit
496 read command sha1 rest
< "$TODO"
502 comment_for_reflog pick
506 die_with_patch
$sha1 "Could not apply $sha1... $rest"
509 comment_for_reflog reword
513 die_with_patch
$sha1 "Could not apply $sha1... $rest"
517 comment_for_reflog edit
521 die_with_patch
$sha1 "Could not apply $sha1... $rest"
523 git rev-parse
--verify HEAD
> "$AMEND"
524 warn
"Stopped at $sha1... $rest"
525 warn
"You can amend the commit now, with"
527 warn
" git commit --amend"
529 warn
"Once you are satisfied with your changes, run"
531 warn
" git rebase --continue"
544 comment_for_reflog
$squash_style
546 test -f "$DONE" && has_action
"$DONE" ||
547 die
"Cannot '$squash_style' without a previous commit"
550 update_squash_messages
$squash_style $sha1
551 author_script
=$
(get_author_ident_from_commit HEAD
)
552 echo "$author_script" > "$AUTHOR_SCRIPT"
553 eval "$author_script"
554 output git
reset --soft HEAD^
555 pick_one
-n $sha1 || die_failed_squash
$sha1 "$rest"
556 case "$(peek_next_command)" in
558 # This is an intermediate commit; its message will only be
559 # used in case of trouble. So use the long version:
560 do_with_author output git commit
--no-verify -F "$SQUASH_MSG" ||
561 die_failed_squash
$sha1 "$rest"
564 # This is the final command of this squash/fixup group
565 if test -f "$FIXUP_MSG"
567 do_with_author git commit
--no-verify -F "$FIXUP_MSG" ||
568 die_failed_squash
$sha1 "$rest"
570 cp "$SQUASH_MSG" "$GIT_DIR"/SQUASH_MSG ||
exit
571 rm -f "$GIT_DIR"/MERGE_MSG
572 do_with_author git commit
--no-verify -e ||
573 die_failed_squash
$sha1 "$rest"
575 rm -f "$SQUASH_MSG" "$FIXUP_MSG"
580 comment_for_reflog goto
582 output git
reset --hard $
(parse_commit
$sha1) ||
583 die
"Could not reset to $sha1"
586 comment_for_reflog merge
588 # this already dies with patch on error
589 output merge_one
$sha1 $rest ||
# $sha1 is not the real sha1...
593 warn
"Unknown command: $command $sha1 $rest"
594 if git rev-parse
--verify -q "$sha1" >/dev
/null
596 die_with_patch
$sha1 "Please fix this in the file $TODO."
598 die
"Please fix this in the file $TODO."
602 test -s "$TODO" && return
604 comment_for_reflog finish
&&
605 HEADNAME
=$
(cat "$DOTEST"/head-name
) &&
606 OLDHEAD
=$
(cat "$DOTEST"/head) &&
607 SHORTONTO
=$
(git rev-parse
--short $
(cat "$DOTEST"/onto
)) &&
608 NEWHEAD
=$
(git rev-parse HEAD
) &&
611 message
="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO" &&
612 git update-ref
-m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
613 git symbolic-ref HEAD
$HEADNAME
616 test ! -f "$DOTEST"/verbose ||
617 git diff-tree
--stat $
(cat "$DOTEST"/head)..HEAD
621 warn
"Successfully rebased and updated $HEADNAME."
633 # skip picking commits whose parents are unchanged
634 skip_unnecessary_picks
() {
636 while read command sha1 rest
638 # fd=3 means we skip the command
639 case "$fd,$command,$(git rev-parse --verify --quiet $sha1^)" in
640 3,pick
,"$ONTO"*|
3,p
,"$ONTO"*)
641 # pick a commit whose parent is current $ONTO -> skip
651 echo "$command${sha1:+ }$sha1${rest:+ }$rest" >&$fd
652 done <"$TODO" >"$TODO.new" 3>>"$DONE" &&
653 mv -f "$TODO".new
"$TODO" ||
654 die
"Could not skip unnecessary pick commands"
657 # check if no other options are set
659 test $# -eq 2 -a "$2" = '--' &&
661 test -z "$PRESERVE_MERGES" &&
662 test -z "$STRATEGY" &&
666 get_saved_options
() {
667 test -d "$REWRITTEN" && PRESERVE_MERGES
=t
668 test -f "$DOTEST"/strategy
&& STRATEGY
="$(cat "$DOTEST"/strategy)"
669 test -f "$DOTEST"/verbose
&& VERBOSE
=t
670 test -f "$DOTEST"/rebase-root
&& REBASE_ROOT
=t
673 # Rearrange the todo list that has both "pick sha1 msg" and
674 # "pick sha1 fixup!/squash! msg" appears in it so that the latter
675 # comes immediately after the former, and change "pick" to
677 rearrange_squash
() {
678 sed -n -e 's/^pick \([0-9a-f]*\) \(squash\)! /\1 \2 /p' \
679 -e 's/^pick \([0-9a-f]*\) \(fixup\)! /\1 \2 /p' \
681 test -s "$1.sq" ||
return
684 while read pick sha1 message
687 *" $sha1 "*) continue ;;
689 echo "$pick $sha1 $message"
690 while read squash action msg
694 echo "$action $squash $action! $msg"
699 done >"$1.rearranged" <"$1"
700 cat "$1.rearranged" >"$1"
701 rm -f "$1.sq" "$1.rearranged"
709 if left
=${1%...*} right
=${1#*...} &&
710 onto
=$
(git merge-base
--all ${left:-HEAD} ${right:-HEAD})
720 git rev-parse
--verify "$1^0"
727 OK_TO_SKIP_PRE_REBASE
=yes
732 is_standalone
"$@" || usage
734 comment_for_reflog
continue
736 test -d "$DOTEST" || die
"No interactive rebase running"
739 git rev-parse
--verify HEAD
>/dev
/null ||
740 die
"Cannot read HEAD"
741 git update-index
--ignore-submodules --refresh &&
742 git diff-files
--quiet --ignore-submodules ||
743 die
"Working tree is dirty"
745 # do we have anything to commit?
746 if git diff-index
--cached --quiet --ignore-submodules HEAD
--
748 : Nothing to commit
-- skip this
750 .
"$AUTHOR_SCRIPT" ||
751 die
"Cannot find the author identity"
755 amend
=$
(git rev-parse
--verify HEAD
)
756 test "$amend" = $
(cat "$AMEND") ||
758 You have uncommitted changes in your working tree. Please, commit them
759 first and then run 'git rebase --continue' again."
760 git
reset --soft HEAD^ ||
761 die
"Cannot rewind the HEAD"
763 do_with_author git commit
--no-verify -F "$MSG" -e ||
{
764 test -n "$amend" && git
reset --soft $amend
765 die
"Could not commit staged changes."
769 require_clean_work_tree
773 is_standalone
"$@" || usage
775 comment_for_reflog abort
778 test -d "$DOTEST" || die
"No interactive rebase running"
780 HEADNAME
=$
(cat "$DOTEST"/head-name
)
781 HEAD
=$
(cat "$DOTEST"/head)
784 git symbolic-ref HEAD
$HEADNAME
787 output git
reset --hard $HEAD &&
792 is_standalone
"$@" || usage
794 comment_for_reflog skip
797 test -d "$DOTEST" || die
"No interactive rebase running"
799 output git
reset --hard && do_rest
804 STRATEGY
="-s "$
(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
813 # we use merge anyway
832 ONTO
=$
(parse_onto
"$1") ||
833 die
"Does not point to a valid commit: $1"
837 test -z "$REBASE_ROOT" -a $# -ge 1 -a $# -le 2 ||
838 test ! -z "$REBASE_ROOT" -a $# -le 1 || usage
840 die
"Interactive rebase already started"
842 git var GIT_COMMITTER_IDENT
>/dev
/null ||
843 die
"You need to set your committer info first"
845 if test -z "$REBASE_ROOT"
848 UPSTREAM
=$
(git rev-parse
--verify "$1") ||
850 test -z "$ONTO" && ONTO
=$UPSTREAM
856 die
"You must specify --onto when using --root"
859 run_pre_rebase_hook
"$UPSTREAM_ARG" "$@"
861 comment_for_reflog start
863 require_clean_work_tree
867 output git show-ref
--verify --quiet "refs/heads/$1" ||
868 die
"Invalid branchname: $1"
869 output git checkout
"$1" ||
870 die
"Could not checkout $1"
873 HEAD
=$
(git rev-parse
--verify HEAD
) || die
"No HEAD?"
874 mkdir
"$DOTEST" || die
"Could not create temporary $DOTEST"
876 : > "$DOTEST"/interactive || die
"Could not mark as interactive"
877 git symbolic-ref HEAD
> "$DOTEST"/head-name
2> /dev
/null ||
878 echo "detached HEAD" > "$DOTEST"/head-name
880 echo $HEAD > "$DOTEST"/head
881 test -z "$REBASE_ROOT" ||
: >"$DOTEST"/rebase-root
882 echo $ONTO > "$DOTEST"/onto
883 test -z "$STRATEGY" ||
echo "$STRATEGY" > "$DOTEST"/strategy
884 test t
= "$VERBOSE" && : > "$DOTEST"/verbose
885 if test t
= "$PRESERVE_MERGES"
887 if test -z "$REBASE_ROOT"
889 mkdir
"$REWRITTEN" &&
890 for c
in $
(git merge-base
--all $HEAD $UPSTREAM)
892 echo $ONTO > "$REWRITTEN"/$c ||
893 die
"Could not init rewritten commits"
896 mkdir
"$REWRITTEN" &&
897 echo $ONTO > "$REWRITTEN"/root ||
898 die
"Could not init rewritten commits"
900 # No cherry-pick because our first pass is to determine
901 # parents to rewrite and skipping dropped commits would
902 # prematurely end our probe
904 first_after_upstream
="$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)"
906 MERGES_OPTION
="--no-merges --cherry-pick"
909 SHORTHEAD
=$
(git rev-parse
--short $HEAD)
910 SHORTONTO
=$
(git rev-parse
--short $ONTO)
911 SHORTUPSTREAM
=$
(git rev-parse
--short $UPSTREAM)
912 REVISIONS
=$UPSTREAM...
$HEAD
913 SHORTREVISIONS
=$SHORTUPSTREAM..
$SHORTHEAD
914 git rev-list
$MERGES_OPTION --pretty=oneline
--abbrev-commit \
915 --abbrev=7 --reverse --left-right --topo-order \
917 sed -n "s/^>//p" |
while read shortsha1 rest
919 if test t
!= "$PRESERVE_MERGES"
921 echo "pick $shortsha1 $rest" >> "$TODO"
923 sha1
=$
(git rev-parse
$shortsha1)
924 if test -z "$REBASE_ROOT"
927 for p
in $
(git rev-list
--parents -1 $sha1 | cut
-d' ' -s -f2-)
929 if test -f "$REWRITTEN"/$p -a \
( $p != $ONTO -o $sha1 = $first_after_upstream \
)
937 if test f
= "$preserve"
939 touch "$REWRITTEN"/$sha1
940 echo "pick $shortsha1 $rest" >> "$TODO"
945 # Watch for commits that been dropped by --cherry-pick
946 if test t
= "$PRESERVE_MERGES"
949 # Save all non-cherry-picked changes
950 git rev-list
$REVISIONS --left-right --cherry-pick | \
951 sed -n "s/^>//p" > "$DOTEST"/not-cherry-picks
952 # Now all commits and note which ones are missing in
953 # not-cherry-picks and hence being dropped
954 git rev-list
$REVISIONS |
957 if test -f "$REWRITTEN"/$rev -a "$(sane_grep "$rev" "$DOTEST"/not-cherry-picks)" = ""
959 # Use -f2 because if rev-list is telling us this commit is
960 # not worthwhile, we don't want to track its multiple heads,
961 # just the history of its first-parent for others that will
962 # be rebasing on top of it
963 git rev-list
--parents -1 $rev | cut
-d' ' -s -f2 > "$DROPPED"/$rev
964 short
=$
(git rev-list
-1 --abbrev-commit --abbrev=7 $rev)
965 sane_grep
-v "^[a-z][a-z]* $short" <"$TODO" > "${TODO}2" ; mv "${TODO}2" "$TODO"
971 test -s "$TODO" ||
echo noop
>> "$TODO"
972 test -n "$AUTOSQUASH" && rearrange_squash
"$TODO"
973 cat >> "$TODO" << EOF
975 # Rebase $SHORTREVISIONS onto $SHORTONTO
978 # p, pick = use commit
979 # r, reword = use commit, but edit the commit message
980 # e, edit = use commit, but stop for amending
981 # s, squash = use commit, but meld into previous commit
982 # f, fixup = like "squash", but discard this commit's log message
983 # g, goto = reset the current state to the given commit
984 # m, merge parents <parents> original <original merge commit>
985 # = redo the given merge commit
987 # If you remove a line here THAT COMMIT WILL BE LOST.
988 # However, if you remove everything, the rebase will be aborted.
992 has_action
"$TODO" ||
993 die_abort
"Nothing to do"
995 cp "$TODO" "$TODO".backup
996 git_editor
"$TODO" ||
997 die_abort
"Could not execute editor"
999 has_action
"$TODO" ||
1000 die_abort
"Nothing to do"
1002 test -d "$REWRITTEN" || skip_unnecessary_picks
1004 git update-ref ORIG_HEAD
$HEAD
1005 output git checkout
$ONTO && do_rest