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 no-ff cherry-pick all commits, even if unchanged
24 m,merge always used (no-op)
25 i,interactive always used (no-op)
27 continue continue rebasing process
28 abort abort rebasing process and restore original branch
29 skip skip current patch and continue rebasing process
30 no-verify override pre-rebase hook from stopping the operation
31 verify allow pre-rebase hook to run
32 root rebase all reachable commmits up to the root(s)
33 autosquash move commits that begin with squash!/fixup! under -i
39 dotest
="$GIT_DIR/rebase-merge"
41 # The file containing rebase commands, comments, and empty lines.
42 # This file is created by "git rebase -i" then edited by the user. As
43 # the lines are processed, they are removed from the front of this
44 # file and written to the tail of $done.
45 todo
="$dotest"/git-rebase-todo
47 # The rebase command lines that have already been processed. A line
48 # is moved here when it is first handled, before any associated user
52 # The commit message that is planned to be used for any changes that
53 # need to be committed following a user interaction.
56 # The file into which is accumulated the suggested commit message for
57 # squash/fixup commands. When the first of a series of squash/fixups
58 # is seen, the file is created and the commit message from the
59 # previous commit and from the first squash/fixup commit are written
60 # to it. The commit message for each subsequent squash/fixup commit
61 # is appended to the file as it is processed.
63 # The first line of the file is of the form
64 # # This is a combination of $count commits.
65 # where $count is the number of commits whose messages have been
66 # written to the file so far (including the initial "pick" commit).
67 # Each time that a commit message is processed, this line is read and
68 # updated. It is deleted just before the combined commit is made.
69 squash_msg
="$dotest"/message-squash
71 # If the current series of squash/fixups has not yet included a squash
72 # command, then this file exists and holds the commit message of the
73 # original "pick" commit. (If the series ends without a "squash"
74 # command, then this can be used as the commit message of the combined
75 # commit without opening the editor.)
76 fixup_msg
="$dotest"/message-fixup
78 # $rewritten is the name of a directory containing files for each
79 # commit that is reachable by at least one merge base of $head and
80 # $upstream. They are not necessarily rewritten, but their children
81 # might be. This ensures that commits on merged, but otherwise
82 # unrelated side branches are left alone. (Think "X" in the man page's
84 rewritten
="$dotest"/rewritten
86 dropped
="$dotest"/dropped
88 # A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
89 # GIT_AUTHOR_DATE that will be used for the commit that is currently
91 author_script
="$dotest"/author-script
93 # When an "edit" rebase command is being processed, the SHA1 of the
94 # commit to be edited is recorded in this file. When "git rebase
95 # --continue" is executed, if there are any staged changes then they
96 # will be amended to the HEAD commit, but only provided the HEAD
97 # commit is still the commit to be edited. When any other rebase
98 # command is processed, this file is deleted.
101 # For the post-rewrite hook, we make a list of rewritten commits and
102 # their new sha1s. The rewritten-pending list keeps the sha1s of
103 # commits that have been processed, but not committed yet,
104 # e.g. because they are waiting for a 'squash' command.
105 rewritten_list
="$dotest"/rewritten-list
106 rewritten_pending
="$dotest"/rewritten-pending
112 ok_to_skip_pre_rebase
=
115 test "$(git config --bool rebase.autosquash)" = "true" && autosquash
=t
118 GIT_CHERRY_PICK_HELP
="\
119 hint: after resolving the conflicts, mark the corrected paths
120 hint: with 'git add <paths>' and run 'git rebase --continue'"
121 export GIT_CHERRY_PICK_HELP
124 printf '%s\n' "$*" >&2
132 test $status != 0 && printf "%s\n" "$output"
141 # Output the commit message for the specified commit.
143 git cat-file commit
"$1" |
sed "1,/^$/d"
146 run_pre_rebase_hook
() {
147 if test -z "$ok_to_skip_pre_rebase" &&
148 test -x "$GIT_DIR/hooks/pre-rebase"
150 "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} ||
{
151 echo >&2 "The pre-rebase hook refused to rebase."
158 orig_reflog_action
="$GIT_REFLOG_ACTION"
160 comment_for_reflog
() {
161 case "$orig_reflog_action" in
163 GIT_REFLOG_ACTION
="rebase -i ($1)"
164 export GIT_REFLOG_ACTION
170 mark_action_done
() {
171 sed -e 1q
< "$todo" >> "$done"
172 sed -e 1d
< "$todo" >> "$todo".new
173 mv -f "$todo".new
"$todo"
174 new_count
=$
(sane_grep
-c '^[^#]' < "$done")
175 total
=$
(($new_count+$
(sane_grep
-c '^[^#]' < "$todo")))
176 if test "$last_count" != "$new_count"
178 last_count
=$new_count
179 printf "Rebasing (%d/%d)\r" $new_count $total
180 test -z "$verbose" ||
echo
185 sha1_and_parents
="$(git rev-list --parents -1 "$1")"
186 case "$sha1_and_parents" in
188 git
diff --cc $sha1_and_parents
191 git diff-tree
-p "$1^!"
196 esac > "$dotest"/patch
198 commit_message
"$1" > "$msg"
199 test -f "$author_script" ||
200 get_author_ident_from_commit
"$1" > "$author_script"
204 echo "$1" > "$dotest"/stopped-sha
216 sane_grep
'^[^#]' "$1" >/dev
/null
219 # Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and
220 # GIT_AUTHOR_DATE exported from the current environment.
223 export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE
230 case "$1" in -n) sha1
=$2; ff
= ;; *) sha1
=$1 ;; esac
231 case "$force_rebase" in '') ;; ?
*) ff
= ;; esac
232 output git rev-parse
--verify $sha1 || die
"Invalid commit name: $sha1"
233 test -d "$rewritten" &&
234 pick_one_preserving_merges
"$@" && return
235 if test -n "$rebase_root"
237 output git cherry-pick
"$@"
240 output git cherry-pick
$ff "$@"
243 pick_one_preserving_merges
() {
254 sha1
=$
(git rev-parse
$sha1)
256 if test -f "$dotest"/current-commit
258 if test "$fast_forward" = t
260 while read current_commit
262 git rev-parse HEAD
> "$rewritten"/$current_commit
263 done <"$dotest"/current-commit
264 rm "$dotest"/current-commit ||
265 die
"Cannot write current commit's replacement sha1"
269 echo $sha1 >> "$dotest"/current-commit
271 # rewrite parents; if none were rewritten, we can fast-forward.
273 pend
=" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)"
274 if test "$pend" = " "
278 while [ "$pend" != "" ]
280 p
=$
(expr "$pend" : ' \([^ ]*\)')
283 if test -f "$rewritten"/$p
285 new_p
=$
(cat "$rewritten"/$p)
287 # If the todo reordered commits, and our parent is marked for
288 # rewriting, but hasn't been gotten to yet, assume the user meant to
289 # drop it on top of the current HEAD
292 new_p
=$
(git rev-parse HEAD
)
295 test $p != $new_p && fast_forward
=f
296 case "$new_parents" in
298 ;; # do nothing; that parent is already there
300 new_parents
="$new_parents $new_p"
304 if test -f "$dropped"/$p
307 replacement
="$(cat "$dropped"/$p)"
308 test -z "$replacement" && replacement
=root
309 pend
=" $replacement$pend"
311 new_parents
="$new_parents $p"
315 case $fast_forward in
317 output warn
"Fast-forward to $sha1"
318 output git
reset --hard $sha1 ||
319 die
"Cannot fast-forward to $sha1"
322 first_parent
=$
(expr "$new_parents" : ' \([^ ]*\)')
326 # detach HEAD to current parent
327 output git checkout
$first_parent 2> /dev
/null ||
328 die
"Cannot move HEAD to $first_parent"
331 case "$new_parents" in
333 test "a$1" = a-n
&& die
"Refusing to squash a merge: $sha1"
336 author_script_content
=$
(get_author_ident_from_commit
$sha1)
337 eval "$author_script_content"
338 msg_content
="$(commit_message $sha1)"
339 # No point in merging the first parent, that's HEAD
340 new_parents
=${new_parents# $first_parent}
341 if ! do_with_author output \
342 git merge
${strategy:+-s $strategy} -m \
343 "$msg_content" $new_parents
345 printf "%s\n" "$msg_content" > "$GIT_DIR"/MERGE_MSG
346 die_with_patch
$sha1 "Error redoing merge $sha1"
348 echo "$sha1 $(git rev-parse HEAD^0)" >> "$rewritten_list"
351 output git cherry-pick
"$@" ||
352 die_with_patch
$sha1 "Could not pick $sha1"
361 *1[0-9]|
*[04-9]) echo "$1"th
;;
368 update_squash_messages
() {
369 if test -f "$squash_msg"; then
370 mv "$squash_msg" "$squash_msg".bak ||
exit
372 -e "1s/^# This is a combination of \(.*\) commits\./\1/p" \
373 -e "q" < "$squash_msg".bak
)+1))
375 echo "# This is a combination of $count commits."
376 sed -e 1d
-e '2,/^./{
378 }' <"$squash_msg".bak
381 commit_message HEAD
> "$fixup_msg" || die
"Cannot write $fixup_msg"
384 echo "# This is a combination of 2 commits."
385 echo "# The first commit's message is:"
394 echo "# This is the $(nth_string $count) commit message:"
400 echo "# The $(nth_string $count) commit message will be skipped:"
402 commit_message
$2 |
sed -e 's/^/# /'
407 peek_next_command
() {
408 sed -n -e "/^#/d" -e '/^$/d' -e "s/ .*//p" -e "q" < "$todo"
411 # A squash/fixup has failed. Prepare the long version of the squash
412 # commit message, then die_with_patch. This code path requires the
413 # user to edit the combined commit message for all commits that have
414 # been squashed/fixedup so far. So also erase the old squash
415 # messages, effectively causing the combined commit to be used as the
416 # new basis for any further squash/fixups. Args: sha1 rest
417 die_failed_squash
() {
418 mv "$squash_msg" "$msg" ||
exit
420 cp "$msg" "$GIT_DIR"/MERGE_MSG ||
exit
422 warn
"Could not apply $1... $2"
426 flush_rewritten_pending
() {
427 test -s "$rewritten_pending" ||
return
428 newsha1
="$(git rev-parse HEAD^0)"
429 sed "s/$/ $newsha1/" < "$rewritten_pending" >> "$rewritten_list"
430 rm -f "$rewritten_pending"
433 record_in_rewritten
() {
434 oldsha1
="$(git rev-parse $1)"
435 echo "$oldsha1" >> "$rewritten_pending"
437 case "$(peek_next_command)" in
441 flush_rewritten_pending
447 rm -f "$msg" "$author_script" "$amend" ||
exit
448 read -r command sha1 rest
< "$todo"
454 comment_for_reflog pick
458 die_with_patch
$sha1 "Could not apply $sha1... $rest"
459 record_in_rewritten
$sha1
462 comment_for_reflog reword
466 die_with_patch
$sha1 "Could not apply $sha1... $rest"
467 git commit
--amend --no-post-rewrite
468 record_in_rewritten
$sha1
471 comment_for_reflog edit
475 die_with_patch
$sha1 "Could not apply $sha1... $rest"
476 echo "$sha1" > "$dotest"/stopped-sha
478 git rev-parse
--verify HEAD
> "$amend"
479 warn
"Stopped at $sha1... $rest"
480 warn
"You can amend the commit now, with"
482 warn
" git commit --amend"
484 warn
"Once you are satisfied with your changes, run"
486 warn
" git rebase --continue"
499 comment_for_reflog
$squash_style
501 test -f "$done" && has_action
"$done" ||
502 die
"Cannot '$squash_style' without a previous commit"
505 update_squash_messages
$squash_style $sha1
506 author_script_content
=$
(get_author_ident_from_commit HEAD
)
507 echo "$author_script_content" > "$author_script"
508 eval "$author_script_content"
509 output git
reset --soft HEAD^
510 pick_one
-n $sha1 || die_failed_squash
$sha1 "$rest"
511 case "$(peek_next_command)" in
513 # This is an intermediate commit; its message will only be
514 # used in case of trouble. So use the long version:
515 do_with_author output git commit
--no-verify -F "$squash_msg" ||
516 die_failed_squash
$sha1 "$rest"
519 # This is the final command of this squash/fixup group
520 if test -f "$fixup_msg"
522 do_with_author git commit
--no-verify -F "$fixup_msg" ||
523 die_failed_squash
$sha1 "$rest"
525 cp "$squash_msg" "$GIT_DIR"/SQUASH_MSG ||
exit
526 rm -f "$GIT_DIR"/MERGE_MSG
527 do_with_author git commit
--no-verify -e ||
528 die_failed_squash
$sha1 "$rest"
530 rm -f "$squash_msg" "$fixup_msg"
533 record_in_rewritten
$sha1
536 read -r command rest
< "$todo"
538 printf 'Executing: %s\n' "$rest"
539 # "exec" command doesn't take a sha1 in the todo-list.
540 # => can't just use $sha1 here.
541 git rev-parse
--verify HEAD
> "$dotest"/stopped-sha
542 ${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
544 if test "$status" -ne 0
546 warn
"Execution failed: $rest"
547 warn
"You can fix the problem, and then run"
549 warn
" git rebase --continue"
553 # Run in subshell because require_clean_work_tree can die.
554 if ! (require_clean_work_tree
"rebase")
556 warn
"Commit or stash your changes, and then run"
558 warn
" git rebase --continue"
564 warn
"Unknown command: $command $sha1 $rest"
565 if git rev-parse
--verify -q "$sha1" >/dev
/null
567 die_with_patch
$sha1 "Please fix this in the file $todo."
569 die
"Please fix this in the file $todo."
573 test -s "$todo" && return
575 comment_for_reflog finish
&&
576 headname
=$
(cat "$dotest"/head-name
) &&
577 oldhead
=$
(cat "$dotest"/head) &&
578 shortonto
=$
(git rev-parse
--short $
(cat "$dotest"/onto
)) &&
579 newhead
=$
(git rev-parse HEAD
) &&
582 message
="$GIT_REFLOG_ACTION: $headname onto $shortonto" &&
583 git update-ref
-m "$message" $headname $newhead $oldhead &&
584 git symbolic-ref HEAD
$headname
587 test ! -f "$dotest"/verbose ||
588 git diff-tree
--stat $
(cat "$dotest"/head)..HEAD
591 test -s "$rewritten_list" &&
592 git notes copy
--for-rewrite=rebase
< "$rewritten_list" ||
593 true
# we don't care if this copying failed
595 if test -x "$GIT_DIR"/hooks
/post-rewrite
&&
596 test -s "$rewritten_list"; then
597 "$GIT_DIR"/hooks
/post-rewrite rebase
< "$rewritten_list"
598 true
# we don't care if this hook failed
602 warn
"Successfully rebased and updated $headname."
614 # skip picking commits whose parents are unchanged
615 skip_unnecessary_picks
() {
617 while read -r command rest
619 # fd=3 means we skip the command
620 case "$fd,$command" in
622 # pick a commit whose parent is current $onto -> skip
624 case "$(git rev-parse --verify --quiet "$sha1"^)" in
640 printf '%s\n' "$command${rest:+ }$rest" >&$fd
641 done <"$todo" >"$todo.new" 3>>"$done" &&
642 mv -f "$todo".new
"$todo" &&
643 case "$(peek_next_command)" in
645 record_in_rewritten
"$onto"
648 die
"Could not skip unnecessary pick commands"
651 # check if no other options are set
653 test $# -eq 2 -a "$2" = '--' &&
655 test -z "$preserve_merges" &&
656 test -z "$strategy" &&
660 get_saved_options
() {
661 test -d "$rewritten" && preserve_merges
=t
662 test -f "$dotest"/strategy
&& strategy
="$(cat "$dotest"/strategy)"
663 test -f "$dotest"/verbose
&& verbose
=t
664 test -f "$dotest"/rebase-root
&& rebase_root
=t
667 # Rearrange the todo list that has both "pick sha1 msg" and
668 # "pick sha1 fixup!/squash! msg" appears in it so that the latter
669 # comes immediately after the former, and change "pick" to
671 rearrange_squash
() {
672 # extract fixup!/squash! lines and resolve any referenced sha1's
673 while read -r pick sha1 message
676 "squash! "*|
"fixup! "*)
677 action
="${message%%!*}"
678 rest
="${message#*! }"
679 echo "$sha1 $action $rest"
680 # if it's a single word, try to resolve to a full sha1 and
681 # emit a second copy. This allows us to match on both message
683 if test "${rest#* }" = "$rest"; then
684 fullsha
="$(git rev-parse -q --verify "$rest" 2>/dev/null)"
685 if test -n "$fullsha"; then
686 # prefix the action to uniquely identify this line as
687 # intended for full sha1 match
688 echo "$sha1 +$action $fullsha"
693 test -s "$1.sq" ||
return
696 while read -r pick sha1 message
699 *" $sha1 "*) continue ;;
701 printf '%s\n' "$pick $sha1 $message"
703 while read -r squash action msg_content
706 *" $squash "*) continue ;;
712 # full sha1 prefix test
713 case "$msg_content" in "$sha1"*) emit
=1;; esac ;;
715 # message prefix test
716 case "$message" in "$msg_content"*) emit
=1;; esac ;;
718 if test $emit = 1; then
719 printf '%s\n' "$action $squash $action! $msg_content"
723 done >"$1.rearranged" <"$1"
724 cat "$1.rearranged" >"$1"
725 rm -f "$1.sq" "$1.rearranged"
733 if left
=${1%...*} right
=${1#*...} &&
734 onto
=$
(git merge-base
--all ${left:-HEAD} ${right:-HEAD})
744 git rev-parse
--verify "$1^0"
751 ok_to_skip_pre_rebase
=yes
754 ok_to_skip_pre_rebase
=
757 is_standalone
"$@" || usage
759 comment_for_reflog
continue
761 test -d "$dotest" || die
"No interactive rebase running"
764 git rev-parse
--verify HEAD
>/dev
/null ||
765 die
"Cannot read HEAD"
766 git update-index
--ignore-submodules --refresh &&
767 git diff-files
--quiet --ignore-submodules ||
768 die
"Working tree is dirty"
770 # do we have anything to commit?
771 if git diff-index
--cached --quiet --ignore-submodules HEAD
--
773 : Nothing to commit
-- skip this
775 .
"$author_script" ||
776 die
"Cannot find the author identity"
780 current_head
=$
(git rev-parse
--verify HEAD
)
781 test "$current_head" = $
(cat "$amend") ||
783 You have uncommitted changes in your working tree. Please, commit them
784 first and then run 'git rebase --continue' again."
785 git
reset --soft HEAD^ ||
786 die
"Cannot rewind the HEAD"
788 do_with_author git commit
--no-verify -F "$msg" -e ||
{
789 test -n "$current_head" && git
reset --soft $current_head
790 die
"Could not commit staged changes."
794 record_in_rewritten
"$(cat "$dotest"/stopped-sha)"
796 require_clean_work_tree
"rebase"
800 is_standalone
"$@" || usage
802 comment_for_reflog abort
805 test -d "$dotest" || die
"No interactive rebase running"
807 headname
=$
(cat "$dotest"/head-name
)
808 head=$
(cat "$dotest"/head)
811 git symbolic-ref HEAD
$headname
814 output git
reset --hard $head &&
819 is_standalone
"$@" || usage
821 comment_for_reflog skip
824 test -d "$dotest" || die
"No interactive rebase running"
826 output git
reset --hard && do_rest
831 strategy
=$
(expr "z$1" : 'z-[^=]*=\(.*\)') ;;
840 # we use merge anyway
864 test 2 -le "$#" || usage
878 onto
=$
(parse_onto
"$onto") || die
"Does not point to a valid commit: $1"
881 test -z "$rebase_root" -a $# -ge 1 -a $# -le 2 ||
882 test ! -z "$rebase_root" -a $# -le 1 || usage
884 die
"Interactive rebase already started"
886 git var GIT_COMMITTER_IDENT
>/dev
/null ||
887 die
"You need to set your committer info first"
889 if test -z "$rebase_root"
892 upstream
=$
(git rev-parse
--verify "$1") || die
"Invalid base"
893 test -z "$onto" && onto
=$upstream
899 die
"You must specify --onto when using --root"
901 run_pre_rebase_hook
"$upstream_arg" "$@"
903 comment_for_reflog start
905 require_clean_work_tree
"rebase" "Please commit or stash them."
909 output git checkout
"$1" -- ||
910 die
"Could not checkout $1"
913 head=$
(git rev-parse
--verify HEAD
) || die
"No HEAD?"
914 mkdir
"$dotest" || die
"Could not create temporary $dotest"
916 : > "$dotest"/interactive || die
"Could not mark as interactive"
917 git symbolic-ref HEAD
> "$dotest"/head-name
2> /dev
/null ||
918 echo "detached HEAD" > "$dotest"/head-name
920 echo $head > "$dotest"/head
921 case "$rebase_root" in
923 rm -f "$dotest"/rebase-root
;;
925 : >"$dotest"/rebase-root
;;
927 echo $onto > "$dotest"/onto
928 test -z "$strategy" ||
echo "$strategy" > "$dotest"/strategy
929 test t
= "$verbose" && : > "$dotest"/verbose
930 if test t
= "$preserve_merges"
932 if test -z "$rebase_root"
934 mkdir
"$rewritten" &&
935 for c
in $
(git merge-base
--all $head $upstream)
937 echo $onto > "$rewritten"/$c ||
938 die
"Could not init rewritten commits"
941 mkdir
"$rewritten" &&
942 echo $onto > "$rewritten"/root ||
943 die
"Could not init rewritten commits"
945 # No cherry-pick because our first pass is to determine
946 # parents to rewrite and skipping dropped commits would
947 # prematurely end our probe
949 first_after_upstream
="$(git rev-list --reverse --first-parent $upstream..$head | head -n 1)"
951 merges_option
="--no-merges --cherry-pick"
954 shorthead
=$
(git rev-parse
--short $head)
955 shortonto
=$
(git rev-parse
--short $onto)
956 if test -z "$rebase_root"
957 # this is now equivalent to ! -z "$upstream"
959 shortupstream
=$
(git rev-parse
--short $upstream)
960 revisions
=$upstream...
$head
961 shortrevisions
=$shortupstream..
$shorthead
963 revisions
=$onto...
$head
964 shortrevisions
=$shorthead
966 git rev-list
$merges_option --pretty=oneline
--abbrev-commit \
967 --abbrev=7 --reverse --left-right --topo-order \
970 while read -r shortsha1 rest
972 if test t
!= "$preserve_merges"
974 printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
976 sha1
=$
(git rev-parse
$shortsha1)
977 if test -z "$rebase_root"
980 for p
in $
(git rev-list
--parents -1 $sha1 | cut
-d' ' -s -f2-)
982 if test -f "$rewritten"/$p -a \
( $p != $onto -o $sha1 = $first_after_upstream \
)
990 if test f
= "$preserve"
992 touch "$rewritten"/$sha1
993 printf '%s\n' "pick $shortsha1 $rest" >> "$todo"
998 # Watch for commits that been dropped by --cherry-pick
999 if test t
= "$preserve_merges"
1002 # Save all non-cherry-picked changes
1003 git rev-list
$revisions --left-right --cherry-pick | \
1004 sed -n "s/^>//p" > "$dotest"/not-cherry-picks
1005 # Now all commits and note which ones are missing in
1006 # not-cherry-picks and hence being dropped
1007 git rev-list
$revisions |
1010 if test -f "$rewritten"/$rev -a "$(sane_grep "$rev" "$dotest"/not-cherry-picks)" = ""
1012 # Use -f2 because if rev-list is telling us this commit is
1013 # not worthwhile, we don't want to track its multiple heads,
1014 # just the history of its first-parent for others that will
1015 # be rebasing on top of it
1016 git rev-list
--parents -1 $rev | cut
-d' ' -s -f2 > "$dropped"/$rev
1017 short
=$
(git rev-list
-1 --abbrev-commit --abbrev=7 $rev)
1018 sane_grep
-v "^[a-z][a-z]* $short" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
1019 rm "$rewritten"/$rev
1024 test -s "$todo" ||
echo noop
>> "$todo"
1025 test -n "$autosquash" && rearrange_squash
"$todo"
1026 cat >> "$todo" << EOF
1028 # Rebase $shortrevisions onto $shortonto
1031 # p, pick = use commit
1032 # r, reword = use commit, but edit the commit message
1033 # e, edit = use commit, but stop for amending
1034 # s, squash = use commit, but meld into previous commit
1035 # f, fixup = like "squash", but discard this commit's log message
1036 # x, exec = run command (the rest of the line) using shell
1038 # If you remove a line here THAT COMMIT WILL BE LOST.
1039 # However, if you remove everything, the rebase will be aborted.
1043 has_action
"$todo" ||
1044 die_abort
"Nothing to do"
1046 cp "$todo" "$todo".backup
1047 git_editor
"$todo" ||
1048 die_abort
"Could not execute editor"
1050 has_action
"$todo" ||
1051 die_abort
"Nothing to do"
1053 test -d "$rewritten" ||
test -n "$force_rebase" || skip_unnecessary_picks
1055 output git checkout
$onto || die_abort
"could not detach HEAD"
1056 git update-ref ORIG_HEAD
$head