{"thread":{"id":"48547","subject":"[GSoC][PATCH 0/4] rebase: split rebase -p from rebase -i","startedAt":"2018-05-22T13:31:42Z","lastAt":"2018-05-28T12:36:25Z","messageCount":26,"participants":["Alban Gruin","Stefan Beller","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"348301","messageId":"20180522133110.32723-1-alban.gruin@gmail.com","threadId":"48547","inReplyTo":null,"subject":"[GSoC][PATCH 0/4] rebase: split rebase -p from rebase -i","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T13:31:06Z","receivedAt":"2018-05-22T13:31:42Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This splits the `rebase --preserve-merges` functionnality from\ngit-rebase--interactive.sh. This is part of the effort to depreciate\npreserve-merges. The new script, git-rebase--preserve-merges.sh, should be left\nto bitrot. All the dead code left by the duplication of\ngit-rebase--interactive.sh is also removed.\n\nThis patch series is based of js/sequencer-and-root-commits.\n\nAlban Gruin (4):\n  rebase: duplicate git-rebase--interactive.sh to\n    git-rebase--preserve-merges.sh\n  rebase: strip unused code in git-rebase--preserve-merges.sh\n  rebase: use the new git-rebase--preserve-merges.sh\n  rebase: remove -p code from git-rebase--interactive.sh\n\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--interactive.sh     |  708 +---------------------------\n git-rebase--preserve-merges.sh | 1004 ++++++++++++++++++++++++++++++++++++++++\n git-rebase.sh                  |   32 +-\n 5 files changed, 1040 insertions(+), 707 deletions(-)\n create mode 100644 git-rebase--preserve-merges.sh\n\n-- \n2.16.1\n\n"},{"id":"348302","messageId":"20180522133110.32723-2-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T13:31:07Z","receivedAt":"2018-05-22T13:31:48Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This duplicates git-rebase--interactive.sh to\ngit-rebase--preserve-merges.sh. This is done to split -p from -i. No\nmodifications are made to this file here, but any code that is not used by -p\nwill be stripped in the next commit.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--preserve-merges.sh | 1059 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 1062 insertions(+)\n create mode 100644 git-rebase--preserve-merges.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 833ef3b0b..ef4925485 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -117,6 +117,7 @@\n /git-rebase--helper\n /git-rebase--interactive\n /git-rebase--merge\n+/git-rebase--preserve-merges\n /git-receive-pack\n /git-reflog\n /git-remote\ndiff --git a/Makefile b/Makefile\nindex 50da82b01..810a0d0f4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -582,6 +582,7 @@ SCRIPT_LIB += git-mergetool--lib\n SCRIPT_LIB += git-parse-remote\n SCRIPT_LIB += git-rebase--am\n SCRIPT_LIB += git-rebase--interactive\n+SCRIPT_LIB += git-rebase--preserve-merges\n SCRIPT_LIB += git-rebase--merge\n SCRIPT_LIB += git-sh-setup\n SCRIPT_LIB += git-sh-i18n\n@@ -2271,6 +2272,7 @@ LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH)\n LOCALIZED_SH += git-parse-remote.sh\n LOCALIZED_SH += git-rebase--interactive.sh\n+LOCALIZED_SH += git-rebase--preserve-merges.sh\n LOCALIZED_SH += git-sh-setup.sh\n LOCALIZED_PERL = $(SCRIPT_PERL)\n \ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nnew file mode 100644\nindex 000000000..9947e6265\n--- /dev/null\n+++ b/git-rebase--preserve-merges.sh\n@@ -0,0 +1,1059 @@\n+# This shell script fragment is sourced by git-rebase to implement\n+# its interactive mode.  \"git rebase --interactive\" makes it easy\n+# to fix up commits in the middle of a series and rearrange commits.\n+#\n+# Copyright (c) 2006 Johannes E. Schindelin\n+#\n+# The original idea comes from Eric W. Biederman, in\n+# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n+#\n+# The file containing rebase commands, comments, and empty lines.\n+# This file is created by \"git rebase -i\" then edited by the user.  As\n+# the lines are processed, they are removed from the front of this\n+# file and written to the tail of $done.\n+todo=\"$state_dir\"/git-rebase-todo\n+\n+# The rebase command lines that have already been processed.  A line\n+# is moved here when it is first handled, before any associated user\n+# actions.\n+done=\"$state_dir\"/done\n+\n+# The commit message that is planned to be used for any changes that\n+# need to be committed following a user interaction.\n+msg=\"$state_dir\"/message\n+\n+# The file into which is accumulated the suggested commit message for\n+# squash/fixup commands.  When the first of a series of squash/fixups\n+# is seen, the file is created and the commit message from the\n+# previous commit and from the first squash/fixup commit are written\n+# to it.  The commit message for each subsequent squash/fixup commit\n+# is appended to the file as it is processed.\n+#\n+# The first line of the file is of the form\n+#     # This is a combination of $count commits.\n+# where $count is the number of commits whose messages have been\n+# written to the file so far (including the initial \"pick\" commit).\n+# Each time that a commit message is processed, this line is read and\n+# updated.  It is deleted just before the combined commit is made.\n+squash_msg=\"$state_dir\"/message-squash\n+\n+# If the current series of squash/fixups has not yet included a squash\n+# command, then this file exists and holds the commit message of the\n+# original \"pick\" commit.  (If the series ends without a \"squash\"\n+# command, then this can be used as the commit message of the combined\n+# commit without opening the editor.)\n+fixup_msg=\"$state_dir\"/message-fixup\n+\n+# $rewritten is the name of a directory containing files for each\n+# commit that is reachable by at least one merge base of $head and\n+# $upstream. They are not necessarily rewritten, but their children\n+# might be.  This ensures that commits on merged, but otherwise\n+# unrelated side branches are left alone. (Think \"X\" in the man page's\n+# example.)\n+rewritten=\"$state_dir\"/rewritten\n+\n+dropped=\"$state_dir\"/dropped\n+\n+end=\"$state_dir\"/end\n+msgnum=\"$state_dir\"/msgnum\n+\n+# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE that will be used for the commit that is currently\n+# being rebased.\n+author_script=\"$state_dir\"/author-script\n+\n+# When an \"edit\" rebase command is being processed, the SHA1 of the\n+# commit to be edited is recorded in this file.  When \"git rebase\n+# --continue\" is executed, if there are any staged changes then they\n+# will be amended to the HEAD commit, but only provided the HEAD\n+# commit is still the commit to be edited.  When any other rebase\n+# command is processed, this file is deleted.\n+amend=\"$state_dir\"/amend\n+\n+# For the post-rewrite hook, we make a list of rewritten commits and\n+# their new sha1s.  The rewritten-pending list keeps the sha1s of\n+# commits that have been processed, but not committed yet,\n+# e.g. because they are waiting for a 'squash' command.\n+rewritten_list=\"$state_dir\"/rewritten-list\n+rewritten_pending=\"$state_dir\"/rewritten-pending\n+\n+# Work around Git for Windows' Bash whose \"read\" does not strip CRLF\n+# and leaves CR at the end instead.\n+cr=$(printf \"\\015\")\n+\n+strategy_args=${strategy:+--strategy=$strategy}\n+test -n \"$strategy_opts\" &&\n+eval '\n+\tfor strategy_opt in '\"$strategy_opts\"'\n+\tdo\n+\t\tstrategy_args=\"$strategy_args -X$(git rev-parse --sq-quote \"${strategy_opt#--}\")\"\n+\tdone\n+'\n+\n+GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n+export GIT_CHERRY_PICK_HELP\n+\n+comment_char=$(git config --get core.commentchar 2>/dev/null)\n+case \"$comment_char\" in\n+'' | auto)\n+\tcomment_char=\"#\"\n+\t;;\n+?)\n+\t;;\n+*)\n+\tcomment_char=$(echo \"$comment_char\" | cut -c1)\n+\t;;\n+esac\n+\n+warn () {\n+\tprintf '%s\\n' \"$*\" >&2\n+}\n+\n+# Output the commit message for the specified commit.\n+commit_message () {\n+\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n+}\n+\n+orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n+\n+comment_for_reflog () {\n+\tcase \"$orig_reflog_action\" in\n+\t''|rebase*)\n+\t\tGIT_REFLOG_ACTION=\"rebase -i ($1)\"\n+\t\texport GIT_REFLOG_ACTION\n+\t\t;;\n+\tesac\n+}\n+\n+last_count=\n+mark_action_done () {\n+\tsed -e 1q < \"$todo\" >> \"$done\"\n+\tsed -e 1d < \"$todo\" >> \"$todo\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tnew_count=$(( $(git stripspace --strip-comments <\"$done\" | wc -l) ))\n+\techo $new_count >\"$msgnum\"\n+\ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n+\techo $total >\"$end\"\n+\tif test \"$last_count\" != \"$new_count\"\n+\tthen\n+\t\tlast_count=$new_count\n+\t\teval_gettext \"Rebasing (\\$new_count/\\$total)\"; printf \"\\r\"\n+\t\ttest -z \"$verbose\" || echo\n+\tfi\n+}\n+\n+# Put the last action marked done at the beginning of the todo list\n+# again. If there has not been an action marked done yet, leave the list of\n+# items on the todo list unchanged.\n+reschedule_last_action () {\n+\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n+\tsed -e \\$d <\"$done\" >\"$done\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tmv -f \"$done\".new \"$done\"\n+}\n+\n+append_todo_help () {\n+\tgettext \"\n+Commands:\n+p, pick = use commit\n+r, reword = use commit, but edit the commit message\n+e, edit = use commit, but stop for amending\n+s, squash = use commit, but meld into previous commit\n+f, fixup = like \\\"squash\\\", but discard this commit's log message\n+x, exec = run command (the rest of the line) using shell\n+d, drop = remove commit\n+\n+These lines can be re-ordered; they are executed from top to bottom.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test $(get_missing_commit_check_level) = error\n+\tthen\n+\t\tgettext \"\n+Do not remove any line. Use 'drop' explicitly to remove a commit.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\telse\n+\t\tgettext \"\n+If you remove a line here THAT COMMIT WILL BE LOST.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\tfi\n+}\n+\n+make_patch () {\n+\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n+\tcase \"$sha1_and_parents\" in\n+\t?*' '?*' '?*)\n+\t\tgit diff --cc $sha1_and_parents\n+\t\t;;\n+\t?*' '?*)\n+\t\tgit diff-tree -p \"$1^!\"\n+\t\t;;\n+\t*)\n+\t\techo \"Root commit\"\n+\t\t;;\n+\tesac > \"$state_dir\"/patch\n+\ttest -f \"$msg\" ||\n+\t\tcommit_message \"$1\" > \"$msg\"\n+\ttest -f \"$author_script\" ||\n+\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n+}\n+\n+die_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch \"$1\"\n+\tdie \"$2\"\n+}\n+\n+exit_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch $1\n+\tgit rev-parse --verify HEAD > \"$amend\"\n+\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\twarn \"$(eval_gettext \"\\\n+You can amend the commit now, with\n+\n+\tgit commit --amend \\$gpg_sign_opt_quoted\n+\n+Once you are satisfied with your changes, run\n+\n+\tgit rebase --continue\")\"\n+\twarn\n+\texit $2\n+}\n+\n+die_abort () {\n+\tapply_autostash\n+\trm -rf \"$state_dir\"\n+\tdie \"$1\"\n+}\n+\n+has_action () {\n+\ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n+}\n+\n+is_empty_commit() {\n+\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n+\t\tsha1=$1\n+\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n+\t}\n+\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n+\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n+\ttest \"$tree\" = \"$ptree\"\n+}\n+\n+is_merge_commit()\n+{\n+\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n+}\n+\n+# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE exported from the current environment.\n+do_with_author () {\n+\t(\n+\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n+\t\t\"$@\"\n+\t)\n+}\n+\n+git_sequence_editor () {\n+\tif test -z \"$GIT_SEQUENCE_EDITOR\"\n+\tthen\n+\t\tGIT_SEQUENCE_EDITOR=\"$(git config sequence.editor)\"\n+\t\tif [ -z \"$GIT_SEQUENCE_EDITOR\" ]\n+\t\tthen\n+\t\t\tGIT_SEQUENCE_EDITOR=\"$(git var GIT_EDITOR)\" || return $?\n+\t\tfi\n+\tfi\n+\n+\teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n+}\n+\n+pick_one () {\n+\tff=--ff\n+\n+\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n+\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n+\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n+\n+\tif is_empty_commit \"$sha1\"\n+\tthen\n+\t\tempty_args=\"--allow-empty\"\n+\tfi\n+\n+\ttest -d \"$rewritten\" &&\n+\t\tpick_one_preserving_merges \"$@\" && return\n+\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n+\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n+\n+\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n+\t# previous task so this commit is not lost.\n+\tret=$?\n+\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n+\treturn $ret\n+}\n+\n+pick_one_preserving_merges () {\n+\tfast_forward=t\n+\tcase \"$1\" in\n+\t-n)\n+\t\tfast_forward=f\n+\t\tsha1=$2\n+\t\t;;\n+\t*)\n+\t\tsha1=$1\n+\t\t;;\n+\tesac\n+\tsha1=$(git rev-parse $sha1)\n+\n+\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n+\tthen\n+\t\twhile read current_commit\n+\t\tdo\n+\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n+\t\tdone <\"$state_dir\"/current-commit\n+\t\trm \"$state_dir\"/current-commit ||\n+\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n+\tfi\n+\n+\techo $sha1 >> \"$state_dir\"/current-commit\n+\n+\t# rewrite parents; if none were rewritten, we can fast-forward.\n+\tnew_parents=\n+\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n+\tif test \"$pend\" = \" \"\n+\tthen\n+\t\tpend=\" root\"\n+\tfi\n+\twhile [ \"$pend\" != \"\" ]\n+\tdo\n+\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n+\t\tpend=\"${pend# $p}\"\n+\n+\t\tif test -f \"$rewritten\"/$p\n+\t\tthen\n+\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n+\n+\t\t\t# If the todo reordered commits, and our parent is marked for\n+\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n+\t\t\t# drop it on top of the current HEAD\n+\t\t\tif test -z \"$new_p\"\n+\t\t\tthen\n+\t\t\t\tnew_p=$(git rev-parse HEAD)\n+\t\t\tfi\n+\n+\t\t\ttest $p != $new_p && fast_forward=f\n+\t\t\tcase \"$new_parents\" in\n+\t\t\t*$new_p*)\n+\t\t\t\t;; # do nothing; that parent is already there\n+\t\t\t*)\n+\t\t\t\tnew_parents=\"$new_parents $new_p\"\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\telse\n+\t\t\tif test -f \"$dropped\"/$p\n+\t\t\tthen\n+\t\t\t\tfast_forward=f\n+\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n+\t\t\t\ttest -z \"$replacement\" && replacement=root\n+\t\t\t\tpend=\" $replacement$pend\"\n+\t\t\telse\n+\t\t\t\tnew_parents=\"$new_parents $p\"\n+\t\t\tfi\n+\t\tfi\n+\tdone\n+\tcase $fast_forward in\n+\tt)\n+\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n+\t\toutput git reset --hard $sha1 ||\n+\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n+\t\t;;\n+\tf)\n+\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n+\n+\t\tif [ \"$1\" != \"-n\" ]\n+\t\tthen\n+\t\t\t# detach HEAD to current parent\n+\t\t\toutput git checkout $first_parent 2> /dev/null ||\n+\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n+\t\tfi\n+\n+\t\tcase \"$new_parents\" in\n+\t\t' '*' '*)\n+\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n+\n+\t\t\t# redo merge\n+\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n+\t\t\teval \"$author_script_content\"\n+\t\t\tmsg_content=\"$(commit_message $sha1)\"\n+\t\t\t# No point in merging the first parent, that's HEAD\n+\t\t\tnew_parents=${new_parents# $first_parent}\n+\t\t\tmerge_args=\"--no-log --no-ff\"\n+\t\t\tif ! do_with_author output eval \\\n+\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n+\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n+\t\t\t\t\"$strategy_args\" \\\n+\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n+\t\t\t\t\"$new_parents\"\n+\t\t\tthen\n+\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n+\t\t\tfi\n+\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n+\t\t\t\t$allow_empty_message \\\n+\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t\"$strategy_args\" \"$@\" ||\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n+\t\t\t;;\n+\t\tesac\n+\t\t;;\n+\tesac\n+}\n+\n+this_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"This is the commit message #\\${n}:\"\n+}\n+\n+skip_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"The commit message #\\${n} will be skipped:\"\n+}\n+\n+update_squash_messages () {\n+\tif test -f \"$squash_msg\"; then\n+\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n+\t\tcount=$(($(sed -n \\\n+\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n+\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n+\t\t\t\t\"This is a combination of \\$count commit.\" \\\n+\t\t\t\t\"This is a combination of \\$count commits.\" \\\n+\t\t\t\t$count)\"\n+\t\t\tsed -e 1d -e '2,/^./{\n+\t\t\t\t/^$/d\n+\t\t\t}' <\"$squash_msg\".bak\n+\t\t} >\"$squash_msg\"\n+\telse\n+\t\tcommit_message HEAD >\"$fixup_msg\" ||\n+\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n+\t\tcount=2\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n+\t\t\techo\n+\t\t\tcat \"$fixup_msg\"\n+\t\t} >\"$squash_msg\"\n+\tfi\n+\tcase $1 in\n+\tsquash)\n+\t\trm -f \"$fixup_msg\"\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n+\t\techo\n+\t\tcommit_message $2\n+\t\t;;\n+\tfixup)\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n+\t\techo\n+\t\t# Change the space after the comment character to TAB:\n+\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n+\t\t;;\n+\tesac >>\"$squash_msg\"\n+}\n+\n+peek_next_command () {\n+\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n+}\n+\n+# A squash/fixup has failed.  Prepare the long version of the squash\n+# commit message, then die_with_patch.  This code path requires the\n+# user to edit the combined commit message for all commits that have\n+# been squashed/fixedup so far.  So also erase the old squash\n+# messages, effectively causing the combined commit to be used as the\n+# new basis for any further squash/fixups.  Args: sha1 rest\n+die_failed_squash() {\n+\tsha1=$1\n+\trest=$2\n+\tmv \"$squash_msg\" \"$msg\" || exit\n+\trm -f \"$fixup_msg\"\n+\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n+\twarn\n+\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tdie_with_patch $sha1 \"\"\n+}\n+\n+flush_rewritten_pending() {\n+\ttest -s \"$rewritten_pending\" || return\n+\tnewsha1=\"$(git rev-parse HEAD^0)\"\n+\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n+\trm -f \"$rewritten_pending\"\n+}\n+\n+record_in_rewritten() {\n+\toldsha1=\"$(git rev-parse $1)\"\n+\techo \"$oldsha1\" >> \"$rewritten_pending\"\n+\n+\tcase \"$(peek_next_command)\" in\n+\tsquash|s|fixup|f)\n+\t\t;;\n+\t*)\n+\t\tflush_rewritten_pending\n+\t\t;;\n+\tesac\n+}\n+\n+do_pick () {\n+\tsha1=$1\n+\trest=$2\n+\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n+\tthen\n+\t\t# Set the correct commit message and author info on the\n+\t\t# sentinel root before cherry-picking the original changes\n+\t\t# without committing (-n).  Finally, update the sentinel again\n+\t\t# to include these changes.  If the cherry-pick results in a\n+\t\t# conflict, this means our behaviour is similar to a standard\n+\t\t# failed cherry-pick during rebase, with a dirty index to\n+\t\t# resolve before manually running git commit --amend then git\n+\t\t# rebase --continue.\n+\t\tgit commit --allow-empty --allow-empty-message --amend \\\n+\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n+\t\t\tpick_one -n $sha1 &&\n+\t\t\tgit commit --allow-empty --allow-empty-message \\\n+\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n+\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n+\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\telse\n+\t\tpick_one $sha1 ||\n+\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tfi\n+}\n+\n+do_next () {\n+\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n+\tread -r command sha1 rest < \"$todo\"\n+\tcase \"$command\" in\n+\t\"$comment_char\"*|''|noop|drop|d)\n+\t\tmark_action_done\n+\t\t;;\n+\t\"$cr\")\n+\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n+\t\tmark_action_done\n+\t\t;;\n+\tpick|p)\n+\t\tcomment_for_reflog pick\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\treword|r)\n+\t\tcomment_for_reflog reword\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n+\t\t\t$allow_empty_message || {\n+\t\t\twarn \"$(eval_gettext \"\\\n+Could not amend commit after successfully picking \\$sha1... \\$rest\n+This is most likely due to an empty commit message, or the pre-commit hook\n+failed. If the pre-commit hook failed, you may need to resolve the issue before\n+you are able to reword the commit.\")\"\n+\t\t\texit_with_patch $sha1 1\n+\t\t}\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tedit|e)\n+\t\tcomment_for_reflog edit\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n+\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n+\t\texit_with_patch $sha1 0\n+\t\t;;\n+\tsquash|s|fixup|f)\n+\t\tcase \"$command\" in\n+\t\tsquash|s)\n+\t\t\tsquash_style=squash\n+\t\t\t;;\n+\t\tfixup|f)\n+\t\t\tsquash_style=fixup\n+\t\t\t;;\n+\t\tesac\n+\t\tcomment_for_reflog $squash_style\n+\n+\t\ttest -f \"$done\" && has_action \"$done\" ||\n+\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n+\n+\t\tmark_action_done\n+\t\tupdate_squash_messages $squash_style $sha1\n+\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n+\t\techo \"$author_script_content\" > \"$author_script\"\n+\t\teval \"$author_script_content\"\n+\t\tif ! pick_one -n $sha1\n+\t\tthen\n+\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n+\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\tfi\n+\t\tcase \"$(peek_next_command)\" in\n+\t\tsquash|s|fixup|f)\n+\t\t\t# This is an intermediate commit; its message will only be\n+\t\t\t# used in case of trouble.  So use the long version:\n+\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n+\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# This is the final command of this squash/fixup group\n+\t\t\tif test -f \"$fixup_msg\"\n+\t\t\tthen\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\telse\n+\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n+\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\tfi\n+\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n+\t\t\t;;\n+\t\tesac\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tx|\"exec\")\n+\t\tread -r command rest < \"$todo\"\n+\t\tmark_action_done\n+\t\teval_gettextln \"Executing: \\$rest\"\n+\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n+\t\tstatus=$?\n+\t\t# Run in subshell because require_clean_work_tree can die.\n+\t\tdirty=f\n+\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n+\t\tif test \"$status\" -ne 0\n+\t\tthen\n+\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n+\t\t\ttest \"$dirty\" = f ||\n+\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n+\n+\t\t\twarn \"$(gettext \"\\\n+You can fix the problem, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\tif test $status -eq 127\t\t# command not found\n+\t\t\tthen\n+\t\t\t\tstatus=1\n+\t\t\tfi\n+\t\t\texit \"$status\"\n+\t\telif test \"$dirty\" = t\n+\t\tthen\n+\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n+\t\t\twarn \"$(eval_gettext \"\\\n+Execution succeeded: \\$rest\n+but left changes to the index and/or the working tree\n+Commit or stash your changes, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\texit 1\n+\t\tfi\n+\t\t;;\n+\t*)\n+\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n+\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n+\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n+\t\tthen\n+\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n+\t\telse\n+\t\t\tdie \"$fixtodo\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\ttest -s \"$todo\" && return\n+\n+\tcomment_for_reflog finish &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\tcase $head_name in\n+\trefs/*)\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n+\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n+\t\tgit symbolic-ref \\\n+\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n+\t\t  HEAD $head_name\n+\t\t;;\n+\tesac && {\n+\t\ttest ! -f \"$state_dir\"/verbose ||\n+\t\t\tgit diff-tree --stat $orig_head..HEAD\n+\t} &&\n+\t{\n+\t\ttest -s \"$rewritten_list\" &&\n+\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n+\t\ttrue # we don't care if this copying failed\n+\t} &&\n+\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n+\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n+\t\t\"$hook\" rebase < \"$rewritten_list\"\n+\t\ttrue # we don't care if this hook failed\n+\tfi &&\n+\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n+\n+\treturn 1 # not failure; just to break the do_rest loop\n+}\n+\n+# can only return 0, when the infinite loop breaks\n+do_rest () {\n+\twhile :\n+\tdo\n+\t\tdo_next || break\n+\tdone\n+}\n+\n+expand_todo_ids() {\n+\tgit rebase--helper --expand-ids\n+}\n+\n+collapse_todo_ids() {\n+\tgit rebase--helper --shorten-ids\n+}\n+\n+# Switch to the branch in $into and notify it in the reflog\n+checkout_onto () {\n+\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $onto_name\"\n+\toutput git checkout $onto || die_abort \"$(gettext \"could not detach HEAD\")\"\n+\tgit update-ref ORIG_HEAD $orig_head\n+}\n+\n+get_missing_commit_check_level () {\n+\tcheck_level=$(git config --get rebase.missingCommitsCheck)\n+\tcheck_level=${check_level:-ignore}\n+\t# Don't be case sensitive\n+\tprintf '%s' \"$check_level\" | tr 'A-Z' 'a-z'\n+}\n+\n+# Initiate an action. If the cannot be any\n+# further action it  may exec a command\n+# or exit and not return.\n+#\n+# TODO: Consider a cleaner return model so it\n+# never exits and always return 0 if process\n+# is complete.\n+#\n+# Parameter 1 is the action to initiate.\n+#\n+# Returns 0 if the action was able to complete\n+# and if 1 if further processing is required.\n+initiate_action () {\n+\tcase \"$1\" in\n+\tcontinue)\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\t# do we have anything to commit?\n+\t\tif git diff-index --cached --quiet HEAD --\n+\t\tthen\n+\t\t\t# Nothing to commit -- skip this commit\n+\n+\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n+\t\telse\n+\t\t\tif ! test -f \"$author_script\"\n+\t\t\tthen\n+\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\t\t\t\tdie \"$(eval_gettext \"\\\n+You have staged changes in your working tree.\n+If these changes are meant to be\n+squashed into the previous commit, run:\n+\n+  git commit --amend \\$gpg_sign_opt_quoted\n+\n+If they are meant to go into a new commit, run:\n+\n+  git commit \\$gpg_sign_opt_quoted\n+\n+In both cases, once you're done, continue with:\n+\n+  git rebase --continue\n+\")\"\n+\t\t\tfi\n+\t\t\t. \"$author_script\" ||\n+\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n+\t\t\tif test -f \"$amend\"\n+\t\t\tthen\n+\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n+\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n+\t\t\t\tdie \"$(gettext \"\\\n+You have uncommitted changes in your working tree. Please commit them\n+first and then run 'git rebase --continue' again.\")\"\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\telse\n+\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\tfi\n+\t\tfi\n+\n+\t\tif test -r \"$state_dir\"/stopped-sha\n+\t\tthen\n+\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n+\t\tfi\n+\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tskip)\n+\t\tgit rerere clear\n+\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tedit-todo)\n+\t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n+\t\tmv -f \"$todo\".new \"$todo\"\n+\t\tcollapse_todo_ids\n+\t\tappend_todo_help\n+\t\tgettext \"\n+You are editing the todo file of an ongoing interactive rebase.\n+To continue rebase after editing, run:\n+    git rebase --continue\n+\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\t\tgit_sequence_editor \"$todo\" ||\n+\t\t\tdie \"$(gettext \"Could not execute editor\")\"\n+\t\texpand_todo_ids\n+\n+\t\texit\n+\t\t;;\n+\tshow-current-patch)\n+\t\texec git show REBASE_HEAD --\n+\t\t;;\n+\t*)\n+\t\treturn 1 # continue\n+\t\t;;\n+\tesac\n+}\n+\n+setup_reflog_action () {\n+\tcomment_for_reflog start\n+\n+\tif test ! -z \"$switch_to\"\n+\tthen\n+\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\"\n+\t\toutput git checkout \"$switch_to\" -- ||\n+\t\t\tdie \"$(eval_gettext \"Could not checkout \\$switch_to\")\"\n+\n+\t\tcomment_for_reflog start\n+\tfi\n+}\n+\n+init_basic_state () {\n+\torig_head=$(git rev-parse --verify HEAD) || die \"$(gettext \"No HEAD?\")\"\n+\tmkdir -p \"$state_dir\" || die \"$(eval_gettext \"Could not create temporary \\$state_dir\")\"\n+\trm -f \"$(git rev-parse --git-path REBASE_HEAD)\"\n+\n+\t: > \"$state_dir\"/interactive || die \"$(gettext \"Could not mark as interactive\")\"\n+\twrite_basic_state\n+}\n+\n+init_revisions_and_shortrevisions () {\n+\tshorthead=$(git rev-parse --short $orig_head)\n+\tshortonto=$(git rev-parse --short $onto)\n+\tif test -z \"$rebase_root\"\n+\t\t# this is now equivalent to ! -z \"$upstream\"\n+\tthen\n+\t\tshortupstream=$(git rev-parse --short $upstream)\n+\t\trevisions=$upstream...$orig_head\n+\t\tshortrevisions=$shortupstream..$shorthead\n+\telse\n+\t\trevisions=$onto...$orig_head\n+\t\tshortrevisions=$shorthead\n+\tfi\n+}\n+\n+complete_action() {\n+\ttest -s \"$todo\" || echo noop >> \"$todo\"\n+\ttest -z \"$autosquash\" || git rebase--helper --rearrange-squash || exit\n+\ttest -n \"$cmd\" && git rebase--helper --add-exec-commands \"$cmd\"\n+\n+\ttodocount=$(git stripspace --strip-comments <\"$todo\" | wc -l)\n+\ttodocount=${todocount##* }\n+\n+cat >>\"$todo\" <<EOF\n+\n+$comment_char $(eval_ngettext \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount command)\" \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n+\t\"$todocount\")\n+EOF\n+\tappend_todo_help\n+\tgettext \"\n+\tHowever, if you remove everything, the rebase will be aborted.\n+\n+\t\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test -z \"$keep_empty\"\n+\tthen\n+\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n+\tfi\n+\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tcp \"$todo\" \"$todo\".backup\n+\tcollapse_todo_ids\n+\tgit_sequence_editor \"$todo\" ||\n+\t\tdie_abort \"$(gettext \"Could not execute editor\")\"\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tgit rebase--helper --check-todo-list || {\n+\t\tret=$?\n+\t\tcheckout_onto\n+\t\texit $ret\n+\t}\n+\n+\texpand_todo_ids\n+\n+\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n+\tdie \"Could not skip unnecessary pick commands\"\n+\n+\tcheckout_onto\n+\tif test -z \"$rebase_root\" && test ! -d \"$rewritten\"\n+\tthen\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t--continue\n+\tfi\n+\tdo_rest\n+}\n+\n+git_rebase__interactive () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n+\tdie \"$(gettext \"Could not generate todo list\")\"\n+\n+\tcomplete_action\n+}\n+\n+git_rebase__interactive__preserve_merges () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tif test -z \"$rebase_root\"\n+\tthen\n+\t\tmkdir \"$rewritten\" &&\n+\t\tfor c in $(git merge-base --all $orig_head $upstream)\n+\t\tdo\n+\t\t\techo $onto > \"$rewritten\"/$c ||\n+\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\t\tdone\n+\telse\n+\t\tmkdir \"$rewritten\" &&\n+\t\techo $onto > \"$rewritten\"/root ||\n+\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\tfi\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tformat=$(git config --get rebase.instructionFormat)\n+\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n+\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n+\t\t--reverse --left-right --topo-order \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n+\t\tsed -n \"s/^>//p\" |\n+\twhile read -r sha1 rest\n+\tdo\n+\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n+\t\tthen\n+\t\t\tcomment_out=\"$comment_char \"\n+\t\telse\n+\t\t\tcomment_out=\n+\t\tfi\n+\n+\t\tif test -z \"$rebase_root\"\n+\t\tthen\n+\t\t\tpreserve=t\n+\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n+\t\t\tdo\n+\t\t\t\tif test -f \"$rewritten\"/$p\n+\t\t\t\tthen\n+\t\t\t\t\tpreserve=f\n+\t\t\t\tfi\n+\t\t\tdone\n+\t\telse\n+\t\t\tpreserve=f\n+\t\tfi\n+\t\tif test f = \"$preserve\"\n+\t\tthen\n+\t\t\ttouch \"$rewritten\"/$sha1\n+\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n+\t\tfi\n+\tdone\n+\n+\t# Watch for commits that been dropped by --cherry-pick\n+\tmkdir \"$dropped\"\n+\t# Save all non-cherry-picked changes\n+\tgit rev-list $revisions --left-right --cherry-pick | \\\n+\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n+\t# Now all commits and note which ones are missing in\n+\t# not-cherry-picks and hence being dropped\n+\tgit rev-list $revisions |\n+\twhile read rev\n+\tdo\n+\t\tif test -f \"$rewritten\"/$rev &&\n+\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n+\t\tthen\n+\t\t\t# Use -f2 because if rev-list is telling us this commit is\n+\t\t\t# not worthwhile, we don't want to track its multiple heads,\n+\t\t\t# just the history of its first-parent for others that will\n+\t\t\t# be rebasing on top of it\n+\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n+\t\t\tsha1=$(git rev-list -1 $rev)\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n+\t\t\trm \"$rewritten\"/$rev\n+\t\tfi\n+\tdone\n+\n+\tcomplete_action\n+}\n-- \n2.16.1\n\n"},{"id":"348303","messageId":"20180522133110.32723-3-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T13:31:08Z","receivedAt":"2018-05-22T13:31:50Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This removes the code coming from git-rebase--interactive.sh that is not needed\nby preserve-merges.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--preserve-merges.sh | 63 +++---------------------------------------\n 1 file changed, 4 insertions(+), 59 deletions(-)\n\ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nindex 9947e6265..7bbbb2438 100644\n--- a/git-rebase--preserve-merges.sh\n+++ b/git-rebase--preserve-merges.sh\n@@ -1,12 +1,8 @@\n-# This shell script fragment is sourced by git-rebase to implement\n-# its interactive mode.  \"git rebase --interactive\" makes it easy\n-# to fix up commits in the middle of a series and rearrange commits.\n+# This shell script fragment is sourced by git-rebase to implement its\n+# preserve-merges mode.\n #\n # Copyright (c) 2006 Johannes E. Schindelin\n #\n-# The original idea comes from Eric W. Biederman, in\n-# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n-#\n # The file containing rebase commands, comments, and empty lines.\n # This file is created by \"git rebase -i\" then edited by the user.  As\n # the lines are processed, they are removed from the front of this\n@@ -281,17 +277,7 @@ pick_one () {\n \t\tempty_args=\"--allow-empty\"\n \tfi\n \n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n+\tpick_one_preserving_merges \"$@\"\n }\n \n pick_one_preserving_merges () {\n@@ -755,11 +741,6 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\t# do we have anything to commit?\n \t\tif git diff-index --cached --quiet HEAD --\n \t\tthen\n@@ -818,12 +799,6 @@ first and then run 'git rebase --continue' again.\")\"\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\tdo_rest\n \t\treturn 0\n \t\t;;\n@@ -936,41 +911,11 @@ EOF\n \t}\n \n \texpand_todo_ids\n-\n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n-\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n-\tdie \"Could not skip unnecessary pick commands\"\n-\n \tcheckout_onto\n-\tif test -z \"$rebase_root\" && test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n \tdo_rest\n }\n \n-git_rebase__interactive () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n-\tdie \"$(gettext \"Could not generate todo list\")\"\n-\n-\tcomplete_action\n-}\n-\n-git_rebase__interactive__preserve_merges () {\n+git_rebase__preserve_merges () {\n \tinitiate_action \"$action\"\n \tret=$?\n \tif test $ret = 0; then\n-- \n2.16.1\n\n"},{"id":"348304","messageId":"20180522133110.32723-4-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH 3/4] rebase: use the new git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T13:31:09Z","receivedAt":"2018-05-22T13:31:56Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Creates a new type of rebase, \"preserve-merges\", used when rebase is called with\n-p.\n\nBefore that, the type for preserve-merges was \"interactive\", and some places of\nthis script compared $type to \"interactive\". Instead, the code now checks if\n$interactive_rebase is empty or not, as it is set to \"explicit\" when calling an\ninteractive rebase (and, possibly, one of its submodes), and \"implied\" when\ncalling one of its submodes (eg. preserve-merges) *without* interactive rebase.\n\nIt also detects the presence of the directory \"$merge_dir\"/rewritten left by the\npreserve-merges script when calling rebase --continue, --skip, etc., and, if it\nexists, sets the rebase mode to preserve-merges. In this case,\ninteractive_rebase is set to \"explicit\", as \"implied\" would break some tests.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase.sh | 32 +++++++++++++++++++++++++-------\n 1 file changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 40be59ecc..19bdebb48 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -207,7 +207,14 @@ run_specific_rebase () {\n \t\tautosquash=\n \tfi\n \t. git-rebase--$type\n-\tgit_rebase__$type${preserve_merges:+__preserve_merges}\n+\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\tgit_rebase__$type\n+\telse\n+\t\tgit_rebase__preserve_merges\n+\tfi\n+\n \tret=$?\n \tif test $ret -eq 0\n \tthen\n@@ -239,7 +246,12 @@ then\n \tstate_dir=\"$apply_dir\"\n elif test -d \"$merge_dir\"\n then\n-\tif test -f \"$merge_dir\"/interactive\n+\tif test -d \"$merge_dir\"/rewritten\n+\tthen\n+\t\ttype=preserve-merges\n+\t\tinteractive_rebase=explicit\n+\t\tpreserve_merges=t\n+\telif test -f \"$merge_dir\"/interactive\n \tthen\n \t\ttype=interactive\n \t\tinteractive_rebase=explicit\n@@ -402,14 +414,14 @@ if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"$(gettext \"No rebase in progress?\")\"\n \t# Only interactive rebase uses detailed reflog messages\n-\tif test \"$type\" = interactive && test \"$GIT_REFLOG_ACTION\" = rebase\n+\tif test -n \"$interactive_rebase\" && test \"$GIT_REFLOG_ACTION\" = rebase\n \tthen\n \t\tGIT_REFLOG_ACTION=\"rebase -i ($action)\"\n \t\texport GIT_REFLOG_ACTION\n \tfi\n fi\n \n-if test \"$action\" = \"edit-todo\" && test \"$type\" != \"interactive\"\n+if test \"$action\" = \"edit-todo\" && test -z \"$interactive_rebase\"\n then\n \tdie \"$(gettext \"The --edit-todo action can only be used during interactive rebase.\")\"\n fi\n@@ -487,7 +499,13 @@ fi\n \n if test -n \"$interactive_rebase\"\n then\n-\ttype=interactive\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\ttype=interactive\n+\telse\n+\t\ttype=preserve-merges\n+\tfi\n+\n \tstate_dir=\"$merge_dir\"\n elif test -n \"$do_merge\"\n then\n@@ -647,7 +665,7 @@ require_clean_work_tree \"rebase\" \"$(gettext \"Please commit or stash them.\")\"\n # but this should be done only when upstream and onto are the same\n # and if this is not an interactive rebase.\n mb=$(git merge-base \"$onto\" \"$orig_head\")\n-if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n+if test -z \"$interactive_rebase\" && test \"$upstream\" = \"$onto\" &&\n \ttest \"$mb\" = \"$onto\" && test -z \"$restrict_revision\" &&\n \t# linear history?\n \t! (git rev-list --parents \"$onto\"..\"$orig_head\" | sane_grep \" .* \") > /dev/null\n@@ -691,7 +709,7 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n-test \"$type\" = interactive && run_specific_rebase\n+test -n \"$interactive_rebase\" && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"$(gettext \"First, rewinding head to replay your work on top of it...\")\"\n-- \n2.16.1\n\n"},{"id":"348305","messageId":"20180522133110.32723-5-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH 4/4] rebase: remove -p code from git-rebase--interactive.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T13:31:10Z","receivedAt":"2018-05-22T13:31:57Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"All the code specific to preserve-merges was moved to\ngit-rebase--preserve-merges.sh, and so it’s useless to keep it here.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--interactive.sh | 708 +--------------------------------------------\n 1 file changed, 8 insertions(+), 700 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2f4941d0f..657d32773 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -105,15 +105,6 @@ case \"$comment_char\" in\n \t;;\n esac\n \n-warn () {\n-\tprintf '%s\\n' \"$*\" >&2\n-}\n-\n-# Output the commit message for the specified commit.\n-commit_message () {\n-\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n-}\n-\n orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n@@ -142,16 +133,6 @@ mark_action_done () {\n \tfi\n }\n \n-# Put the last action marked done at the beginning of the todo list\n-# again. If there has not been an action marked done yet, leave the list of\n-# items on the todo list unchanged.\n-reschedule_last_action () {\n-\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n-\tsed -e \\$d <\"$done\" >\"$done\".new\n-\tmv -f \"$todo\".new \"$todo\"\n-\tmv -f \"$done\".new \"$done\"\n-}\n-\n append_todo_help () {\n \tgettext \"\n Commands:\n@@ -184,50 +165,6 @@ If you remove a line here THAT COMMIT WILL BE LOST.\n \tfi\n }\n \n-make_patch () {\n-\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n-\tcase \"$sha1_and_parents\" in\n-\t?*' '?*' '?*)\n-\t\tgit diff --cc $sha1_and_parents\n-\t\t;;\n-\t?*' '?*)\n-\t\tgit diff-tree -p \"$1^!\"\n-\t\t;;\n-\t*)\n-\t\techo \"Root commit\"\n-\t\t;;\n-\tesac > \"$state_dir\"/patch\n-\ttest -f \"$msg\" ||\n-\t\tcommit_message \"$1\" > \"$msg\"\n-\ttest -f \"$author_script\" ||\n-\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n-}\n-\n-die_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch \"$1\"\n-\tdie \"$2\"\n-}\n-\n-exit_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch $1\n-\tgit rev-parse --verify HEAD > \"$amend\"\n-\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\twarn \"$(eval_gettext \"\\\n-You can amend the commit now, with\n-\n-\tgit commit --amend \\$gpg_sign_opt_quoted\n-\n-Once you are satisfied with your changes, run\n-\n-\tgit rebase --continue\")\"\n-\twarn\n-\texit $2\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -238,30 +175,6 @@ has_action () {\n \ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n }\n \n-is_empty_commit() {\n-\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n-\t\tsha1=$1\n-\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n-\t}\n-\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n-\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n-\ttest \"$tree\" = \"$ptree\"\n-}\n-\n-is_merge_commit()\n-{\n-\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n-}\n-\n-# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n-# GIT_AUTHOR_DATE exported from the current environment.\n-do_with_author () {\n-\t(\n-\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n-\t\t\"$@\"\n-\t)\n-}\n-\n git_sequence_editor () {\n \tif test -z \"$GIT_SEQUENCE_EDITOR\"\n \tthen\n@@ -275,455 +188,6 @@ git_sequence_editor () {\n \teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n }\n \n-pick_one () {\n-\tff=--ff\n-\n-\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n-\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n-\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n-\n-\tif is_empty_commit \"$sha1\"\n-\tthen\n-\t\tempty_args=\"--allow-empty\"\n-\tfi\n-\n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n-}\n-\n-pick_one_preserving_merges () {\n-\tfast_forward=t\n-\tcase \"$1\" in\n-\t-n)\n-\t\tfast_forward=f\n-\t\tsha1=$2\n-\t\t;;\n-\t*)\n-\t\tsha1=$1\n-\t\t;;\n-\tesac\n-\tsha1=$(git rev-parse $sha1)\n-\n-\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n-\tthen\n-\t\twhile read current_commit\n-\t\tdo\n-\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n-\t\tdone <\"$state_dir\"/current-commit\n-\t\trm \"$state_dir\"/current-commit ||\n-\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n-\tfi\n-\n-\techo $sha1 >> \"$state_dir\"/current-commit\n-\n-\t# rewrite parents; if none were rewritten, we can fast-forward.\n-\tnew_parents=\n-\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n-\tif test \"$pend\" = \" \"\n-\tthen\n-\t\tpend=\" root\"\n-\tfi\n-\twhile [ \"$pend\" != \"\" ]\n-\tdo\n-\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n-\t\tpend=\"${pend# $p}\"\n-\n-\t\tif test -f \"$rewritten\"/$p\n-\t\tthen\n-\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n-\n-\t\t\t# If the todo reordered commits, and our parent is marked for\n-\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n-\t\t\t# drop it on top of the current HEAD\n-\t\t\tif test -z \"$new_p\"\n-\t\t\tthen\n-\t\t\t\tnew_p=$(git rev-parse HEAD)\n-\t\t\tfi\n-\n-\t\t\ttest $p != $new_p && fast_forward=f\n-\t\t\tcase \"$new_parents\" in\n-\t\t\t*$new_p*)\n-\t\t\t\t;; # do nothing; that parent is already there\n-\t\t\t*)\n-\t\t\t\tnew_parents=\"$new_parents $new_p\"\n-\t\t\t\t;;\n-\t\t\tesac\n-\t\telse\n-\t\t\tif test -f \"$dropped\"/$p\n-\t\t\tthen\n-\t\t\t\tfast_forward=f\n-\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n-\t\t\t\ttest -z \"$replacement\" && replacement=root\n-\t\t\t\tpend=\" $replacement$pend\"\n-\t\t\telse\n-\t\t\t\tnew_parents=\"$new_parents $p\"\n-\t\t\tfi\n-\t\tfi\n-\tdone\n-\tcase $fast_forward in\n-\tt)\n-\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n-\t\toutput git reset --hard $sha1 ||\n-\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n-\t\t;;\n-\tf)\n-\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\n-\t\tif [ \"$1\" != \"-n\" ]\n-\t\tthen\n-\t\t\t# detach HEAD to current parent\n-\t\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n-\t\tfi\n-\n-\t\tcase \"$new_parents\" in\n-\t\t' '*' '*)\n-\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n-\n-\t\t\t# redo merge\n-\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n-\t\t\teval \"$author_script_content\"\n-\t\t\tmsg_content=\"$(commit_message $sha1)\"\n-\t\t\t# No point in merging the first parent, that's HEAD\n-\t\t\tnew_parents=${new_parents# $first_parent}\n-\t\t\tmerge_args=\"--no-log --no-ff\"\n-\t\t\tif ! do_with_author output eval \\\n-\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n-\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n-\t\t\t\t\"$strategy_args\" \\\n-\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n-\t\t\t\t\"$new_parents\"\n-\t\t\tthen\n-\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n-\t\t\tfi\n-\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n-\t\t\t\t$allow_empty_message \\\n-\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t\"$strategy_args\" \"$@\" ||\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n-\t\t\t;;\n-\t\tesac\n-\t\t;;\n-\tesac\n-}\n-\n-this_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"This is the commit message #\\${n}:\"\n-}\n-\n-skip_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"The commit message #\\${n} will be skipped:\"\n-}\n-\n-update_squash_messages () {\n-\tif test -f \"$squash_msg\"; then\n-\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n-\t\tcount=$(($(sed -n \\\n-\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n-\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n-\t\t\t\t\"This is a combination of \\$count commit.\" \\\n-\t\t\t\t\"This is a combination of \\$count commits.\" \\\n-\t\t\t\t$count)\"\n-\t\t\tsed -e 1d -e '2,/^./{\n-\t\t\t\t/^$/d\n-\t\t\t}' <\"$squash_msg\".bak\n-\t\t} >\"$squash_msg\"\n-\telse\n-\t\tcommit_message HEAD >\"$fixup_msg\" ||\n-\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n-\t\tcount=2\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n-\t\t\techo\n-\t\t\tcat \"$fixup_msg\"\n-\t\t} >\"$squash_msg\"\n-\tfi\n-\tcase $1 in\n-\tsquash)\n-\t\trm -f \"$fixup_msg\"\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n-\t\techo\n-\t\tcommit_message $2\n-\t\t;;\n-\tfixup)\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n-\t\techo\n-\t\t# Change the space after the comment character to TAB:\n-\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n-\t\t;;\n-\tesac >>\"$squash_msg\"\n-}\n-\n-peek_next_command () {\n-\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n-}\n-\n-# A squash/fixup has failed.  Prepare the long version of the squash\n-# commit message, then die_with_patch.  This code path requires the\n-# user to edit the combined commit message for all commits that have\n-# been squashed/fixedup so far.  So also erase the old squash\n-# messages, effectively causing the combined commit to be used as the\n-# new basis for any further squash/fixups.  Args: sha1 rest\n-die_failed_squash() {\n-\tsha1=$1\n-\trest=$2\n-\tmv \"$squash_msg\" \"$msg\" || exit\n-\trm -f \"$fixup_msg\"\n-\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n-\twarn\n-\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tdie_with_patch $sha1 \"\"\n-}\n-\n-flush_rewritten_pending() {\n-\ttest -s \"$rewritten_pending\" || return\n-\tnewsha1=\"$(git rev-parse HEAD^0)\"\n-\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n-\trm -f \"$rewritten_pending\"\n-}\n-\n-record_in_rewritten() {\n-\toldsha1=\"$(git rev-parse $1)\"\n-\techo \"$oldsha1\" >> \"$rewritten_pending\"\n-\n-\tcase \"$(peek_next_command)\" in\n-\tsquash|s|fixup|f)\n-\t\t;;\n-\t*)\n-\t\tflush_rewritten_pending\n-\t\t;;\n-\tesac\n-}\n-\n-do_pick () {\n-\tsha1=$1\n-\trest=$2\n-\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n-\tthen\n-\t\t# Set the correct commit message and author info on the\n-\t\t# sentinel root before cherry-picking the original changes\n-\t\t# without committing (-n).  Finally, update the sentinel again\n-\t\t# to include these changes.  If the cherry-pick results in a\n-\t\t# conflict, this means our behaviour is similar to a standard\n-\t\t# failed cherry-pick during rebase, with a dirty index to\n-\t\t# resolve before manually running git commit --amend then git\n-\t\t# rebase --continue.\n-\t\tgit commit --allow-empty --allow-empty-message --amend \\\n-\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n-\t\t\tpick_one -n $sha1 &&\n-\t\t\tgit commit --allow-empty --allow-empty-message \\\n-\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n-\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n-\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\telse\n-\t\tpick_one $sha1 ||\n-\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tfi\n-}\n-\n-do_next () {\n-\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n-\tread -r command sha1 rest < \"$todo\"\n-\tcase \"$command\" in\n-\t\"$comment_char\"*|''|noop|drop|d)\n-\t\tmark_action_done\n-\t\t;;\n-\t\"$cr\")\n-\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n-\t\tmark_action_done\n-\t\t;;\n-\tpick|p)\n-\t\tcomment_for_reflog pick\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\treword|r)\n-\t\tcomment_for_reflog reword\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n-\t\t\t$allow_empty_message || {\n-\t\t\twarn \"$(eval_gettext \"\\\n-Could not amend commit after successfully picking \\$sha1... \\$rest\n-This is most likely due to an empty commit message, or the pre-commit hook\n-failed. If the pre-commit hook failed, you may need to resolve the issue before\n-you are able to reword the commit.\")\"\n-\t\t\texit_with_patch $sha1 1\n-\t\t}\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tedit|e)\n-\t\tcomment_for_reflog edit\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n-\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n-\t\texit_with_patch $sha1 0\n-\t\t;;\n-\tsquash|s|fixup|f)\n-\t\tcase \"$command\" in\n-\t\tsquash|s)\n-\t\t\tsquash_style=squash\n-\t\t\t;;\n-\t\tfixup|f)\n-\t\t\tsquash_style=fixup\n-\t\t\t;;\n-\t\tesac\n-\t\tcomment_for_reflog $squash_style\n-\n-\t\ttest -f \"$done\" && has_action \"$done\" ||\n-\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n-\n-\t\tmark_action_done\n-\t\tupdate_squash_messages $squash_style $sha1\n-\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n-\t\techo \"$author_script_content\" > \"$author_script\"\n-\t\teval \"$author_script_content\"\n-\t\tif ! pick_one -n $sha1\n-\t\tthen\n-\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n-\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\tfi\n-\t\tcase \"$(peek_next_command)\" in\n-\t\tsquash|s|fixup|f)\n-\t\t\t# This is an intermediate commit; its message will only be\n-\t\t\t# used in case of trouble.  So use the long version:\n-\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n-\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\t# This is the final command of this squash/fixup group\n-\t\t\tif test -f \"$fixup_msg\"\n-\t\t\tthen\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\telse\n-\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n-\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\tfi\n-\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n-\t\t\t;;\n-\t\tesac\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tx|\"exec\")\n-\t\tread -r command rest < \"$todo\"\n-\t\tmark_action_done\n-\t\teval_gettextln \"Executing: \\$rest\"\n-\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n-\t\tstatus=$?\n-\t\t# Run in subshell because require_clean_work_tree can die.\n-\t\tdirty=f\n-\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n-\t\tif test \"$status\" -ne 0\n-\t\tthen\n-\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n-\t\t\ttest \"$dirty\" = f ||\n-\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n-\n-\t\t\twarn \"$(gettext \"\\\n-You can fix the problem, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\tif test $status -eq 127\t\t# command not found\n-\t\t\tthen\n-\t\t\t\tstatus=1\n-\t\t\tfi\n-\t\t\texit \"$status\"\n-\t\telif test \"$dirty\" = t\n-\t\tthen\n-\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n-\t\t\twarn \"$(eval_gettext \"\\\n-Execution succeeded: \\$rest\n-but left changes to the index and/or the working tree\n-Commit or stash your changes, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\texit 1\n-\t\tfi\n-\t\t;;\n-\t*)\n-\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n-\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n-\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n-\t\tthen\n-\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n-\t\telse\n-\t\t\tdie \"$fixtodo\"\n-\t\tfi\n-\t\t;;\n-\tesac\n-\ttest -s \"$todo\" && return\n-\n-\tcomment_for_reflog finish &&\n-\tnewhead=$(git rev-parse HEAD) &&\n-\tcase $head_name in\n-\trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n-\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n-\t\tgit symbolic-ref \\\n-\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n-\t\t  HEAD $head_name\n-\t\t;;\n-\tesac && {\n-\t\ttest ! -f \"$state_dir\"/verbose ||\n-\t\t\tgit diff-tree --stat $orig_head..HEAD\n-\t} &&\n-\t{\n-\t\ttest -s \"$rewritten_list\" &&\n-\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n-\t\ttrue # we don't care if this copying failed\n-\t} &&\n-\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n-\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n-\t\t\"$hook\" rebase < \"$rewritten_list\"\n-\t\ttrue # we don't care if this hook failed\n-\tfi &&\n-\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n-\n-\treturn 1 # not failure; just to break the do_rest loop\n-}\n-\n-# can only return 0, when the infinite loop breaks\n-do_rest () {\n-\twhile :\n-\tdo\n-\t\tdo_next || break\n-\tdone\n-}\n-\n expand_todo_ids() {\n \tgit rebase--helper --expand-ids\n }\n@@ -761,77 +225,13 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\t# do we have anything to commit?\n-\t\tif git diff-index --cached --quiet HEAD --\n-\t\tthen\n-\t\t\t# Nothing to commit -- skip this commit\n-\n-\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n-\t\telse\n-\t\t\tif ! test -f \"$author_script\"\n-\t\t\tthen\n-\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\t\t\t\tdie \"$(eval_gettext \"\\\n-You have staged changes in your working tree.\n-If these changes are meant to be\n-squashed into the previous commit, run:\n-\n-  git commit --amend \\$gpg_sign_opt_quoted\n-\n-If they are meant to go into a new commit, run:\n-\n-  git commit \\$gpg_sign_opt_quoted\n-\n-In both cases, once you're done, continue with:\n-\n-  git rebase --continue\n-\")\"\n-\t\t\tfi\n-\t\t\t. \"$author_script\" ||\n-\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n-\t\t\tif test -f \"$amend\"\n-\t\t\tthen\n-\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n-\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n-\t\t\t\tdie \"$(gettext \"\\\n-You have uncommitted changes in your working tree. Please commit them\n-first and then run 'git rebase --continue' again.\")\"\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\telse\n-\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\tfi\n-\t\tfi\n-\n-\t\tif test -r \"$state_dir\"/stopped-sha\n-\t\tthen\n-\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n-\t\tfi\n-\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tedit-todo)\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n@@ -945,18 +345,14 @@ EOF\n \n \texpand_todo_ids\n \n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\ttest -n \"$force_rebase\" ||\n \tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n \tdie \"Could not skip unnecessary pick commands\"\n \n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n-\tdo_rest\n+\trequire_clean_work_tree \"rebase\"\n+\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t     --continue\n }\n \n git_rebase__interactive () {\n@@ -979,91 +375,3 @@ git_rebase__interactive () {\n \n \tcomplete_action\n }\n-\n-git_rebase__interactive__preserve_merges () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tif test -z \"$rebase_root\"\n-\tthen\n-\t\tmkdir \"$rewritten\" &&\n-\t\tfor c in $(git merge-base --all $orig_head $upstream)\n-\t\tdo\n-\t\t\techo $onto > \"$rewritten\"/$c ||\n-\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\t\tdone\n-\telse\n-\t\tmkdir \"$rewritten\" &&\n-\t\techo $onto > \"$rewritten\"/root ||\n-\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\tfi\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tformat=$(git config --get rebase.instructionFormat)\n-\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n-\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n-\t\t--reverse --left-right --topo-order \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n-\t\tsed -n \"s/^>//p\" |\n-\twhile read -r sha1 rest\n-\tdo\n-\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n-\t\tthen\n-\t\t\tcomment_out=\"$comment_char \"\n-\t\telse\n-\t\t\tcomment_out=\n-\t\tfi\n-\n-\t\tif test -z \"$rebase_root\"\n-\t\tthen\n-\t\t\tpreserve=t\n-\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n-\t\t\tdo\n-\t\t\t\tif test -f \"$rewritten\"/$p\n-\t\t\t\tthen\n-\t\t\t\t\tpreserve=f\n-\t\t\t\tfi\n-\t\t\tdone\n-\t\telse\n-\t\t\tpreserve=f\n-\t\tfi\n-\t\tif test f = \"$preserve\"\n-\t\tthen\n-\t\t\ttouch \"$rewritten\"/$sha1\n-\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n-\t\tfi\n-\tdone\n-\n-\t# Watch for commits that been dropped by --cherry-pick\n-\tmkdir \"$dropped\"\n-\t# Save all non-cherry-picked changes\n-\tgit rev-list $revisions --left-right --cherry-pick | \\\n-\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n-\t# Now all commits and note which ones are missing in\n-\t# not-cherry-picks and hence being dropped\n-\tgit rev-list $revisions |\n-\twhile read rev\n-\tdo\n-\t\tif test -f \"$rewritten\"/$rev &&\n-\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n-\t\tthen\n-\t\t\t# Use -f2 because if rev-list is telling us this commit is\n-\t\t\t# not worthwhile, we don't want to track its multiple heads,\n-\t\t\t# just the history of its first-parent for others that will\n-\t\t\t# be rebasing on top of it\n-\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n-\t\t\tsha1=$(git rev-list -1 $rev)\n-\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n-\t\t\trm \"$rewritten\"/$rev\n-\t\tfi\n-\tdone\n-\n-\tcomplete_action\n-}\n-- \n2.16.1\n\n"},{"id":"348316","messageId":"CAGZ79kaTPu=z_6oJk__meuyhUt-pU_LtOJ90rPTQcC=YvhnOnw@mail.gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-2-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-22T18:26:13Z","receivedAt":"2018-05-22T18:26:19Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 22, 2018 at 6:31 AM, Alban Gruin <alban.gruin@gmail.com> wrote:\n> This duplicates git-rebase--interactive.sh to\n> git-rebase--preserve-merges.sh. This is done to split -p from -i. No\n> modifications are made to this file here, but any code that is not used by -p\n> will be stripped in the next commit.\n>\n> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>\n\nSo how would I best review this?\n\nI applied the patches locally[1], and ran git-ls-tree on this commit\nhoping to find the same blob id for git-rebase--interactive.sh as for\ngit-rebase--preserve-merges.sh; however I did not.\n\nSo I diffed them and had the diff below[2], which looks like that has parts\nof Johannes recent series?\n\nThanks,\nStefan\n\n[1] After applying I pushed it to\nhttps://github.com/stefanbeller/git/tree/alban_split_off_-p\nand this patch is commit 9f64342ea1b64d43e4675b5f202174c9e0f77dbf\n\n[2] $ git diff 9f64342ea1b64d43e4675b5f202174c9e0f77dbf:git-rebase--preserve-merges.sh\n\\\n    9f64342ea1b64d43e4675b5f202174c9e0f77dbf:git-rebase--interactive.sh\ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--interactive.sh\nindex 9947e6265fe..2f4941d0fc9 100644\n--- a/git-rebase--preserve-merges.sh\n+++ b/git-rebase--interactive.sh\n@@ -155,13 +155,19 @@ reschedule_last_action () {\n append_todo_help () {\n        gettext \"\n Commands:\n-p, pick = use commit\n-r, reword = use commit, but edit the commit message\n-e, edit = use commit, but stop for amending\n-s, squash = use commit, but meld into previous commit\n-f, fixup = like \\\"squash\\\", but discard this commit's log message\n-x, exec = run command (the rest of the line) using shell\n-d, drop = remove commit\n+p, pick <commit> = use commit\n+r, reword <commit> = use commit, but edit the commit message\n+e, edit <commit> = use commit, but stop for amending\n+s, squash <commit> = use commit, but meld into previous commit\n+f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n+x, exec <commit> = run command (the rest of the line) using shell\n+d, drop <commit> = remove commit\n+l, label <label> = label current HEAD with a name\n+t, reset <label> = reset HEAD to a label\n+m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n+.       create a merge commit using the original merge commit's\n+.       message (or the oneline, if no original merge commit was\n+.       specified). Use -c <commit> to reword the commit message.\n\n These lines can be re-ordered; they are executed from top to bottom.\n \" | git stripspace --comment-lines >>\"$todo\"\n@@ -888,6 +894,8 @@ init_revisions_and_shortrevisions () {\n        else\n                revisions=$onto...$orig_head\n                shortrevisions=$shorthead\n+               test -z \"$squash_onto\" ||\n+               echo \"$squash_onto\" >\"$state_dir\"/squash-onto\n        fi\n }\n\n@@ -942,7 +950,7 @@ EOF\n        die \"Could not skip unnecessary pick commands\"\n\n        checkout_onto\n-       if test -z \"$rebase_root\" && test ! -d \"$rewritten\"\n+       if test ! -d \"$rewritten\"\n        then\n                require_clean_work_tree \"rebase\"\n                exec git rebase--helper ${force_rebase:+--no-ff}\n$allow_empty_message \\\n@@ -964,6 +972,8 @@ git_rebase__interactive () {\n        init_revisions_and_shortrevisions\n\n        git rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n+               ${rebase_merges:+--rebase-merges} \\\n+               ${rebase_cousins:+--rebase-cousins} \\\n                $revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n        die \"$(gettext \"Could not generate todo list\")\"\n"},{"id":"348317","messageId":"CAGZ79kbiCE1CDMYN+aV8s9Ev2joCZJqroN3wBkoRvZZLHqOFww@mail.gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-1-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH 0/4] rebase: split rebase -p from rebase -i","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-05-22T18:29:09Z","receivedAt":"2018-05-22T18:29:14Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, May 22, 2018 at 6:31 AM, Alban Gruin <alban.gruin@gmail.com> wrote:\n> This splits the `rebase --preserve-merges` functionnality from\n> git-rebase--interactive.sh. This is part of the effort to depreciate\n> preserve-merges. The new script, git-rebase--preserve-merges.sh, should be left\n> to bitrot. All the dead code left by the duplication of\n> git-rebase--interactive.sh is also removed.\n\n... and I thought the original motivation was getting the rest of rebase\ninto a shape that rewriting it is easier, the potential bit rot of\n--preserve-merges\nis rather a side effect, but not the main goal.\n\nI commented on patch 1, as I don't quite understand the changes,\nthe other patches look good to me.\n\nThanks,\nStefan\n"},{"id":"348326","messageId":"a3d0d6f6-c6c8-ad70-4e1a-7804dbfa1b35@gmail.com","threadId":"48547","inReplyTo":"CAGZ79kaTPu=z_6oJk__meuyhUt-pU_LtOJ90rPTQcC=YvhnOnw@mail.gmail.com","subject":"Re: [GSoC][PATCH 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T19:15:21Z","receivedAt":"2018-05-22T19:15:32Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Stefan,\n\nLe 22/05/2018 à 20:26, Stefan Beller a écrit :\n> On Tue, May 22, 2018 at 6:31 AM, Alban Gruin <alban.gruin@gmail.com> wrote:\n>> This duplicates git-rebase--interactive.sh to\n>> git-rebase--preserve-merges.sh. This is done to split -p from -i. No\n>> modifications are made to this file here, but any code that is not used by -p\n>> will be stripped in the next commit.\n>>\n>> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>\n> \n> So how would I best review this?\n> \n> I applied the patches locally[1], and ran git-ls-tree on this commit\n> hoping to find the same blob id for git-rebase--interactive.sh as for\n> git-rebase--preserve-merges.sh; however I did not.\n> \n> So I diffed them and had the diff below[2], which looks like that has parts\n> of Johannes recent series?\n> \n\nThanks for the heads-up.\n\nI started to work on that patch set on the master branch of git.git, and\nI forgot to update git-rebase--preserve-merges.sh after rebasing on\nJohannes’ branch.\n\nSo I’ll reroll the patch as soon as possible.\n\n> Thanks,\n> Stefan\n> \n\n\n"},{"id":"348328","messageId":"20180522211625.23893-1-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522133110.32723-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 0/4] rebase: split rebase -p from rebase -i","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T21:16:21Z","receivedAt":"2018-05-22T21:16:37Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This splits the `rebase --preserve-merges` functionnality from\ngit-rebase--interactive.sh. All the dead code left by the duplication of\ngit-rebase--interactive.sh is also removed. This will make it easier to rewrite\nthis script in C.\n\nThis patch series is based of js/sequencer-and-root-commits.\n\nChanges since v1:\n\n - Duplicating the correct version of git-rebase--interactive.sh (thanks\n   Stefan!)\n\nAlban Gruin (4):\n  rebase: duplicate git-rebase--interactive.sh to\n    git-rebase--preserve-merges.sh\n  rebase: strip unused code in git-rebase--preserve-merges.sh\n  rebase: use the new git-rebase--preserve-merges.sh\n  rebase: remove -p code from git-rebase--interactive.sh\n\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--interactive.sh     |  708 +---------------------------\n git-rebase--preserve-merges.sh | 1012 ++++++++++++++++++++++++++++++++++++++++\n git-rebase.sh                  |   32 +-\n 5 files changed, 1048 insertions(+), 707 deletions(-)\n create mode 100644 git-rebase--preserve-merges.sh\n\n-- \n2.16.1\n\n"},{"id":"348329","messageId":"20180522211625.23893-3-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522211625.23893-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T21:16:23Z","receivedAt":"2018-05-22T21:16:44Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This removes the code coming from git-rebase--interactive.sh that is not needed\nby preserve-merges.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--preserve-merges.sh | 65 +++---------------------------------------\n 1 file changed, 4 insertions(+), 61 deletions(-)\n\ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nindex 2f4941d0f..c51c7828e 100644\n--- a/git-rebase--preserve-merges.sh\n+++ b/git-rebase--preserve-merges.sh\n@@ -1,12 +1,8 @@\n-# This shell script fragment is sourced by git-rebase to implement\n-# its interactive mode.  \"git rebase --interactive\" makes it easy\n-# to fix up commits in the middle of a series and rearrange commits.\n+# This shell script fragment is sourced by git-rebase to implement its\n+# preserve-merges mode.\n #\n # Copyright (c) 2006 Johannes E. Schindelin\n #\n-# The original idea comes from Eric W. Biederman, in\n-# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n-#\n # The file containing rebase commands, comments, and empty lines.\n # This file is created by \"git rebase -i\" then edited by the user.  As\n # the lines are processed, they are removed from the front of this\n@@ -287,17 +283,7 @@ pick_one () {\n \t\tempty_args=\"--allow-empty\"\n \tfi\n \n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n+\tpick_one_preserving_merges \"$@\"\n }\n \n pick_one_preserving_merges () {\n@@ -761,11 +747,6 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\t# do we have anything to commit?\n \t\tif git diff-index --cached --quiet HEAD --\n \t\tthen\n@@ -824,12 +805,6 @@ first and then run 'git rebase --continue' again.\")\"\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\tdo_rest\n \t\treturn 0\n \t\t;;\n@@ -944,43 +919,11 @@ EOF\n \t}\n \n \texpand_todo_ids\n-\n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n-\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n-\tdie \"Could not skip unnecessary pick commands\"\n-\n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n \tdo_rest\n }\n \n-git_rebase__interactive () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n-\t\t${rebase_merges:+--rebase-merges} \\\n-\t\t${rebase_cousins:+--rebase-cousins} \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n-\tdie \"$(gettext \"Could not generate todo list\")\"\n-\n-\tcomplete_action\n-}\n-\n-git_rebase__interactive__preserve_merges () {\n+git_rebase__preserve_merges () {\n \tinitiate_action \"$action\"\n \tret=$?\n \tif test $ret = 0; then\n-- \n2.16.1\n\n"},{"id":"348330","messageId":"20180522211625.23893-4-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522211625.23893-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 3/4] rebase: use the new git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T21:16:24Z","receivedAt":"2018-05-22T21:16:46Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Creates a new type of rebase, \"preserve-merges\", used when rebase is called with\n-p.\n\nBefore that, the type for preserve-merges was \"interactive\", and some places of\nthis script compared $type to \"interactive\". Instead, the code now checks if\n$interactive_rebase is empty or not, as it is set to \"explicit\" when calling an\ninteractive rebase (and, possibly, one of its submodes), and \"implied\" when\ncalling one of its submodes (eg. preserve-merges) *without* interactive rebase.\n\nIt also detects the presence of the directory \"$merge_dir\"/rewritten left by the\npreserve-merges script when calling rebase --continue, --skip, etc., and, if it\nexists, sets the rebase mode to preserve-merges. In this case,\ninteractive_rebase is set to \"explicit\", as \"implied\" would break some tests.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase.sh | 32 +++++++++++++++++++++++++-------\n 1 file changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 40be59ecc..19bdebb48 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -207,7 +207,14 @@ run_specific_rebase () {\n \t\tautosquash=\n \tfi\n \t. git-rebase--$type\n-\tgit_rebase__$type${preserve_merges:+__preserve_merges}\n+\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\tgit_rebase__$type\n+\telse\n+\t\tgit_rebase__preserve_merges\n+\tfi\n+\n \tret=$?\n \tif test $ret -eq 0\n \tthen\n@@ -239,7 +246,12 @@ then\n \tstate_dir=\"$apply_dir\"\n elif test -d \"$merge_dir\"\n then\n-\tif test -f \"$merge_dir\"/interactive\n+\tif test -d \"$merge_dir\"/rewritten\n+\tthen\n+\t\ttype=preserve-merges\n+\t\tinteractive_rebase=explicit\n+\t\tpreserve_merges=t\n+\telif test -f \"$merge_dir\"/interactive\n \tthen\n \t\ttype=interactive\n \t\tinteractive_rebase=explicit\n@@ -402,14 +414,14 @@ if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"$(gettext \"No rebase in progress?\")\"\n \t# Only interactive rebase uses detailed reflog messages\n-\tif test \"$type\" = interactive && test \"$GIT_REFLOG_ACTION\" = rebase\n+\tif test -n \"$interactive_rebase\" && test \"$GIT_REFLOG_ACTION\" = rebase\n \tthen\n \t\tGIT_REFLOG_ACTION=\"rebase -i ($action)\"\n \t\texport GIT_REFLOG_ACTION\n \tfi\n fi\n \n-if test \"$action\" = \"edit-todo\" && test \"$type\" != \"interactive\"\n+if test \"$action\" = \"edit-todo\" && test -z \"$interactive_rebase\"\n then\n \tdie \"$(gettext \"The --edit-todo action can only be used during interactive rebase.\")\"\n fi\n@@ -487,7 +499,13 @@ fi\n \n if test -n \"$interactive_rebase\"\n then\n-\ttype=interactive\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\ttype=interactive\n+\telse\n+\t\ttype=preserve-merges\n+\tfi\n+\n \tstate_dir=\"$merge_dir\"\n elif test -n \"$do_merge\"\n then\n@@ -647,7 +665,7 @@ require_clean_work_tree \"rebase\" \"$(gettext \"Please commit or stash them.\")\"\n # but this should be done only when upstream and onto are the same\n # and if this is not an interactive rebase.\n mb=$(git merge-base \"$onto\" \"$orig_head\")\n-if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n+if test -z \"$interactive_rebase\" && test \"$upstream\" = \"$onto\" &&\n \ttest \"$mb\" = \"$onto\" && test -z \"$restrict_revision\" &&\n \t# linear history?\n \t! (git rev-list --parents \"$onto\"..\"$orig_head\" | sane_grep \" .* \") > /dev/null\n@@ -691,7 +709,7 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n-test \"$type\" = interactive && run_specific_rebase\n+test -n \"$interactive_rebase\" && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"$(gettext \"First, rewinding head to replay your work on top of it...\")\"\n-- \n2.16.1\n\n"},{"id":"348331","messageId":"20180522211625.23893-2-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522211625.23893-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T21:16:22Z","receivedAt":"2018-05-22T21:16:49Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This duplicates git-rebase--interactive.sh to\ngit-rebase--preserve-merges.sh. This is done to split -p from -i. No\nmodifications are made to this file here, but any code that is not used by -p\nwill be stripped in the next commit.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--preserve-merges.sh | 1069 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 1072 insertions(+)\n create mode 100644 git-rebase--preserve-merges.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 833ef3b0b..ef4925485 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -117,6 +117,7 @@\n /git-rebase--helper\n /git-rebase--interactive\n /git-rebase--merge\n+/git-rebase--preserve-merges\n /git-receive-pack\n /git-reflog\n /git-remote\ndiff --git a/Makefile b/Makefile\nindex 50da82b01..810a0d0f4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -582,6 +582,7 @@ SCRIPT_LIB += git-mergetool--lib\n SCRIPT_LIB += git-parse-remote\n SCRIPT_LIB += git-rebase--am\n SCRIPT_LIB += git-rebase--interactive\n+SCRIPT_LIB += git-rebase--preserve-merges\n SCRIPT_LIB += git-rebase--merge\n SCRIPT_LIB += git-sh-setup\n SCRIPT_LIB += git-sh-i18n\n@@ -2271,6 +2272,7 @@ LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH)\n LOCALIZED_SH += git-parse-remote.sh\n LOCALIZED_SH += git-rebase--interactive.sh\n+LOCALIZED_SH += git-rebase--preserve-merges.sh\n LOCALIZED_SH += git-sh-setup.sh\n LOCALIZED_PERL = $(SCRIPT_PERL)\n \ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nnew file mode 100644\nindex 000000000..2f4941d0f\n--- /dev/null\n+++ b/git-rebase--preserve-merges.sh\n@@ -0,0 +1,1069 @@\n+# This shell script fragment is sourced by git-rebase to implement\n+# its interactive mode.  \"git rebase --interactive\" makes it easy\n+# to fix up commits in the middle of a series and rearrange commits.\n+#\n+# Copyright (c) 2006 Johannes E. Schindelin\n+#\n+# The original idea comes from Eric W. Biederman, in\n+# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n+#\n+# The file containing rebase commands, comments, and empty lines.\n+# This file is created by \"git rebase -i\" then edited by the user.  As\n+# the lines are processed, they are removed from the front of this\n+# file and written to the tail of $done.\n+todo=\"$state_dir\"/git-rebase-todo\n+\n+# The rebase command lines that have already been processed.  A line\n+# is moved here when it is first handled, before any associated user\n+# actions.\n+done=\"$state_dir\"/done\n+\n+# The commit message that is planned to be used for any changes that\n+# need to be committed following a user interaction.\n+msg=\"$state_dir\"/message\n+\n+# The file into which is accumulated the suggested commit message for\n+# squash/fixup commands.  When the first of a series of squash/fixups\n+# is seen, the file is created and the commit message from the\n+# previous commit and from the first squash/fixup commit are written\n+# to it.  The commit message for each subsequent squash/fixup commit\n+# is appended to the file as it is processed.\n+#\n+# The first line of the file is of the form\n+#     # This is a combination of $count commits.\n+# where $count is the number of commits whose messages have been\n+# written to the file so far (including the initial \"pick\" commit).\n+# Each time that a commit message is processed, this line is read and\n+# updated.  It is deleted just before the combined commit is made.\n+squash_msg=\"$state_dir\"/message-squash\n+\n+# If the current series of squash/fixups has not yet included a squash\n+# command, then this file exists and holds the commit message of the\n+# original \"pick\" commit.  (If the series ends without a \"squash\"\n+# command, then this can be used as the commit message of the combined\n+# commit without opening the editor.)\n+fixup_msg=\"$state_dir\"/message-fixup\n+\n+# $rewritten is the name of a directory containing files for each\n+# commit that is reachable by at least one merge base of $head and\n+# $upstream. They are not necessarily rewritten, but their children\n+# might be.  This ensures that commits on merged, but otherwise\n+# unrelated side branches are left alone. (Think \"X\" in the man page's\n+# example.)\n+rewritten=\"$state_dir\"/rewritten\n+\n+dropped=\"$state_dir\"/dropped\n+\n+end=\"$state_dir\"/end\n+msgnum=\"$state_dir\"/msgnum\n+\n+# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE that will be used for the commit that is currently\n+# being rebased.\n+author_script=\"$state_dir\"/author-script\n+\n+# When an \"edit\" rebase command is being processed, the SHA1 of the\n+# commit to be edited is recorded in this file.  When \"git rebase\n+# --continue\" is executed, if there are any staged changes then they\n+# will be amended to the HEAD commit, but only provided the HEAD\n+# commit is still the commit to be edited.  When any other rebase\n+# command is processed, this file is deleted.\n+amend=\"$state_dir\"/amend\n+\n+# For the post-rewrite hook, we make a list of rewritten commits and\n+# their new sha1s.  The rewritten-pending list keeps the sha1s of\n+# commits that have been processed, but not committed yet,\n+# e.g. because they are waiting for a 'squash' command.\n+rewritten_list=\"$state_dir\"/rewritten-list\n+rewritten_pending=\"$state_dir\"/rewritten-pending\n+\n+# Work around Git for Windows' Bash whose \"read\" does not strip CRLF\n+# and leaves CR at the end instead.\n+cr=$(printf \"\\015\")\n+\n+strategy_args=${strategy:+--strategy=$strategy}\n+test -n \"$strategy_opts\" &&\n+eval '\n+\tfor strategy_opt in '\"$strategy_opts\"'\n+\tdo\n+\t\tstrategy_args=\"$strategy_args -X$(git rev-parse --sq-quote \"${strategy_opt#--}\")\"\n+\tdone\n+'\n+\n+GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n+export GIT_CHERRY_PICK_HELP\n+\n+comment_char=$(git config --get core.commentchar 2>/dev/null)\n+case \"$comment_char\" in\n+'' | auto)\n+\tcomment_char=\"#\"\n+\t;;\n+?)\n+\t;;\n+*)\n+\tcomment_char=$(echo \"$comment_char\" | cut -c1)\n+\t;;\n+esac\n+\n+warn () {\n+\tprintf '%s\\n' \"$*\" >&2\n+}\n+\n+# Output the commit message for the specified commit.\n+commit_message () {\n+\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n+}\n+\n+orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n+\n+comment_for_reflog () {\n+\tcase \"$orig_reflog_action\" in\n+\t''|rebase*)\n+\t\tGIT_REFLOG_ACTION=\"rebase -i ($1)\"\n+\t\texport GIT_REFLOG_ACTION\n+\t\t;;\n+\tesac\n+}\n+\n+last_count=\n+mark_action_done () {\n+\tsed -e 1q < \"$todo\" >> \"$done\"\n+\tsed -e 1d < \"$todo\" >> \"$todo\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tnew_count=$(( $(git stripspace --strip-comments <\"$done\" | wc -l) ))\n+\techo $new_count >\"$msgnum\"\n+\ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n+\techo $total >\"$end\"\n+\tif test \"$last_count\" != \"$new_count\"\n+\tthen\n+\t\tlast_count=$new_count\n+\t\teval_gettext \"Rebasing (\\$new_count/\\$total)\"; printf \"\\r\"\n+\t\ttest -z \"$verbose\" || echo\n+\tfi\n+}\n+\n+# Put the last action marked done at the beginning of the todo list\n+# again. If there has not been an action marked done yet, leave the list of\n+# items on the todo list unchanged.\n+reschedule_last_action () {\n+\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n+\tsed -e \\$d <\"$done\" >\"$done\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tmv -f \"$done\".new \"$done\"\n+}\n+\n+append_todo_help () {\n+\tgettext \"\n+Commands:\n+p, pick <commit> = use commit\n+r, reword <commit> = use commit, but edit the commit message\n+e, edit <commit> = use commit, but stop for amending\n+s, squash <commit> = use commit, but meld into previous commit\n+f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n+x, exec <commit> = run command (the rest of the line) using shell\n+d, drop <commit> = remove commit\n+l, label <label> = label current HEAD with a name\n+t, reset <label> = reset HEAD to a label\n+m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n+.       create a merge commit using the original merge commit's\n+.       message (or the oneline, if no original merge commit was\n+.       specified). Use -c <commit> to reword the commit message.\n+\n+These lines can be re-ordered; they are executed from top to bottom.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test $(get_missing_commit_check_level) = error\n+\tthen\n+\t\tgettext \"\n+Do not remove any line. Use 'drop' explicitly to remove a commit.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\telse\n+\t\tgettext \"\n+If you remove a line here THAT COMMIT WILL BE LOST.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\tfi\n+}\n+\n+make_patch () {\n+\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n+\tcase \"$sha1_and_parents\" in\n+\t?*' '?*' '?*)\n+\t\tgit diff --cc $sha1_and_parents\n+\t\t;;\n+\t?*' '?*)\n+\t\tgit diff-tree -p \"$1^!\"\n+\t\t;;\n+\t*)\n+\t\techo \"Root commit\"\n+\t\t;;\n+\tesac > \"$state_dir\"/patch\n+\ttest -f \"$msg\" ||\n+\t\tcommit_message \"$1\" > \"$msg\"\n+\ttest -f \"$author_script\" ||\n+\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n+}\n+\n+die_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch \"$1\"\n+\tdie \"$2\"\n+}\n+\n+exit_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch $1\n+\tgit rev-parse --verify HEAD > \"$amend\"\n+\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\twarn \"$(eval_gettext \"\\\n+You can amend the commit now, with\n+\n+\tgit commit --amend \\$gpg_sign_opt_quoted\n+\n+Once you are satisfied with your changes, run\n+\n+\tgit rebase --continue\")\"\n+\twarn\n+\texit $2\n+}\n+\n+die_abort () {\n+\tapply_autostash\n+\trm -rf \"$state_dir\"\n+\tdie \"$1\"\n+}\n+\n+has_action () {\n+\ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n+}\n+\n+is_empty_commit() {\n+\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n+\t\tsha1=$1\n+\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n+\t}\n+\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n+\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n+\ttest \"$tree\" = \"$ptree\"\n+}\n+\n+is_merge_commit()\n+{\n+\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n+}\n+\n+# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE exported from the current environment.\n+do_with_author () {\n+\t(\n+\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n+\t\t\"$@\"\n+\t)\n+}\n+\n+git_sequence_editor () {\n+\tif test -z \"$GIT_SEQUENCE_EDITOR\"\n+\tthen\n+\t\tGIT_SEQUENCE_EDITOR=\"$(git config sequence.editor)\"\n+\t\tif [ -z \"$GIT_SEQUENCE_EDITOR\" ]\n+\t\tthen\n+\t\t\tGIT_SEQUENCE_EDITOR=\"$(git var GIT_EDITOR)\" || return $?\n+\t\tfi\n+\tfi\n+\n+\teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n+}\n+\n+pick_one () {\n+\tff=--ff\n+\n+\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n+\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n+\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n+\n+\tif is_empty_commit \"$sha1\"\n+\tthen\n+\t\tempty_args=\"--allow-empty\"\n+\tfi\n+\n+\ttest -d \"$rewritten\" &&\n+\t\tpick_one_preserving_merges \"$@\" && return\n+\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n+\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n+\n+\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n+\t# previous task so this commit is not lost.\n+\tret=$?\n+\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n+\treturn $ret\n+}\n+\n+pick_one_preserving_merges () {\n+\tfast_forward=t\n+\tcase \"$1\" in\n+\t-n)\n+\t\tfast_forward=f\n+\t\tsha1=$2\n+\t\t;;\n+\t*)\n+\t\tsha1=$1\n+\t\t;;\n+\tesac\n+\tsha1=$(git rev-parse $sha1)\n+\n+\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n+\tthen\n+\t\twhile read current_commit\n+\t\tdo\n+\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n+\t\tdone <\"$state_dir\"/current-commit\n+\t\trm \"$state_dir\"/current-commit ||\n+\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n+\tfi\n+\n+\techo $sha1 >> \"$state_dir\"/current-commit\n+\n+\t# rewrite parents; if none were rewritten, we can fast-forward.\n+\tnew_parents=\n+\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n+\tif test \"$pend\" = \" \"\n+\tthen\n+\t\tpend=\" root\"\n+\tfi\n+\twhile [ \"$pend\" != \"\" ]\n+\tdo\n+\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n+\t\tpend=\"${pend# $p}\"\n+\n+\t\tif test -f \"$rewritten\"/$p\n+\t\tthen\n+\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n+\n+\t\t\t# If the todo reordered commits, and our parent is marked for\n+\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n+\t\t\t# drop it on top of the current HEAD\n+\t\t\tif test -z \"$new_p\"\n+\t\t\tthen\n+\t\t\t\tnew_p=$(git rev-parse HEAD)\n+\t\t\tfi\n+\n+\t\t\ttest $p != $new_p && fast_forward=f\n+\t\t\tcase \"$new_parents\" in\n+\t\t\t*$new_p*)\n+\t\t\t\t;; # do nothing; that parent is already there\n+\t\t\t*)\n+\t\t\t\tnew_parents=\"$new_parents $new_p\"\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\telse\n+\t\t\tif test -f \"$dropped\"/$p\n+\t\t\tthen\n+\t\t\t\tfast_forward=f\n+\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n+\t\t\t\ttest -z \"$replacement\" && replacement=root\n+\t\t\t\tpend=\" $replacement$pend\"\n+\t\t\telse\n+\t\t\t\tnew_parents=\"$new_parents $p\"\n+\t\t\tfi\n+\t\tfi\n+\tdone\n+\tcase $fast_forward in\n+\tt)\n+\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n+\t\toutput git reset --hard $sha1 ||\n+\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n+\t\t;;\n+\tf)\n+\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n+\n+\t\tif [ \"$1\" != \"-n\" ]\n+\t\tthen\n+\t\t\t# detach HEAD to current parent\n+\t\t\toutput git checkout $first_parent 2> /dev/null ||\n+\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n+\t\tfi\n+\n+\t\tcase \"$new_parents\" in\n+\t\t' '*' '*)\n+\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n+\n+\t\t\t# redo merge\n+\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n+\t\t\teval \"$author_script_content\"\n+\t\t\tmsg_content=\"$(commit_message $sha1)\"\n+\t\t\t# No point in merging the first parent, that's HEAD\n+\t\t\tnew_parents=${new_parents# $first_parent}\n+\t\t\tmerge_args=\"--no-log --no-ff\"\n+\t\t\tif ! do_with_author output eval \\\n+\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n+\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n+\t\t\t\t\"$strategy_args\" \\\n+\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n+\t\t\t\t\"$new_parents\"\n+\t\t\tthen\n+\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n+\t\t\tfi\n+\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n+\t\t\t\t$allow_empty_message \\\n+\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t\"$strategy_args\" \"$@\" ||\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n+\t\t\t;;\n+\t\tesac\n+\t\t;;\n+\tesac\n+}\n+\n+this_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"This is the commit message #\\${n}:\"\n+}\n+\n+skip_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"The commit message #\\${n} will be skipped:\"\n+}\n+\n+update_squash_messages () {\n+\tif test -f \"$squash_msg\"; then\n+\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n+\t\tcount=$(($(sed -n \\\n+\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n+\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n+\t\t\t\t\"This is a combination of \\$count commit.\" \\\n+\t\t\t\t\"This is a combination of \\$count commits.\" \\\n+\t\t\t\t$count)\"\n+\t\t\tsed -e 1d -e '2,/^./{\n+\t\t\t\t/^$/d\n+\t\t\t}' <\"$squash_msg\".bak\n+\t\t} >\"$squash_msg\"\n+\telse\n+\t\tcommit_message HEAD >\"$fixup_msg\" ||\n+\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n+\t\tcount=2\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n+\t\t\techo\n+\t\t\tcat \"$fixup_msg\"\n+\t\t} >\"$squash_msg\"\n+\tfi\n+\tcase $1 in\n+\tsquash)\n+\t\trm -f \"$fixup_msg\"\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n+\t\techo\n+\t\tcommit_message $2\n+\t\t;;\n+\tfixup)\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n+\t\techo\n+\t\t# Change the space after the comment character to TAB:\n+\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n+\t\t;;\n+\tesac >>\"$squash_msg\"\n+}\n+\n+peek_next_command () {\n+\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n+}\n+\n+# A squash/fixup has failed.  Prepare the long version of the squash\n+# commit message, then die_with_patch.  This code path requires the\n+# user to edit the combined commit message for all commits that have\n+# been squashed/fixedup so far.  So also erase the old squash\n+# messages, effectively causing the combined commit to be used as the\n+# new basis for any further squash/fixups.  Args: sha1 rest\n+die_failed_squash() {\n+\tsha1=$1\n+\trest=$2\n+\tmv \"$squash_msg\" \"$msg\" || exit\n+\trm -f \"$fixup_msg\"\n+\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n+\twarn\n+\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tdie_with_patch $sha1 \"\"\n+}\n+\n+flush_rewritten_pending() {\n+\ttest -s \"$rewritten_pending\" || return\n+\tnewsha1=\"$(git rev-parse HEAD^0)\"\n+\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n+\trm -f \"$rewritten_pending\"\n+}\n+\n+record_in_rewritten() {\n+\toldsha1=\"$(git rev-parse $1)\"\n+\techo \"$oldsha1\" >> \"$rewritten_pending\"\n+\n+\tcase \"$(peek_next_command)\" in\n+\tsquash|s|fixup|f)\n+\t\t;;\n+\t*)\n+\t\tflush_rewritten_pending\n+\t\t;;\n+\tesac\n+}\n+\n+do_pick () {\n+\tsha1=$1\n+\trest=$2\n+\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n+\tthen\n+\t\t# Set the correct commit message and author info on the\n+\t\t# sentinel root before cherry-picking the original changes\n+\t\t# without committing (-n).  Finally, update the sentinel again\n+\t\t# to include these changes.  If the cherry-pick results in a\n+\t\t# conflict, this means our behaviour is similar to a standard\n+\t\t# failed cherry-pick during rebase, with a dirty index to\n+\t\t# resolve before manually running git commit --amend then git\n+\t\t# rebase --continue.\n+\t\tgit commit --allow-empty --allow-empty-message --amend \\\n+\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n+\t\t\tpick_one -n $sha1 &&\n+\t\t\tgit commit --allow-empty --allow-empty-message \\\n+\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n+\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n+\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\telse\n+\t\tpick_one $sha1 ||\n+\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tfi\n+}\n+\n+do_next () {\n+\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n+\tread -r command sha1 rest < \"$todo\"\n+\tcase \"$command\" in\n+\t\"$comment_char\"*|''|noop|drop|d)\n+\t\tmark_action_done\n+\t\t;;\n+\t\"$cr\")\n+\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n+\t\tmark_action_done\n+\t\t;;\n+\tpick|p)\n+\t\tcomment_for_reflog pick\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\treword|r)\n+\t\tcomment_for_reflog reword\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n+\t\t\t$allow_empty_message || {\n+\t\t\twarn \"$(eval_gettext \"\\\n+Could not amend commit after successfully picking \\$sha1... \\$rest\n+This is most likely due to an empty commit message, or the pre-commit hook\n+failed. If the pre-commit hook failed, you may need to resolve the issue before\n+you are able to reword the commit.\")\"\n+\t\t\texit_with_patch $sha1 1\n+\t\t}\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tedit|e)\n+\t\tcomment_for_reflog edit\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n+\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n+\t\texit_with_patch $sha1 0\n+\t\t;;\n+\tsquash|s|fixup|f)\n+\t\tcase \"$command\" in\n+\t\tsquash|s)\n+\t\t\tsquash_style=squash\n+\t\t\t;;\n+\t\tfixup|f)\n+\t\t\tsquash_style=fixup\n+\t\t\t;;\n+\t\tesac\n+\t\tcomment_for_reflog $squash_style\n+\n+\t\ttest -f \"$done\" && has_action \"$done\" ||\n+\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n+\n+\t\tmark_action_done\n+\t\tupdate_squash_messages $squash_style $sha1\n+\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n+\t\techo \"$author_script_content\" > \"$author_script\"\n+\t\teval \"$author_script_content\"\n+\t\tif ! pick_one -n $sha1\n+\t\tthen\n+\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n+\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\tfi\n+\t\tcase \"$(peek_next_command)\" in\n+\t\tsquash|s|fixup|f)\n+\t\t\t# This is an intermediate commit; its message will only be\n+\t\t\t# used in case of trouble.  So use the long version:\n+\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n+\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# This is the final command of this squash/fixup group\n+\t\t\tif test -f \"$fixup_msg\"\n+\t\t\tthen\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\telse\n+\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n+\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\tfi\n+\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n+\t\t\t;;\n+\t\tesac\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tx|\"exec\")\n+\t\tread -r command rest < \"$todo\"\n+\t\tmark_action_done\n+\t\teval_gettextln \"Executing: \\$rest\"\n+\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n+\t\tstatus=$?\n+\t\t# Run in subshell because require_clean_work_tree can die.\n+\t\tdirty=f\n+\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n+\t\tif test \"$status\" -ne 0\n+\t\tthen\n+\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n+\t\t\ttest \"$dirty\" = f ||\n+\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n+\n+\t\t\twarn \"$(gettext \"\\\n+You can fix the problem, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\tif test $status -eq 127\t\t# command not found\n+\t\t\tthen\n+\t\t\t\tstatus=1\n+\t\t\tfi\n+\t\t\texit \"$status\"\n+\t\telif test \"$dirty\" = t\n+\t\tthen\n+\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n+\t\t\twarn \"$(eval_gettext \"\\\n+Execution succeeded: \\$rest\n+but left changes to the index and/or the working tree\n+Commit or stash your changes, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\texit 1\n+\t\tfi\n+\t\t;;\n+\t*)\n+\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n+\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n+\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n+\t\tthen\n+\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n+\t\telse\n+\t\t\tdie \"$fixtodo\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\ttest -s \"$todo\" && return\n+\n+\tcomment_for_reflog finish &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\tcase $head_name in\n+\trefs/*)\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n+\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n+\t\tgit symbolic-ref \\\n+\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n+\t\t  HEAD $head_name\n+\t\t;;\n+\tesac && {\n+\t\ttest ! -f \"$state_dir\"/verbose ||\n+\t\t\tgit diff-tree --stat $orig_head..HEAD\n+\t} &&\n+\t{\n+\t\ttest -s \"$rewritten_list\" &&\n+\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n+\t\ttrue # we don't care if this copying failed\n+\t} &&\n+\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n+\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n+\t\t\"$hook\" rebase < \"$rewritten_list\"\n+\t\ttrue # we don't care if this hook failed\n+\tfi &&\n+\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n+\n+\treturn 1 # not failure; just to break the do_rest loop\n+}\n+\n+# can only return 0, when the infinite loop breaks\n+do_rest () {\n+\twhile :\n+\tdo\n+\t\tdo_next || break\n+\tdone\n+}\n+\n+expand_todo_ids() {\n+\tgit rebase--helper --expand-ids\n+}\n+\n+collapse_todo_ids() {\n+\tgit rebase--helper --shorten-ids\n+}\n+\n+# Switch to the branch in $into and notify it in the reflog\n+checkout_onto () {\n+\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $onto_name\"\n+\toutput git checkout $onto || die_abort \"$(gettext \"could not detach HEAD\")\"\n+\tgit update-ref ORIG_HEAD $orig_head\n+}\n+\n+get_missing_commit_check_level () {\n+\tcheck_level=$(git config --get rebase.missingCommitsCheck)\n+\tcheck_level=${check_level:-ignore}\n+\t# Don't be case sensitive\n+\tprintf '%s' \"$check_level\" | tr 'A-Z' 'a-z'\n+}\n+\n+# Initiate an action. If the cannot be any\n+# further action it  may exec a command\n+# or exit and not return.\n+#\n+# TODO: Consider a cleaner return model so it\n+# never exits and always return 0 if process\n+# is complete.\n+#\n+# Parameter 1 is the action to initiate.\n+#\n+# Returns 0 if the action was able to complete\n+# and if 1 if further processing is required.\n+initiate_action () {\n+\tcase \"$1\" in\n+\tcontinue)\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\t# do we have anything to commit?\n+\t\tif git diff-index --cached --quiet HEAD --\n+\t\tthen\n+\t\t\t# Nothing to commit -- skip this commit\n+\n+\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n+\t\telse\n+\t\t\tif ! test -f \"$author_script\"\n+\t\t\tthen\n+\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\t\t\t\tdie \"$(eval_gettext \"\\\n+You have staged changes in your working tree.\n+If these changes are meant to be\n+squashed into the previous commit, run:\n+\n+  git commit --amend \\$gpg_sign_opt_quoted\n+\n+If they are meant to go into a new commit, run:\n+\n+  git commit \\$gpg_sign_opt_quoted\n+\n+In both cases, once you're done, continue with:\n+\n+  git rebase --continue\n+\")\"\n+\t\t\tfi\n+\t\t\t. \"$author_script\" ||\n+\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n+\t\t\tif test -f \"$amend\"\n+\t\t\tthen\n+\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n+\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n+\t\t\t\tdie \"$(gettext \"\\\n+You have uncommitted changes in your working tree. Please commit them\n+first and then run 'git rebase --continue' again.\")\"\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\telse\n+\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\tfi\n+\t\tfi\n+\n+\t\tif test -r \"$state_dir\"/stopped-sha\n+\t\tthen\n+\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n+\t\tfi\n+\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tskip)\n+\t\tgit rerere clear\n+\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tedit-todo)\n+\t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n+\t\tmv -f \"$todo\".new \"$todo\"\n+\t\tcollapse_todo_ids\n+\t\tappend_todo_help\n+\t\tgettext \"\n+You are editing the todo file of an ongoing interactive rebase.\n+To continue rebase after editing, run:\n+    git rebase --continue\n+\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\t\tgit_sequence_editor \"$todo\" ||\n+\t\t\tdie \"$(gettext \"Could not execute editor\")\"\n+\t\texpand_todo_ids\n+\n+\t\texit\n+\t\t;;\n+\tshow-current-patch)\n+\t\texec git show REBASE_HEAD --\n+\t\t;;\n+\t*)\n+\t\treturn 1 # continue\n+\t\t;;\n+\tesac\n+}\n+\n+setup_reflog_action () {\n+\tcomment_for_reflog start\n+\n+\tif test ! -z \"$switch_to\"\n+\tthen\n+\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\"\n+\t\toutput git checkout \"$switch_to\" -- ||\n+\t\t\tdie \"$(eval_gettext \"Could not checkout \\$switch_to\")\"\n+\n+\t\tcomment_for_reflog start\n+\tfi\n+}\n+\n+init_basic_state () {\n+\torig_head=$(git rev-parse --verify HEAD) || die \"$(gettext \"No HEAD?\")\"\n+\tmkdir -p \"$state_dir\" || die \"$(eval_gettext \"Could not create temporary \\$state_dir\")\"\n+\trm -f \"$(git rev-parse --git-path REBASE_HEAD)\"\n+\n+\t: > \"$state_dir\"/interactive || die \"$(gettext \"Could not mark as interactive\")\"\n+\twrite_basic_state\n+}\n+\n+init_revisions_and_shortrevisions () {\n+\tshorthead=$(git rev-parse --short $orig_head)\n+\tshortonto=$(git rev-parse --short $onto)\n+\tif test -z \"$rebase_root\"\n+\t\t# this is now equivalent to ! -z \"$upstream\"\n+\tthen\n+\t\tshortupstream=$(git rev-parse --short $upstream)\n+\t\trevisions=$upstream...$orig_head\n+\t\tshortrevisions=$shortupstream..$shorthead\n+\telse\n+\t\trevisions=$onto...$orig_head\n+\t\tshortrevisions=$shorthead\n+\t\ttest -z \"$squash_onto\" ||\n+\t\techo \"$squash_onto\" >\"$state_dir\"/squash-onto\n+\tfi\n+}\n+\n+complete_action() {\n+\ttest -s \"$todo\" || echo noop >> \"$todo\"\n+\ttest -z \"$autosquash\" || git rebase--helper --rearrange-squash || exit\n+\ttest -n \"$cmd\" && git rebase--helper --add-exec-commands \"$cmd\"\n+\n+\ttodocount=$(git stripspace --strip-comments <\"$todo\" | wc -l)\n+\ttodocount=${todocount##* }\n+\n+cat >>\"$todo\" <<EOF\n+\n+$comment_char $(eval_ngettext \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount command)\" \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n+\t\"$todocount\")\n+EOF\n+\tappend_todo_help\n+\tgettext \"\n+\tHowever, if you remove everything, the rebase will be aborted.\n+\n+\t\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test -z \"$keep_empty\"\n+\tthen\n+\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n+\tfi\n+\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tcp \"$todo\" \"$todo\".backup\n+\tcollapse_todo_ids\n+\tgit_sequence_editor \"$todo\" ||\n+\t\tdie_abort \"$(gettext \"Could not execute editor\")\"\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tgit rebase--helper --check-todo-list || {\n+\t\tret=$?\n+\t\tcheckout_onto\n+\t\texit $ret\n+\t}\n+\n+\texpand_todo_ids\n+\n+\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n+\tdie \"Could not skip unnecessary pick commands\"\n+\n+\tcheckout_onto\n+\tif test ! -d \"$rewritten\"\n+\tthen\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t--continue\n+\tfi\n+\tdo_rest\n+}\n+\n+git_rebase__interactive () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n+\t\t${rebase_merges:+--rebase-merges} \\\n+\t\t${rebase_cousins:+--rebase-cousins} \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n+\tdie \"$(gettext \"Could not generate todo list\")\"\n+\n+\tcomplete_action\n+}\n+\n+git_rebase__interactive__preserve_merges () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tif test -z \"$rebase_root\"\n+\tthen\n+\t\tmkdir \"$rewritten\" &&\n+\t\tfor c in $(git merge-base --all $orig_head $upstream)\n+\t\tdo\n+\t\t\techo $onto > \"$rewritten\"/$c ||\n+\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\t\tdone\n+\telse\n+\t\tmkdir \"$rewritten\" &&\n+\t\techo $onto > \"$rewritten\"/root ||\n+\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\tfi\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tformat=$(git config --get rebase.instructionFormat)\n+\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n+\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n+\t\t--reverse --left-right --topo-order \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n+\t\tsed -n \"s/^>//p\" |\n+\twhile read -r sha1 rest\n+\tdo\n+\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n+\t\tthen\n+\t\t\tcomment_out=\"$comment_char \"\n+\t\telse\n+\t\t\tcomment_out=\n+\t\tfi\n+\n+\t\tif test -z \"$rebase_root\"\n+\t\tthen\n+\t\t\tpreserve=t\n+\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n+\t\t\tdo\n+\t\t\t\tif test -f \"$rewritten\"/$p\n+\t\t\t\tthen\n+\t\t\t\t\tpreserve=f\n+\t\t\t\tfi\n+\t\t\tdone\n+\t\telse\n+\t\t\tpreserve=f\n+\t\tfi\n+\t\tif test f = \"$preserve\"\n+\t\tthen\n+\t\t\ttouch \"$rewritten\"/$sha1\n+\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n+\t\tfi\n+\tdone\n+\n+\t# Watch for commits that been dropped by --cherry-pick\n+\tmkdir \"$dropped\"\n+\t# Save all non-cherry-picked changes\n+\tgit rev-list $revisions --left-right --cherry-pick | \\\n+\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n+\t# Now all commits and note which ones are missing in\n+\t# not-cherry-picks and hence being dropped\n+\tgit rev-list $revisions |\n+\twhile read rev\n+\tdo\n+\t\tif test -f \"$rewritten\"/$rev &&\n+\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n+\t\tthen\n+\t\t\t# Use -f2 because if rev-list is telling us this commit is\n+\t\t\t# not worthwhile, we don't want to track its multiple heads,\n+\t\t\t# just the history of its first-parent for others that will\n+\t\t\t# be rebasing on top of it\n+\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n+\t\t\tsha1=$(git rev-list -1 $rev)\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n+\t\t\trm \"$rewritten\"/$rev\n+\t\tfi\n+\tdone\n+\n+\tcomplete_action\n+}\n-- \n2.16.1\n\n"},{"id":"348332","messageId":"20180522211625.23893-5-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522211625.23893-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v2 4/4] rebase: remove -p code from git-rebase--interactive.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-22T21:16:25Z","receivedAt":"2018-05-22T21:16:52Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"All the code specific to preserve-merges was moved to\ngit-rebase--preserve-merges.sh, and so it’s useless to keep it here.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--interactive.sh | 708 +--------------------------------------------\n 1 file changed, 8 insertions(+), 700 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2f4941d0f..657d32773 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -105,15 +105,6 @@ case \"$comment_char\" in\n \t;;\n esac\n \n-warn () {\n-\tprintf '%s\\n' \"$*\" >&2\n-}\n-\n-# Output the commit message for the specified commit.\n-commit_message () {\n-\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n-}\n-\n orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n@@ -142,16 +133,6 @@ mark_action_done () {\n \tfi\n }\n \n-# Put the last action marked done at the beginning of the todo list\n-# again. If there has not been an action marked done yet, leave the list of\n-# items on the todo list unchanged.\n-reschedule_last_action () {\n-\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n-\tsed -e \\$d <\"$done\" >\"$done\".new\n-\tmv -f \"$todo\".new \"$todo\"\n-\tmv -f \"$done\".new \"$done\"\n-}\n-\n append_todo_help () {\n \tgettext \"\n Commands:\n@@ -184,50 +165,6 @@ If you remove a line here THAT COMMIT WILL BE LOST.\n \tfi\n }\n \n-make_patch () {\n-\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n-\tcase \"$sha1_and_parents\" in\n-\t?*' '?*' '?*)\n-\t\tgit diff --cc $sha1_and_parents\n-\t\t;;\n-\t?*' '?*)\n-\t\tgit diff-tree -p \"$1^!\"\n-\t\t;;\n-\t*)\n-\t\techo \"Root commit\"\n-\t\t;;\n-\tesac > \"$state_dir\"/patch\n-\ttest -f \"$msg\" ||\n-\t\tcommit_message \"$1\" > \"$msg\"\n-\ttest -f \"$author_script\" ||\n-\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n-}\n-\n-die_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch \"$1\"\n-\tdie \"$2\"\n-}\n-\n-exit_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch $1\n-\tgit rev-parse --verify HEAD > \"$amend\"\n-\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\twarn \"$(eval_gettext \"\\\n-You can amend the commit now, with\n-\n-\tgit commit --amend \\$gpg_sign_opt_quoted\n-\n-Once you are satisfied with your changes, run\n-\n-\tgit rebase --continue\")\"\n-\twarn\n-\texit $2\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -238,30 +175,6 @@ has_action () {\n \ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n }\n \n-is_empty_commit() {\n-\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n-\t\tsha1=$1\n-\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n-\t}\n-\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n-\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n-\ttest \"$tree\" = \"$ptree\"\n-}\n-\n-is_merge_commit()\n-{\n-\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n-}\n-\n-# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n-# GIT_AUTHOR_DATE exported from the current environment.\n-do_with_author () {\n-\t(\n-\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n-\t\t\"$@\"\n-\t)\n-}\n-\n git_sequence_editor () {\n \tif test -z \"$GIT_SEQUENCE_EDITOR\"\n \tthen\n@@ -275,455 +188,6 @@ git_sequence_editor () {\n \teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n }\n \n-pick_one () {\n-\tff=--ff\n-\n-\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n-\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n-\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n-\n-\tif is_empty_commit \"$sha1\"\n-\tthen\n-\t\tempty_args=\"--allow-empty\"\n-\tfi\n-\n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n-}\n-\n-pick_one_preserving_merges () {\n-\tfast_forward=t\n-\tcase \"$1\" in\n-\t-n)\n-\t\tfast_forward=f\n-\t\tsha1=$2\n-\t\t;;\n-\t*)\n-\t\tsha1=$1\n-\t\t;;\n-\tesac\n-\tsha1=$(git rev-parse $sha1)\n-\n-\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n-\tthen\n-\t\twhile read current_commit\n-\t\tdo\n-\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n-\t\tdone <\"$state_dir\"/current-commit\n-\t\trm \"$state_dir\"/current-commit ||\n-\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n-\tfi\n-\n-\techo $sha1 >> \"$state_dir\"/current-commit\n-\n-\t# rewrite parents; if none were rewritten, we can fast-forward.\n-\tnew_parents=\n-\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n-\tif test \"$pend\" = \" \"\n-\tthen\n-\t\tpend=\" root\"\n-\tfi\n-\twhile [ \"$pend\" != \"\" ]\n-\tdo\n-\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n-\t\tpend=\"${pend# $p}\"\n-\n-\t\tif test -f \"$rewritten\"/$p\n-\t\tthen\n-\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n-\n-\t\t\t# If the todo reordered commits, and our parent is marked for\n-\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n-\t\t\t# drop it on top of the current HEAD\n-\t\t\tif test -z \"$new_p\"\n-\t\t\tthen\n-\t\t\t\tnew_p=$(git rev-parse HEAD)\n-\t\t\tfi\n-\n-\t\t\ttest $p != $new_p && fast_forward=f\n-\t\t\tcase \"$new_parents\" in\n-\t\t\t*$new_p*)\n-\t\t\t\t;; # do nothing; that parent is already there\n-\t\t\t*)\n-\t\t\t\tnew_parents=\"$new_parents $new_p\"\n-\t\t\t\t;;\n-\t\t\tesac\n-\t\telse\n-\t\t\tif test -f \"$dropped\"/$p\n-\t\t\tthen\n-\t\t\t\tfast_forward=f\n-\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n-\t\t\t\ttest -z \"$replacement\" && replacement=root\n-\t\t\t\tpend=\" $replacement$pend\"\n-\t\t\telse\n-\t\t\t\tnew_parents=\"$new_parents $p\"\n-\t\t\tfi\n-\t\tfi\n-\tdone\n-\tcase $fast_forward in\n-\tt)\n-\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n-\t\toutput git reset --hard $sha1 ||\n-\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n-\t\t;;\n-\tf)\n-\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\n-\t\tif [ \"$1\" != \"-n\" ]\n-\t\tthen\n-\t\t\t# detach HEAD to current parent\n-\t\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n-\t\tfi\n-\n-\t\tcase \"$new_parents\" in\n-\t\t' '*' '*)\n-\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n-\n-\t\t\t# redo merge\n-\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n-\t\t\teval \"$author_script_content\"\n-\t\t\tmsg_content=\"$(commit_message $sha1)\"\n-\t\t\t# No point in merging the first parent, that's HEAD\n-\t\t\tnew_parents=${new_parents# $first_parent}\n-\t\t\tmerge_args=\"--no-log --no-ff\"\n-\t\t\tif ! do_with_author output eval \\\n-\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n-\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n-\t\t\t\t\"$strategy_args\" \\\n-\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n-\t\t\t\t\"$new_parents\"\n-\t\t\tthen\n-\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n-\t\t\tfi\n-\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n-\t\t\t\t$allow_empty_message \\\n-\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t\"$strategy_args\" \"$@\" ||\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n-\t\t\t;;\n-\t\tesac\n-\t\t;;\n-\tesac\n-}\n-\n-this_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"This is the commit message #\\${n}:\"\n-}\n-\n-skip_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"The commit message #\\${n} will be skipped:\"\n-}\n-\n-update_squash_messages () {\n-\tif test -f \"$squash_msg\"; then\n-\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n-\t\tcount=$(($(sed -n \\\n-\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n-\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n-\t\t\t\t\"This is a combination of \\$count commit.\" \\\n-\t\t\t\t\"This is a combination of \\$count commits.\" \\\n-\t\t\t\t$count)\"\n-\t\t\tsed -e 1d -e '2,/^./{\n-\t\t\t\t/^$/d\n-\t\t\t}' <\"$squash_msg\".bak\n-\t\t} >\"$squash_msg\"\n-\telse\n-\t\tcommit_message HEAD >\"$fixup_msg\" ||\n-\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n-\t\tcount=2\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n-\t\t\techo\n-\t\t\tcat \"$fixup_msg\"\n-\t\t} >\"$squash_msg\"\n-\tfi\n-\tcase $1 in\n-\tsquash)\n-\t\trm -f \"$fixup_msg\"\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n-\t\techo\n-\t\tcommit_message $2\n-\t\t;;\n-\tfixup)\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n-\t\techo\n-\t\t# Change the space after the comment character to TAB:\n-\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n-\t\t;;\n-\tesac >>\"$squash_msg\"\n-}\n-\n-peek_next_command () {\n-\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n-}\n-\n-# A squash/fixup has failed.  Prepare the long version of the squash\n-# commit message, then die_with_patch.  This code path requires the\n-# user to edit the combined commit message for all commits that have\n-# been squashed/fixedup so far.  So also erase the old squash\n-# messages, effectively causing the combined commit to be used as the\n-# new basis for any further squash/fixups.  Args: sha1 rest\n-die_failed_squash() {\n-\tsha1=$1\n-\trest=$2\n-\tmv \"$squash_msg\" \"$msg\" || exit\n-\trm -f \"$fixup_msg\"\n-\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n-\twarn\n-\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tdie_with_patch $sha1 \"\"\n-}\n-\n-flush_rewritten_pending() {\n-\ttest -s \"$rewritten_pending\" || return\n-\tnewsha1=\"$(git rev-parse HEAD^0)\"\n-\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n-\trm -f \"$rewritten_pending\"\n-}\n-\n-record_in_rewritten() {\n-\toldsha1=\"$(git rev-parse $1)\"\n-\techo \"$oldsha1\" >> \"$rewritten_pending\"\n-\n-\tcase \"$(peek_next_command)\" in\n-\tsquash|s|fixup|f)\n-\t\t;;\n-\t*)\n-\t\tflush_rewritten_pending\n-\t\t;;\n-\tesac\n-}\n-\n-do_pick () {\n-\tsha1=$1\n-\trest=$2\n-\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n-\tthen\n-\t\t# Set the correct commit message and author info on the\n-\t\t# sentinel root before cherry-picking the original changes\n-\t\t# without committing (-n).  Finally, update the sentinel again\n-\t\t# to include these changes.  If the cherry-pick results in a\n-\t\t# conflict, this means our behaviour is similar to a standard\n-\t\t# failed cherry-pick during rebase, with a dirty index to\n-\t\t# resolve before manually running git commit --amend then git\n-\t\t# rebase --continue.\n-\t\tgit commit --allow-empty --allow-empty-message --amend \\\n-\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n-\t\t\tpick_one -n $sha1 &&\n-\t\t\tgit commit --allow-empty --allow-empty-message \\\n-\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n-\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n-\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\telse\n-\t\tpick_one $sha1 ||\n-\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tfi\n-}\n-\n-do_next () {\n-\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n-\tread -r command sha1 rest < \"$todo\"\n-\tcase \"$command\" in\n-\t\"$comment_char\"*|''|noop|drop|d)\n-\t\tmark_action_done\n-\t\t;;\n-\t\"$cr\")\n-\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n-\t\tmark_action_done\n-\t\t;;\n-\tpick|p)\n-\t\tcomment_for_reflog pick\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\treword|r)\n-\t\tcomment_for_reflog reword\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n-\t\t\t$allow_empty_message || {\n-\t\t\twarn \"$(eval_gettext \"\\\n-Could not amend commit after successfully picking \\$sha1... \\$rest\n-This is most likely due to an empty commit message, or the pre-commit hook\n-failed. If the pre-commit hook failed, you may need to resolve the issue before\n-you are able to reword the commit.\")\"\n-\t\t\texit_with_patch $sha1 1\n-\t\t}\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tedit|e)\n-\t\tcomment_for_reflog edit\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n-\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n-\t\texit_with_patch $sha1 0\n-\t\t;;\n-\tsquash|s|fixup|f)\n-\t\tcase \"$command\" in\n-\t\tsquash|s)\n-\t\t\tsquash_style=squash\n-\t\t\t;;\n-\t\tfixup|f)\n-\t\t\tsquash_style=fixup\n-\t\t\t;;\n-\t\tesac\n-\t\tcomment_for_reflog $squash_style\n-\n-\t\ttest -f \"$done\" && has_action \"$done\" ||\n-\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n-\n-\t\tmark_action_done\n-\t\tupdate_squash_messages $squash_style $sha1\n-\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n-\t\techo \"$author_script_content\" > \"$author_script\"\n-\t\teval \"$author_script_content\"\n-\t\tif ! pick_one -n $sha1\n-\t\tthen\n-\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n-\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\tfi\n-\t\tcase \"$(peek_next_command)\" in\n-\t\tsquash|s|fixup|f)\n-\t\t\t# This is an intermediate commit; its message will only be\n-\t\t\t# used in case of trouble.  So use the long version:\n-\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n-\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\t# This is the final command of this squash/fixup group\n-\t\t\tif test -f \"$fixup_msg\"\n-\t\t\tthen\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\telse\n-\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n-\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\tfi\n-\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n-\t\t\t;;\n-\t\tesac\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tx|\"exec\")\n-\t\tread -r command rest < \"$todo\"\n-\t\tmark_action_done\n-\t\teval_gettextln \"Executing: \\$rest\"\n-\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n-\t\tstatus=$?\n-\t\t# Run in subshell because require_clean_work_tree can die.\n-\t\tdirty=f\n-\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n-\t\tif test \"$status\" -ne 0\n-\t\tthen\n-\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n-\t\t\ttest \"$dirty\" = f ||\n-\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n-\n-\t\t\twarn \"$(gettext \"\\\n-You can fix the problem, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\tif test $status -eq 127\t\t# command not found\n-\t\t\tthen\n-\t\t\t\tstatus=1\n-\t\t\tfi\n-\t\t\texit \"$status\"\n-\t\telif test \"$dirty\" = t\n-\t\tthen\n-\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n-\t\t\twarn \"$(eval_gettext \"\\\n-Execution succeeded: \\$rest\n-but left changes to the index and/or the working tree\n-Commit or stash your changes, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\texit 1\n-\t\tfi\n-\t\t;;\n-\t*)\n-\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n-\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n-\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n-\t\tthen\n-\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n-\t\telse\n-\t\t\tdie \"$fixtodo\"\n-\t\tfi\n-\t\t;;\n-\tesac\n-\ttest -s \"$todo\" && return\n-\n-\tcomment_for_reflog finish &&\n-\tnewhead=$(git rev-parse HEAD) &&\n-\tcase $head_name in\n-\trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n-\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n-\t\tgit symbolic-ref \\\n-\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n-\t\t  HEAD $head_name\n-\t\t;;\n-\tesac && {\n-\t\ttest ! -f \"$state_dir\"/verbose ||\n-\t\t\tgit diff-tree --stat $orig_head..HEAD\n-\t} &&\n-\t{\n-\t\ttest -s \"$rewritten_list\" &&\n-\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n-\t\ttrue # we don't care if this copying failed\n-\t} &&\n-\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n-\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n-\t\t\"$hook\" rebase < \"$rewritten_list\"\n-\t\ttrue # we don't care if this hook failed\n-\tfi &&\n-\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n-\n-\treturn 1 # not failure; just to break the do_rest loop\n-}\n-\n-# can only return 0, when the infinite loop breaks\n-do_rest () {\n-\twhile :\n-\tdo\n-\t\tdo_next || break\n-\tdone\n-}\n-\n expand_todo_ids() {\n \tgit rebase--helper --expand-ids\n }\n@@ -761,77 +225,13 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\t# do we have anything to commit?\n-\t\tif git diff-index --cached --quiet HEAD --\n-\t\tthen\n-\t\t\t# Nothing to commit -- skip this commit\n-\n-\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n-\t\telse\n-\t\t\tif ! test -f \"$author_script\"\n-\t\t\tthen\n-\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\t\t\t\tdie \"$(eval_gettext \"\\\n-You have staged changes in your working tree.\n-If these changes are meant to be\n-squashed into the previous commit, run:\n-\n-  git commit --amend \\$gpg_sign_opt_quoted\n-\n-If they are meant to go into a new commit, run:\n-\n-  git commit \\$gpg_sign_opt_quoted\n-\n-In both cases, once you're done, continue with:\n-\n-  git rebase --continue\n-\")\"\n-\t\t\tfi\n-\t\t\t. \"$author_script\" ||\n-\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n-\t\t\tif test -f \"$amend\"\n-\t\t\tthen\n-\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n-\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n-\t\t\t\tdie \"$(gettext \"\\\n-You have uncommitted changes in your working tree. Please commit them\n-first and then run 'git rebase --continue' again.\")\"\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\telse\n-\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\tfi\n-\t\tfi\n-\n-\t\tif test -r \"$state_dir\"/stopped-sha\n-\t\tthen\n-\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n-\t\tfi\n-\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tedit-todo)\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n@@ -945,18 +345,14 @@ EOF\n \n \texpand_todo_ids\n \n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\ttest -n \"$force_rebase\" ||\n \tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n \tdie \"Could not skip unnecessary pick commands\"\n \n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n-\tdo_rest\n+\trequire_clean_work_tree \"rebase\"\n+\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t     --continue\n }\n \n git_rebase__interactive () {\n@@ -979,91 +375,3 @@ git_rebase__interactive () {\n \n \tcomplete_action\n }\n-\n-git_rebase__interactive__preserve_merges () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tif test -z \"$rebase_root\"\n-\tthen\n-\t\tmkdir \"$rewritten\" &&\n-\t\tfor c in $(git merge-base --all $orig_head $upstream)\n-\t\tdo\n-\t\t\techo $onto > \"$rewritten\"/$c ||\n-\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\t\tdone\n-\telse\n-\t\tmkdir \"$rewritten\" &&\n-\t\techo $onto > \"$rewritten\"/root ||\n-\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\tfi\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tformat=$(git config --get rebase.instructionFormat)\n-\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n-\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n-\t\t--reverse --left-right --topo-order \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n-\t\tsed -n \"s/^>//p\" |\n-\twhile read -r sha1 rest\n-\tdo\n-\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n-\t\tthen\n-\t\t\tcomment_out=\"$comment_char \"\n-\t\telse\n-\t\t\tcomment_out=\n-\t\tfi\n-\n-\t\tif test -z \"$rebase_root\"\n-\t\tthen\n-\t\t\tpreserve=t\n-\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n-\t\t\tdo\n-\t\t\t\tif test -f \"$rewritten\"/$p\n-\t\t\t\tthen\n-\t\t\t\t\tpreserve=f\n-\t\t\t\tfi\n-\t\t\tdone\n-\t\telse\n-\t\t\tpreserve=f\n-\t\tfi\n-\t\tif test f = \"$preserve\"\n-\t\tthen\n-\t\t\ttouch \"$rewritten\"/$sha1\n-\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n-\t\tfi\n-\tdone\n-\n-\t# Watch for commits that been dropped by --cherry-pick\n-\tmkdir \"$dropped\"\n-\t# Save all non-cherry-picked changes\n-\tgit rev-list $revisions --left-right --cherry-pick | \\\n-\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n-\t# Now all commits and note which ones are missing in\n-\t# not-cherry-picks and hence being dropped\n-\tgit rev-list $revisions |\n-\twhile read rev\n-\tdo\n-\t\tif test -f \"$rewritten\"/$rev &&\n-\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n-\t\tthen\n-\t\t\t# Use -f2 because if rev-list is telling us this commit is\n-\t\t\t# not worthwhile, we don't want to track its multiple heads,\n-\t\t\t# just the history of its first-parent for others that will\n-\t\t\t# be rebasing on top of it\n-\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n-\t\t\tsha1=$(git rev-list -1 $rev)\n-\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n-\t\t\trm \"$rewritten\"/$rev\n-\t\tfi\n-\tdone\n-\n-\tcomplete_action\n-}\n-- \n2.16.1\n\n"},{"id":"348422","messageId":"20180524114958.26521-1-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180522211625.23893-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 0/4] rebase: split rebase -p from rebase -i","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-24T11:49:54Z","receivedAt":"2018-05-24T11:50:14Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This splits the `rebase --preserve-merges` functionnality from\ngit-rebase--interactive.sh. All the dead code left by the duplication of\ngit-rebase--interactive.sh is also removed. This will make it easier to rewrite\nthis script in C.\n\nThis patch series is based of js/sequencer-and-root-commits.\n\nChanges since v2:\n\n - Removing `\n\nAlban Gruin (4):\n  rebase: duplicate git-rebase--interactive.sh to\n    git-rebase--preserve-merges.sh\n  rebase: strip unused code in git-rebase--preserve-merges.sh\n  rebase: use the new git-rebase--preserve-merges.sh\n  rebase: remove -p code from git-rebase--interactive.sh\n\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--interactive.sh     |  802 +------------------------------\n git-rebase--preserve-merges.sh | 1012 ++++++++++++++++++++++++++++++++++++++++\n git-rebase.sh                  |   32 +-\n 5 files changed, 1048 insertions(+), 801 deletions(-)\n create mode 100644 git-rebase--preserve-merges.sh\n\n-- \n2.16.1\n\n"},{"id":"348423","messageId":"20180524114958.26521-5-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 4/4] rebase: remove -p code from git-rebase--interactive.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-24T11:49:58Z","receivedAt":"2018-05-24T11:50:27Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"All the code specific to preserve-merges was moved to\ngit-rebase--preserve-merges.sh, and so it’s useless to keep it here.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--interactive.sh | 802 +--------------------------------------------\n 1 file changed, 8 insertions(+), 794 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2f4941d0f..9884ecd71 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -13,83 +13,6 @@\n # file and written to the tail of $done.\n todo=\"$state_dir\"/git-rebase-todo\n \n-# The rebase command lines that have already been processed.  A line\n-# is moved here when it is first handled, before any associated user\n-# actions.\n-done=\"$state_dir\"/done\n-\n-# The commit message that is planned to be used for any changes that\n-# need to be committed following a user interaction.\n-msg=\"$state_dir\"/message\n-\n-# The file into which is accumulated the suggested commit message for\n-# squash/fixup commands.  When the first of a series of squash/fixups\n-# is seen, the file is created and the commit message from the\n-# previous commit and from the first squash/fixup commit are written\n-# to it.  The commit message for each subsequent squash/fixup commit\n-# is appended to the file as it is processed.\n-#\n-# The first line of the file is of the form\n-#     # This is a combination of $count commits.\n-# where $count is the number of commits whose messages have been\n-# written to the file so far (including the initial \"pick\" commit).\n-# Each time that a commit message is processed, this line is read and\n-# updated.  It is deleted just before the combined commit is made.\n-squash_msg=\"$state_dir\"/message-squash\n-\n-# If the current series of squash/fixups has not yet included a squash\n-# command, then this file exists and holds the commit message of the\n-# original \"pick\" commit.  (If the series ends without a \"squash\"\n-# command, then this can be used as the commit message of the combined\n-# commit without opening the editor.)\n-fixup_msg=\"$state_dir\"/message-fixup\n-\n-# $rewritten is the name of a directory containing files for each\n-# commit that is reachable by at least one merge base of $head and\n-# $upstream. They are not necessarily rewritten, but their children\n-# might be.  This ensures that commits on merged, but otherwise\n-# unrelated side branches are left alone. (Think \"X\" in the man page's\n-# example.)\n-rewritten=\"$state_dir\"/rewritten\n-\n-dropped=\"$state_dir\"/dropped\n-\n-end=\"$state_dir\"/end\n-msgnum=\"$state_dir\"/msgnum\n-\n-# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n-# GIT_AUTHOR_DATE that will be used for the commit that is currently\n-# being rebased.\n-author_script=\"$state_dir\"/author-script\n-\n-# When an \"edit\" rebase command is being processed, the SHA1 of the\n-# commit to be edited is recorded in this file.  When \"git rebase\n-# --continue\" is executed, if there are any staged changes then they\n-# will be amended to the HEAD commit, but only provided the HEAD\n-# commit is still the commit to be edited.  When any other rebase\n-# command is processed, this file is deleted.\n-amend=\"$state_dir\"/amend\n-\n-# For the post-rewrite hook, we make a list of rewritten commits and\n-# their new sha1s.  The rewritten-pending list keeps the sha1s of\n-# commits that have been processed, but not committed yet,\n-# e.g. because they are waiting for a 'squash' command.\n-rewritten_list=\"$state_dir\"/rewritten-list\n-rewritten_pending=\"$state_dir\"/rewritten-pending\n-\n-# Work around Git for Windows' Bash whose \"read\" does not strip CRLF\n-# and leaves CR at the end instead.\n-cr=$(printf \"\\015\")\n-\n-strategy_args=${strategy:+--strategy=$strategy}\n-test -n \"$strategy_opts\" &&\n-eval '\n-\tfor strategy_opt in '\"$strategy_opts\"'\n-\tdo\n-\t\tstrategy_args=\"$strategy_args -X$(git rev-parse --sq-quote \"${strategy_opt#--}\")\"\n-\tdone\n-'\n-\n GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n export GIT_CHERRY_PICK_HELP\n \n@@ -105,15 +28,6 @@ case \"$comment_char\" in\n \t;;\n esac\n \n-warn () {\n-\tprintf '%s\\n' \"$*\" >&2\n-}\n-\n-# Output the commit message for the specified commit.\n-commit_message () {\n-\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n-}\n-\n orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n@@ -125,33 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-last_count=\n-mark_action_done () {\n-\tsed -e 1q < \"$todo\" >> \"$done\"\n-\tsed -e 1d < \"$todo\" >> \"$todo\".new\n-\tmv -f \"$todo\".new \"$todo\"\n-\tnew_count=$(( $(git stripspace --strip-comments <\"$done\" | wc -l) ))\n-\techo $new_count >\"$msgnum\"\n-\ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n-\techo $total >\"$end\"\n-\tif test \"$last_count\" != \"$new_count\"\n-\tthen\n-\t\tlast_count=$new_count\n-\t\teval_gettext \"Rebasing (\\$new_count/\\$total)\"; printf \"\\r\"\n-\t\ttest -z \"$verbose\" || echo\n-\tfi\n-}\n-\n-# Put the last action marked done at the beginning of the todo list\n-# again. If there has not been an action marked done yet, leave the list of\n-# items on the todo list unchanged.\n-reschedule_last_action () {\n-\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n-\tsed -e \\$d <\"$done\" >\"$done\".new\n-\tmv -f \"$todo\".new \"$todo\"\n-\tmv -f \"$done\".new \"$done\"\n-}\n-\n append_todo_help () {\n \tgettext \"\n Commands:\n@@ -184,50 +71,6 @@ If you remove a line here THAT COMMIT WILL BE LOST.\n \tfi\n }\n \n-make_patch () {\n-\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n-\tcase \"$sha1_and_parents\" in\n-\t?*' '?*' '?*)\n-\t\tgit diff --cc $sha1_and_parents\n-\t\t;;\n-\t?*' '?*)\n-\t\tgit diff-tree -p \"$1^!\"\n-\t\t;;\n-\t*)\n-\t\techo \"Root commit\"\n-\t\t;;\n-\tesac > \"$state_dir\"/patch\n-\ttest -f \"$msg\" ||\n-\t\tcommit_message \"$1\" > \"$msg\"\n-\ttest -f \"$author_script\" ||\n-\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n-}\n-\n-die_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch \"$1\"\n-\tdie \"$2\"\n-}\n-\n-exit_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch $1\n-\tgit rev-parse --verify HEAD > \"$amend\"\n-\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\twarn \"$(eval_gettext \"\\\n-You can amend the commit now, with\n-\n-\tgit commit --amend \\$gpg_sign_opt_quoted\n-\n-Once you are satisfied with your changes, run\n-\n-\tgit rebase --continue\")\"\n-\twarn\n-\texit $2\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -238,30 +81,6 @@ has_action () {\n \ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n }\n \n-is_empty_commit() {\n-\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n-\t\tsha1=$1\n-\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n-\t}\n-\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n-\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n-\ttest \"$tree\" = \"$ptree\"\n-}\n-\n-is_merge_commit()\n-{\n-\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n-}\n-\n-# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n-# GIT_AUTHOR_DATE exported from the current environment.\n-do_with_author () {\n-\t(\n-\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n-\t\t\"$@\"\n-\t)\n-}\n-\n git_sequence_editor () {\n \tif test -z \"$GIT_SEQUENCE_EDITOR\"\n \tthen\n@@ -275,455 +94,6 @@ git_sequence_editor () {\n \teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n }\n \n-pick_one () {\n-\tff=--ff\n-\n-\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n-\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n-\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n-\n-\tif is_empty_commit \"$sha1\"\n-\tthen\n-\t\tempty_args=\"--allow-empty\"\n-\tfi\n-\n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n-}\n-\n-pick_one_preserving_merges () {\n-\tfast_forward=t\n-\tcase \"$1\" in\n-\t-n)\n-\t\tfast_forward=f\n-\t\tsha1=$2\n-\t\t;;\n-\t*)\n-\t\tsha1=$1\n-\t\t;;\n-\tesac\n-\tsha1=$(git rev-parse $sha1)\n-\n-\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n-\tthen\n-\t\twhile read current_commit\n-\t\tdo\n-\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n-\t\tdone <\"$state_dir\"/current-commit\n-\t\trm \"$state_dir\"/current-commit ||\n-\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n-\tfi\n-\n-\techo $sha1 >> \"$state_dir\"/current-commit\n-\n-\t# rewrite parents; if none were rewritten, we can fast-forward.\n-\tnew_parents=\n-\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n-\tif test \"$pend\" = \" \"\n-\tthen\n-\t\tpend=\" root\"\n-\tfi\n-\twhile [ \"$pend\" != \"\" ]\n-\tdo\n-\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n-\t\tpend=\"${pend# $p}\"\n-\n-\t\tif test -f \"$rewritten\"/$p\n-\t\tthen\n-\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n-\n-\t\t\t# If the todo reordered commits, and our parent is marked for\n-\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n-\t\t\t# drop it on top of the current HEAD\n-\t\t\tif test -z \"$new_p\"\n-\t\t\tthen\n-\t\t\t\tnew_p=$(git rev-parse HEAD)\n-\t\t\tfi\n-\n-\t\t\ttest $p != $new_p && fast_forward=f\n-\t\t\tcase \"$new_parents\" in\n-\t\t\t*$new_p*)\n-\t\t\t\t;; # do nothing; that parent is already there\n-\t\t\t*)\n-\t\t\t\tnew_parents=\"$new_parents $new_p\"\n-\t\t\t\t;;\n-\t\t\tesac\n-\t\telse\n-\t\t\tif test -f \"$dropped\"/$p\n-\t\t\tthen\n-\t\t\t\tfast_forward=f\n-\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n-\t\t\t\ttest -z \"$replacement\" && replacement=root\n-\t\t\t\tpend=\" $replacement$pend\"\n-\t\t\telse\n-\t\t\t\tnew_parents=\"$new_parents $p\"\n-\t\t\tfi\n-\t\tfi\n-\tdone\n-\tcase $fast_forward in\n-\tt)\n-\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n-\t\toutput git reset --hard $sha1 ||\n-\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n-\t\t;;\n-\tf)\n-\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\n-\t\tif [ \"$1\" != \"-n\" ]\n-\t\tthen\n-\t\t\t# detach HEAD to current parent\n-\t\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n-\t\tfi\n-\n-\t\tcase \"$new_parents\" in\n-\t\t' '*' '*)\n-\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n-\n-\t\t\t# redo merge\n-\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n-\t\t\teval \"$author_script_content\"\n-\t\t\tmsg_content=\"$(commit_message $sha1)\"\n-\t\t\t# No point in merging the first parent, that's HEAD\n-\t\t\tnew_parents=${new_parents# $first_parent}\n-\t\t\tmerge_args=\"--no-log --no-ff\"\n-\t\t\tif ! do_with_author output eval \\\n-\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n-\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n-\t\t\t\t\"$strategy_args\" \\\n-\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n-\t\t\t\t\"$new_parents\"\n-\t\t\tthen\n-\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n-\t\t\tfi\n-\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n-\t\t\t\t$allow_empty_message \\\n-\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t\"$strategy_args\" \"$@\" ||\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n-\t\t\t;;\n-\t\tesac\n-\t\t;;\n-\tesac\n-}\n-\n-this_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"This is the commit message #\\${n}:\"\n-}\n-\n-skip_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"The commit message #\\${n} will be skipped:\"\n-}\n-\n-update_squash_messages () {\n-\tif test -f \"$squash_msg\"; then\n-\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n-\t\tcount=$(($(sed -n \\\n-\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n-\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n-\t\t\t\t\"This is a combination of \\$count commit.\" \\\n-\t\t\t\t\"This is a combination of \\$count commits.\" \\\n-\t\t\t\t$count)\"\n-\t\t\tsed -e 1d -e '2,/^./{\n-\t\t\t\t/^$/d\n-\t\t\t}' <\"$squash_msg\".bak\n-\t\t} >\"$squash_msg\"\n-\telse\n-\t\tcommit_message HEAD >\"$fixup_msg\" ||\n-\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n-\t\tcount=2\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n-\t\t\techo\n-\t\t\tcat \"$fixup_msg\"\n-\t\t} >\"$squash_msg\"\n-\tfi\n-\tcase $1 in\n-\tsquash)\n-\t\trm -f \"$fixup_msg\"\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n-\t\techo\n-\t\tcommit_message $2\n-\t\t;;\n-\tfixup)\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n-\t\techo\n-\t\t# Change the space after the comment character to TAB:\n-\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n-\t\t;;\n-\tesac >>\"$squash_msg\"\n-}\n-\n-peek_next_command () {\n-\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n-}\n-\n-# A squash/fixup has failed.  Prepare the long version of the squash\n-# commit message, then die_with_patch.  This code path requires the\n-# user to edit the combined commit message for all commits that have\n-# been squashed/fixedup so far.  So also erase the old squash\n-# messages, effectively causing the combined commit to be used as the\n-# new basis for any further squash/fixups.  Args: sha1 rest\n-die_failed_squash() {\n-\tsha1=$1\n-\trest=$2\n-\tmv \"$squash_msg\" \"$msg\" || exit\n-\trm -f \"$fixup_msg\"\n-\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n-\twarn\n-\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tdie_with_patch $sha1 \"\"\n-}\n-\n-flush_rewritten_pending() {\n-\ttest -s \"$rewritten_pending\" || return\n-\tnewsha1=\"$(git rev-parse HEAD^0)\"\n-\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n-\trm -f \"$rewritten_pending\"\n-}\n-\n-record_in_rewritten() {\n-\toldsha1=\"$(git rev-parse $1)\"\n-\techo \"$oldsha1\" >> \"$rewritten_pending\"\n-\n-\tcase \"$(peek_next_command)\" in\n-\tsquash|s|fixup|f)\n-\t\t;;\n-\t*)\n-\t\tflush_rewritten_pending\n-\t\t;;\n-\tesac\n-}\n-\n-do_pick () {\n-\tsha1=$1\n-\trest=$2\n-\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n-\tthen\n-\t\t# Set the correct commit message and author info on the\n-\t\t# sentinel root before cherry-picking the original changes\n-\t\t# without committing (-n).  Finally, update the sentinel again\n-\t\t# to include these changes.  If the cherry-pick results in a\n-\t\t# conflict, this means our behaviour is similar to a standard\n-\t\t# failed cherry-pick during rebase, with a dirty index to\n-\t\t# resolve before manually running git commit --amend then git\n-\t\t# rebase --continue.\n-\t\tgit commit --allow-empty --allow-empty-message --amend \\\n-\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n-\t\t\tpick_one -n $sha1 &&\n-\t\t\tgit commit --allow-empty --allow-empty-message \\\n-\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n-\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n-\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\telse\n-\t\tpick_one $sha1 ||\n-\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tfi\n-}\n-\n-do_next () {\n-\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n-\tread -r command sha1 rest < \"$todo\"\n-\tcase \"$command\" in\n-\t\"$comment_char\"*|''|noop|drop|d)\n-\t\tmark_action_done\n-\t\t;;\n-\t\"$cr\")\n-\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n-\t\tmark_action_done\n-\t\t;;\n-\tpick|p)\n-\t\tcomment_for_reflog pick\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\treword|r)\n-\t\tcomment_for_reflog reword\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n-\t\t\t$allow_empty_message || {\n-\t\t\twarn \"$(eval_gettext \"\\\n-Could not amend commit after successfully picking \\$sha1... \\$rest\n-This is most likely due to an empty commit message, or the pre-commit hook\n-failed. If the pre-commit hook failed, you may need to resolve the issue before\n-you are able to reword the commit.\")\"\n-\t\t\texit_with_patch $sha1 1\n-\t\t}\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tedit|e)\n-\t\tcomment_for_reflog edit\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n-\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n-\t\texit_with_patch $sha1 0\n-\t\t;;\n-\tsquash|s|fixup|f)\n-\t\tcase \"$command\" in\n-\t\tsquash|s)\n-\t\t\tsquash_style=squash\n-\t\t\t;;\n-\t\tfixup|f)\n-\t\t\tsquash_style=fixup\n-\t\t\t;;\n-\t\tesac\n-\t\tcomment_for_reflog $squash_style\n-\n-\t\ttest -f \"$done\" && has_action \"$done\" ||\n-\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n-\n-\t\tmark_action_done\n-\t\tupdate_squash_messages $squash_style $sha1\n-\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n-\t\techo \"$author_script_content\" > \"$author_script\"\n-\t\teval \"$author_script_content\"\n-\t\tif ! pick_one -n $sha1\n-\t\tthen\n-\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n-\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\tfi\n-\t\tcase \"$(peek_next_command)\" in\n-\t\tsquash|s|fixup|f)\n-\t\t\t# This is an intermediate commit; its message will only be\n-\t\t\t# used in case of trouble.  So use the long version:\n-\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n-\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\t# This is the final command of this squash/fixup group\n-\t\t\tif test -f \"$fixup_msg\"\n-\t\t\tthen\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\telse\n-\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n-\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\tfi\n-\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n-\t\t\t;;\n-\t\tesac\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tx|\"exec\")\n-\t\tread -r command rest < \"$todo\"\n-\t\tmark_action_done\n-\t\teval_gettextln \"Executing: \\$rest\"\n-\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n-\t\tstatus=$?\n-\t\t# Run in subshell because require_clean_work_tree can die.\n-\t\tdirty=f\n-\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n-\t\tif test \"$status\" -ne 0\n-\t\tthen\n-\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n-\t\t\ttest \"$dirty\" = f ||\n-\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n-\n-\t\t\twarn \"$(gettext \"\\\n-You can fix the problem, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\tif test $status -eq 127\t\t# command not found\n-\t\t\tthen\n-\t\t\t\tstatus=1\n-\t\t\tfi\n-\t\t\texit \"$status\"\n-\t\telif test \"$dirty\" = t\n-\t\tthen\n-\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n-\t\t\twarn \"$(eval_gettext \"\\\n-Execution succeeded: \\$rest\n-but left changes to the index and/or the working tree\n-Commit or stash your changes, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\texit 1\n-\t\tfi\n-\t\t;;\n-\t*)\n-\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n-\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n-\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n-\t\tthen\n-\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n-\t\telse\n-\t\t\tdie \"$fixtodo\"\n-\t\tfi\n-\t\t;;\n-\tesac\n-\ttest -s \"$todo\" && return\n-\n-\tcomment_for_reflog finish &&\n-\tnewhead=$(git rev-parse HEAD) &&\n-\tcase $head_name in\n-\trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n-\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n-\t\tgit symbolic-ref \\\n-\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n-\t\t  HEAD $head_name\n-\t\t;;\n-\tesac && {\n-\t\ttest ! -f \"$state_dir\"/verbose ||\n-\t\t\tgit diff-tree --stat $orig_head..HEAD\n-\t} &&\n-\t{\n-\t\ttest -s \"$rewritten_list\" &&\n-\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n-\t\ttrue # we don't care if this copying failed\n-\t} &&\n-\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n-\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n-\t\t\"$hook\" rebase < \"$rewritten_list\"\n-\t\ttrue # we don't care if this hook failed\n-\tfi &&\n-\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n-\n-\treturn 1 # not failure; just to break the do_rest loop\n-}\n-\n-# can only return 0, when the infinite loop breaks\n-do_rest () {\n-\twhile :\n-\tdo\n-\t\tdo_next || break\n-\tdone\n-}\n-\n expand_todo_ids() {\n \tgit rebase--helper --expand-ids\n }\n@@ -761,77 +131,13 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\t# do we have anything to commit?\n-\t\tif git diff-index --cached --quiet HEAD --\n-\t\tthen\n-\t\t\t# Nothing to commit -- skip this commit\n-\n-\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n-\t\telse\n-\t\t\tif ! test -f \"$author_script\"\n-\t\t\tthen\n-\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\t\t\t\tdie \"$(eval_gettext \"\\\n-You have staged changes in your working tree.\n-If these changes are meant to be\n-squashed into the previous commit, run:\n-\n-  git commit --amend \\$gpg_sign_opt_quoted\n-\n-If they are meant to go into a new commit, run:\n-\n-  git commit \\$gpg_sign_opt_quoted\n-\n-In both cases, once you're done, continue with:\n-\n-  git rebase --continue\n-\")\"\n-\t\t\tfi\n-\t\t\t. \"$author_script\" ||\n-\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n-\t\t\tif test -f \"$amend\"\n-\t\t\tthen\n-\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n-\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n-\t\t\t\tdie \"$(gettext \"\\\n-You have uncommitted changes in your working tree. Please commit them\n-first and then run 'git rebase --continue' again.\")\"\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\telse\n-\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\tfi\n-\t\tfi\n-\n-\t\tif test -r \"$state_dir\"/stopped-sha\n-\t\tthen\n-\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n-\t\tfi\n-\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tedit-todo)\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n@@ -945,18 +251,14 @@ EOF\n \n \texpand_todo_ids\n \n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\ttest -n \"$force_rebase\" ||\n \tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n \tdie \"Could not skip unnecessary pick commands\"\n \n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n-\tdo_rest\n+\trequire_clean_work_tree \"rebase\"\n+\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t     --continue\n }\n \n git_rebase__interactive () {\n@@ -979,91 +281,3 @@ git_rebase__interactive () {\n \n \tcomplete_action\n }\n-\n-git_rebase__interactive__preserve_merges () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tif test -z \"$rebase_root\"\n-\tthen\n-\t\tmkdir \"$rewritten\" &&\n-\t\tfor c in $(git merge-base --all $orig_head $upstream)\n-\t\tdo\n-\t\t\techo $onto > \"$rewritten\"/$c ||\n-\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\t\tdone\n-\telse\n-\t\tmkdir \"$rewritten\" &&\n-\t\techo $onto > \"$rewritten\"/root ||\n-\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\tfi\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tformat=$(git config --get rebase.instructionFormat)\n-\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n-\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n-\t\t--reverse --left-right --topo-order \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n-\t\tsed -n \"s/^>//p\" |\n-\twhile read -r sha1 rest\n-\tdo\n-\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n-\t\tthen\n-\t\t\tcomment_out=\"$comment_char \"\n-\t\telse\n-\t\t\tcomment_out=\n-\t\tfi\n-\n-\t\tif test -z \"$rebase_root\"\n-\t\tthen\n-\t\t\tpreserve=t\n-\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n-\t\t\tdo\n-\t\t\t\tif test -f \"$rewritten\"/$p\n-\t\t\t\tthen\n-\t\t\t\t\tpreserve=f\n-\t\t\t\tfi\n-\t\t\tdone\n-\t\telse\n-\t\t\tpreserve=f\n-\t\tfi\n-\t\tif test f = \"$preserve\"\n-\t\tthen\n-\t\t\ttouch \"$rewritten\"/$sha1\n-\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n-\t\tfi\n-\tdone\n-\n-\t# Watch for commits that been dropped by --cherry-pick\n-\tmkdir \"$dropped\"\n-\t# Save all non-cherry-picked changes\n-\tgit rev-list $revisions --left-right --cherry-pick | \\\n-\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n-\t# Now all commits and note which ones are missing in\n-\t# not-cherry-picks and hence being dropped\n-\tgit rev-list $revisions |\n-\twhile read rev\n-\tdo\n-\t\tif test -f \"$rewritten\"/$rev &&\n-\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n-\t\tthen\n-\t\t\t# Use -f2 because if rev-list is telling us this commit is\n-\t\t\t# not worthwhile, we don't want to track its multiple heads,\n-\t\t\t# just the history of its first-parent for others that will\n-\t\t\t# be rebasing on top of it\n-\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n-\t\t\tsha1=$(git rev-list -1 $rev)\n-\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n-\t\t\trm \"$rewritten\"/$rev\n-\t\tfi\n-\tdone\n-\n-\tcomplete_action\n-}\n-- \n2.16.1\n\n"},{"id":"348424","messageId":"20180524114958.26521-4-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 3/4] rebase: use the new git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-24T11:49:57Z","receivedAt":"2018-05-24T11:50:41Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Creates a new type of rebase, \"preserve-merges\", used when rebase is called with\n-p.\n\nBefore that, the type for preserve-merges was \"interactive\", and some places of\nthis script compared $type to \"interactive\". Instead, the code now checks if\n$interactive_rebase is empty or not, as it is set to \"explicit\" when calling an\ninteractive rebase (and, possibly, one of its submodes), and \"implied\" when\ncalling one of its submodes (eg. preserve-merges) *without* interactive rebase.\n\nIt also detects the presence of the directory \"$merge_dir\"/rewritten left by the\npreserve-merges script when calling rebase --continue, --skip, etc., and, if it\nexists, sets the rebase mode to preserve-merges. In this case,\ninteractive_rebase is set to \"explicit\", as \"implied\" would break some tests.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase.sh | 32 +++++++++++++++++++++++++-------\n 1 file changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 40be59ecc..19bdebb48 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -207,7 +207,14 @@ run_specific_rebase () {\n \t\tautosquash=\n \tfi\n \t. git-rebase--$type\n-\tgit_rebase__$type${preserve_merges:+__preserve_merges}\n+\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\tgit_rebase__$type\n+\telse\n+\t\tgit_rebase__preserve_merges\n+\tfi\n+\n \tret=$?\n \tif test $ret -eq 0\n \tthen\n@@ -239,7 +246,12 @@ then\n \tstate_dir=\"$apply_dir\"\n elif test -d \"$merge_dir\"\n then\n-\tif test -f \"$merge_dir\"/interactive\n+\tif test -d \"$merge_dir\"/rewritten\n+\tthen\n+\t\ttype=preserve-merges\n+\t\tinteractive_rebase=explicit\n+\t\tpreserve_merges=t\n+\telif test -f \"$merge_dir\"/interactive\n \tthen\n \t\ttype=interactive\n \t\tinteractive_rebase=explicit\n@@ -402,14 +414,14 @@ if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"$(gettext \"No rebase in progress?\")\"\n \t# Only interactive rebase uses detailed reflog messages\n-\tif test \"$type\" = interactive && test \"$GIT_REFLOG_ACTION\" = rebase\n+\tif test -n \"$interactive_rebase\" && test \"$GIT_REFLOG_ACTION\" = rebase\n \tthen\n \t\tGIT_REFLOG_ACTION=\"rebase -i ($action)\"\n \t\texport GIT_REFLOG_ACTION\n \tfi\n fi\n \n-if test \"$action\" = \"edit-todo\" && test \"$type\" != \"interactive\"\n+if test \"$action\" = \"edit-todo\" && test -z \"$interactive_rebase\"\n then\n \tdie \"$(gettext \"The --edit-todo action can only be used during interactive rebase.\")\"\n fi\n@@ -487,7 +499,13 @@ fi\n \n if test -n \"$interactive_rebase\"\n then\n-\ttype=interactive\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\ttype=interactive\n+\telse\n+\t\ttype=preserve-merges\n+\tfi\n+\n \tstate_dir=\"$merge_dir\"\n elif test -n \"$do_merge\"\n then\n@@ -647,7 +665,7 @@ require_clean_work_tree \"rebase\" \"$(gettext \"Please commit or stash them.\")\"\n # but this should be done only when upstream and onto are the same\n # and if this is not an interactive rebase.\n mb=$(git merge-base \"$onto\" \"$orig_head\")\n-if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n+if test -z \"$interactive_rebase\" && test \"$upstream\" = \"$onto\" &&\n \ttest \"$mb\" = \"$onto\" && test -z \"$restrict_revision\" &&\n \t# linear history?\n \t! (git rev-list --parents \"$onto\"..\"$orig_head\" | sane_grep \" .* \") > /dev/null\n@@ -691,7 +709,7 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n-test \"$type\" = interactive && run_specific_rebase\n+test -n \"$interactive_rebase\" && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"$(gettext \"First, rewinding head to replay your work on top of it...\")\"\n-- \n2.16.1\n\n"},{"id":"348425","messageId":"20180524114958.26521-3-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-24T11:49:56Z","receivedAt":"2018-05-24T11:50:42Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This removes the code coming from git-rebase--interactive.sh that is not needed\nby preserve-merges.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--preserve-merges.sh | 65 +++---------------------------------------\n 1 file changed, 4 insertions(+), 61 deletions(-)\n\ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nindex 2f4941d0f..c51c7828e 100644\n--- a/git-rebase--preserve-merges.sh\n+++ b/git-rebase--preserve-merges.sh\n@@ -1,12 +1,8 @@\n-# This shell script fragment is sourced by git-rebase to implement\n-# its interactive mode.  \"git rebase --interactive\" makes it easy\n-# to fix up commits in the middle of a series and rearrange commits.\n+# This shell script fragment is sourced by git-rebase to implement its\n+# preserve-merges mode.\n #\n # Copyright (c) 2006 Johannes E. Schindelin\n #\n-# The original idea comes from Eric W. Biederman, in\n-# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n-#\n # The file containing rebase commands, comments, and empty lines.\n # This file is created by \"git rebase -i\" then edited by the user.  As\n # the lines are processed, they are removed from the front of this\n@@ -287,17 +283,7 @@ pick_one () {\n \t\tempty_args=\"--allow-empty\"\n \tfi\n \n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n+\tpick_one_preserving_merges \"$@\"\n }\n \n pick_one_preserving_merges () {\n@@ -761,11 +747,6 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\t# do we have anything to commit?\n \t\tif git diff-index --cached --quiet HEAD --\n \t\tthen\n@@ -824,12 +805,6 @@ first and then run 'git rebase --continue' again.\")\"\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\tdo_rest\n \t\treturn 0\n \t\t;;\n@@ -944,43 +919,11 @@ EOF\n \t}\n \n \texpand_todo_ids\n-\n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n-\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n-\tdie \"Could not skip unnecessary pick commands\"\n-\n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n \tdo_rest\n }\n \n-git_rebase__interactive () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n-\t\t${rebase_merges:+--rebase-merges} \\\n-\t\t${rebase_cousins:+--rebase-cousins} \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n-\tdie \"$(gettext \"Could not generate todo list\")\"\n-\n-\tcomplete_action\n-}\n-\n-git_rebase__interactive__preserve_merges () {\n+git_rebase__preserve_merges () {\n \tinitiate_action \"$action\"\n \tret=$?\n \tif test $ret = 0; then\n-- \n2.16.1\n\n"},{"id":"348426","messageId":"20180524114958.26521-2-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v3 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-24T11:49:55Z","receivedAt":"2018-05-24T11:50:45Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This duplicates git-rebase--interactive.sh to\ngit-rebase--preserve-merges.sh. This is done to split -p from -i. No\nmodifications are made to this file here, but any code that is not used by -p\nwill be stripped in the next commit.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--preserve-merges.sh | 1069 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 1072 insertions(+)\n create mode 100644 git-rebase--preserve-merges.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 833ef3b0b..ef4925485 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -117,6 +117,7 @@\n /git-rebase--helper\n /git-rebase--interactive\n /git-rebase--merge\n+/git-rebase--preserve-merges\n /git-receive-pack\n /git-reflog\n /git-remote\ndiff --git a/Makefile b/Makefile\nindex 50da82b01..810a0d0f4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -582,6 +582,7 @@ SCRIPT_LIB += git-mergetool--lib\n SCRIPT_LIB += git-parse-remote\n SCRIPT_LIB += git-rebase--am\n SCRIPT_LIB += git-rebase--interactive\n+SCRIPT_LIB += git-rebase--preserve-merges\n SCRIPT_LIB += git-rebase--merge\n SCRIPT_LIB += git-sh-setup\n SCRIPT_LIB += git-sh-i18n\n@@ -2271,6 +2272,7 @@ LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH)\n LOCALIZED_SH += git-parse-remote.sh\n LOCALIZED_SH += git-rebase--interactive.sh\n+LOCALIZED_SH += git-rebase--preserve-merges.sh\n LOCALIZED_SH += git-sh-setup.sh\n LOCALIZED_PERL = $(SCRIPT_PERL)\n \ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nnew file mode 100644\nindex 000000000..2f4941d0f\n--- /dev/null\n+++ b/git-rebase--preserve-merges.sh\n@@ -0,0 +1,1069 @@\n+# This shell script fragment is sourced by git-rebase to implement\n+# its interactive mode.  \"git rebase --interactive\" makes it easy\n+# to fix up commits in the middle of a series and rearrange commits.\n+#\n+# Copyright (c) 2006 Johannes E. Schindelin\n+#\n+# The original idea comes from Eric W. Biederman, in\n+# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n+#\n+# The file containing rebase commands, comments, and empty lines.\n+# This file is created by \"git rebase -i\" then edited by the user.  As\n+# the lines are processed, they are removed from the front of this\n+# file and written to the tail of $done.\n+todo=\"$state_dir\"/git-rebase-todo\n+\n+# The rebase command lines that have already been processed.  A line\n+# is moved here when it is first handled, before any associated user\n+# actions.\n+done=\"$state_dir\"/done\n+\n+# The commit message that is planned to be used for any changes that\n+# need to be committed following a user interaction.\n+msg=\"$state_dir\"/message\n+\n+# The file into which is accumulated the suggested commit message for\n+# squash/fixup commands.  When the first of a series of squash/fixups\n+# is seen, the file is created and the commit message from the\n+# previous commit and from the first squash/fixup commit are written\n+# to it.  The commit message for each subsequent squash/fixup commit\n+# is appended to the file as it is processed.\n+#\n+# The first line of the file is of the form\n+#     # This is a combination of $count commits.\n+# where $count is the number of commits whose messages have been\n+# written to the file so far (including the initial \"pick\" commit).\n+# Each time that a commit message is processed, this line is read and\n+# updated.  It is deleted just before the combined commit is made.\n+squash_msg=\"$state_dir\"/message-squash\n+\n+# If the current series of squash/fixups has not yet included a squash\n+# command, then this file exists and holds the commit message of the\n+# original \"pick\" commit.  (If the series ends without a \"squash\"\n+# command, then this can be used as the commit message of the combined\n+# commit without opening the editor.)\n+fixup_msg=\"$state_dir\"/message-fixup\n+\n+# $rewritten is the name of a directory containing files for each\n+# commit that is reachable by at least one merge base of $head and\n+# $upstream. They are not necessarily rewritten, but their children\n+# might be.  This ensures that commits on merged, but otherwise\n+# unrelated side branches are left alone. (Think \"X\" in the man page's\n+# example.)\n+rewritten=\"$state_dir\"/rewritten\n+\n+dropped=\"$state_dir\"/dropped\n+\n+end=\"$state_dir\"/end\n+msgnum=\"$state_dir\"/msgnum\n+\n+# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE that will be used for the commit that is currently\n+# being rebased.\n+author_script=\"$state_dir\"/author-script\n+\n+# When an \"edit\" rebase command is being processed, the SHA1 of the\n+# commit to be edited is recorded in this file.  When \"git rebase\n+# --continue\" is executed, if there are any staged changes then they\n+# will be amended to the HEAD commit, but only provided the HEAD\n+# commit is still the commit to be edited.  When any other rebase\n+# command is processed, this file is deleted.\n+amend=\"$state_dir\"/amend\n+\n+# For the post-rewrite hook, we make a list of rewritten commits and\n+# their new sha1s.  The rewritten-pending list keeps the sha1s of\n+# commits that have been processed, but not committed yet,\n+# e.g. because they are waiting for a 'squash' command.\n+rewritten_list=\"$state_dir\"/rewritten-list\n+rewritten_pending=\"$state_dir\"/rewritten-pending\n+\n+# Work around Git for Windows' Bash whose \"read\" does not strip CRLF\n+# and leaves CR at the end instead.\n+cr=$(printf \"\\015\")\n+\n+strategy_args=${strategy:+--strategy=$strategy}\n+test -n \"$strategy_opts\" &&\n+eval '\n+\tfor strategy_opt in '\"$strategy_opts\"'\n+\tdo\n+\t\tstrategy_args=\"$strategy_args -X$(git rev-parse --sq-quote \"${strategy_opt#--}\")\"\n+\tdone\n+'\n+\n+GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n+export GIT_CHERRY_PICK_HELP\n+\n+comment_char=$(git config --get core.commentchar 2>/dev/null)\n+case \"$comment_char\" in\n+'' | auto)\n+\tcomment_char=\"#\"\n+\t;;\n+?)\n+\t;;\n+*)\n+\tcomment_char=$(echo \"$comment_char\" | cut -c1)\n+\t;;\n+esac\n+\n+warn () {\n+\tprintf '%s\\n' \"$*\" >&2\n+}\n+\n+# Output the commit message for the specified commit.\n+commit_message () {\n+\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n+}\n+\n+orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n+\n+comment_for_reflog () {\n+\tcase \"$orig_reflog_action\" in\n+\t''|rebase*)\n+\t\tGIT_REFLOG_ACTION=\"rebase -i ($1)\"\n+\t\texport GIT_REFLOG_ACTION\n+\t\t;;\n+\tesac\n+}\n+\n+last_count=\n+mark_action_done () {\n+\tsed -e 1q < \"$todo\" >> \"$done\"\n+\tsed -e 1d < \"$todo\" >> \"$todo\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tnew_count=$(( $(git stripspace --strip-comments <\"$done\" | wc -l) ))\n+\techo $new_count >\"$msgnum\"\n+\ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n+\techo $total >\"$end\"\n+\tif test \"$last_count\" != \"$new_count\"\n+\tthen\n+\t\tlast_count=$new_count\n+\t\teval_gettext \"Rebasing (\\$new_count/\\$total)\"; printf \"\\r\"\n+\t\ttest -z \"$verbose\" || echo\n+\tfi\n+}\n+\n+# Put the last action marked done at the beginning of the todo list\n+# again. If there has not been an action marked done yet, leave the list of\n+# items on the todo list unchanged.\n+reschedule_last_action () {\n+\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n+\tsed -e \\$d <\"$done\" >\"$done\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tmv -f \"$done\".new \"$done\"\n+}\n+\n+append_todo_help () {\n+\tgettext \"\n+Commands:\n+p, pick <commit> = use commit\n+r, reword <commit> = use commit, but edit the commit message\n+e, edit <commit> = use commit, but stop for amending\n+s, squash <commit> = use commit, but meld into previous commit\n+f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n+x, exec <commit> = run command (the rest of the line) using shell\n+d, drop <commit> = remove commit\n+l, label <label> = label current HEAD with a name\n+t, reset <label> = reset HEAD to a label\n+m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n+.       create a merge commit using the original merge commit's\n+.       message (or the oneline, if no original merge commit was\n+.       specified). Use -c <commit> to reword the commit message.\n+\n+These lines can be re-ordered; they are executed from top to bottom.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test $(get_missing_commit_check_level) = error\n+\tthen\n+\t\tgettext \"\n+Do not remove any line. Use 'drop' explicitly to remove a commit.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\telse\n+\t\tgettext \"\n+If you remove a line here THAT COMMIT WILL BE LOST.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\tfi\n+}\n+\n+make_patch () {\n+\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n+\tcase \"$sha1_and_parents\" in\n+\t?*' '?*' '?*)\n+\t\tgit diff --cc $sha1_and_parents\n+\t\t;;\n+\t?*' '?*)\n+\t\tgit diff-tree -p \"$1^!\"\n+\t\t;;\n+\t*)\n+\t\techo \"Root commit\"\n+\t\t;;\n+\tesac > \"$state_dir\"/patch\n+\ttest -f \"$msg\" ||\n+\t\tcommit_message \"$1\" > \"$msg\"\n+\ttest -f \"$author_script\" ||\n+\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n+}\n+\n+die_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch \"$1\"\n+\tdie \"$2\"\n+}\n+\n+exit_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch $1\n+\tgit rev-parse --verify HEAD > \"$amend\"\n+\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\twarn \"$(eval_gettext \"\\\n+You can amend the commit now, with\n+\n+\tgit commit --amend \\$gpg_sign_opt_quoted\n+\n+Once you are satisfied with your changes, run\n+\n+\tgit rebase --continue\")\"\n+\twarn\n+\texit $2\n+}\n+\n+die_abort () {\n+\tapply_autostash\n+\trm -rf \"$state_dir\"\n+\tdie \"$1\"\n+}\n+\n+has_action () {\n+\ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n+}\n+\n+is_empty_commit() {\n+\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n+\t\tsha1=$1\n+\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n+\t}\n+\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n+\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n+\ttest \"$tree\" = \"$ptree\"\n+}\n+\n+is_merge_commit()\n+{\n+\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n+}\n+\n+# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE exported from the current environment.\n+do_with_author () {\n+\t(\n+\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n+\t\t\"$@\"\n+\t)\n+}\n+\n+git_sequence_editor () {\n+\tif test -z \"$GIT_SEQUENCE_EDITOR\"\n+\tthen\n+\t\tGIT_SEQUENCE_EDITOR=\"$(git config sequence.editor)\"\n+\t\tif [ -z \"$GIT_SEQUENCE_EDITOR\" ]\n+\t\tthen\n+\t\t\tGIT_SEQUENCE_EDITOR=\"$(git var GIT_EDITOR)\" || return $?\n+\t\tfi\n+\tfi\n+\n+\teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n+}\n+\n+pick_one () {\n+\tff=--ff\n+\n+\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n+\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n+\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n+\n+\tif is_empty_commit \"$sha1\"\n+\tthen\n+\t\tempty_args=\"--allow-empty\"\n+\tfi\n+\n+\ttest -d \"$rewritten\" &&\n+\t\tpick_one_preserving_merges \"$@\" && return\n+\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n+\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n+\n+\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n+\t# previous task so this commit is not lost.\n+\tret=$?\n+\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n+\treturn $ret\n+}\n+\n+pick_one_preserving_merges () {\n+\tfast_forward=t\n+\tcase \"$1\" in\n+\t-n)\n+\t\tfast_forward=f\n+\t\tsha1=$2\n+\t\t;;\n+\t*)\n+\t\tsha1=$1\n+\t\t;;\n+\tesac\n+\tsha1=$(git rev-parse $sha1)\n+\n+\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n+\tthen\n+\t\twhile read current_commit\n+\t\tdo\n+\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n+\t\tdone <\"$state_dir\"/current-commit\n+\t\trm \"$state_dir\"/current-commit ||\n+\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n+\tfi\n+\n+\techo $sha1 >> \"$state_dir\"/current-commit\n+\n+\t# rewrite parents; if none were rewritten, we can fast-forward.\n+\tnew_parents=\n+\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n+\tif test \"$pend\" = \" \"\n+\tthen\n+\t\tpend=\" root\"\n+\tfi\n+\twhile [ \"$pend\" != \"\" ]\n+\tdo\n+\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n+\t\tpend=\"${pend# $p}\"\n+\n+\t\tif test -f \"$rewritten\"/$p\n+\t\tthen\n+\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n+\n+\t\t\t# If the todo reordered commits, and our parent is marked for\n+\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n+\t\t\t# drop it on top of the current HEAD\n+\t\t\tif test -z \"$new_p\"\n+\t\t\tthen\n+\t\t\t\tnew_p=$(git rev-parse HEAD)\n+\t\t\tfi\n+\n+\t\t\ttest $p != $new_p && fast_forward=f\n+\t\t\tcase \"$new_parents\" in\n+\t\t\t*$new_p*)\n+\t\t\t\t;; # do nothing; that parent is already there\n+\t\t\t*)\n+\t\t\t\tnew_parents=\"$new_parents $new_p\"\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\telse\n+\t\t\tif test -f \"$dropped\"/$p\n+\t\t\tthen\n+\t\t\t\tfast_forward=f\n+\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n+\t\t\t\ttest -z \"$replacement\" && replacement=root\n+\t\t\t\tpend=\" $replacement$pend\"\n+\t\t\telse\n+\t\t\t\tnew_parents=\"$new_parents $p\"\n+\t\t\tfi\n+\t\tfi\n+\tdone\n+\tcase $fast_forward in\n+\tt)\n+\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n+\t\toutput git reset --hard $sha1 ||\n+\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n+\t\t;;\n+\tf)\n+\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n+\n+\t\tif [ \"$1\" != \"-n\" ]\n+\t\tthen\n+\t\t\t# detach HEAD to current parent\n+\t\t\toutput git checkout $first_parent 2> /dev/null ||\n+\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n+\t\tfi\n+\n+\t\tcase \"$new_parents\" in\n+\t\t' '*' '*)\n+\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n+\n+\t\t\t# redo merge\n+\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n+\t\t\teval \"$author_script_content\"\n+\t\t\tmsg_content=\"$(commit_message $sha1)\"\n+\t\t\t# No point in merging the first parent, that's HEAD\n+\t\t\tnew_parents=${new_parents# $first_parent}\n+\t\t\tmerge_args=\"--no-log --no-ff\"\n+\t\t\tif ! do_with_author output eval \\\n+\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n+\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n+\t\t\t\t\"$strategy_args\" \\\n+\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n+\t\t\t\t\"$new_parents\"\n+\t\t\tthen\n+\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n+\t\t\tfi\n+\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n+\t\t\t\t$allow_empty_message \\\n+\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t\"$strategy_args\" \"$@\" ||\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n+\t\t\t;;\n+\t\tesac\n+\t\t;;\n+\tesac\n+}\n+\n+this_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"This is the commit message #\\${n}:\"\n+}\n+\n+skip_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"The commit message #\\${n} will be skipped:\"\n+}\n+\n+update_squash_messages () {\n+\tif test -f \"$squash_msg\"; then\n+\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n+\t\tcount=$(($(sed -n \\\n+\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n+\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n+\t\t\t\t\"This is a combination of \\$count commit.\" \\\n+\t\t\t\t\"This is a combination of \\$count commits.\" \\\n+\t\t\t\t$count)\"\n+\t\t\tsed -e 1d -e '2,/^./{\n+\t\t\t\t/^$/d\n+\t\t\t}' <\"$squash_msg\".bak\n+\t\t} >\"$squash_msg\"\n+\telse\n+\t\tcommit_message HEAD >\"$fixup_msg\" ||\n+\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n+\t\tcount=2\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n+\t\t\techo\n+\t\t\tcat \"$fixup_msg\"\n+\t\t} >\"$squash_msg\"\n+\tfi\n+\tcase $1 in\n+\tsquash)\n+\t\trm -f \"$fixup_msg\"\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n+\t\techo\n+\t\tcommit_message $2\n+\t\t;;\n+\tfixup)\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n+\t\techo\n+\t\t# Change the space after the comment character to TAB:\n+\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n+\t\t;;\n+\tesac >>\"$squash_msg\"\n+}\n+\n+peek_next_command () {\n+\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n+}\n+\n+# A squash/fixup has failed.  Prepare the long version of the squash\n+# commit message, then die_with_patch.  This code path requires the\n+# user to edit the combined commit message for all commits that have\n+# been squashed/fixedup so far.  So also erase the old squash\n+# messages, effectively causing the combined commit to be used as the\n+# new basis for any further squash/fixups.  Args: sha1 rest\n+die_failed_squash() {\n+\tsha1=$1\n+\trest=$2\n+\tmv \"$squash_msg\" \"$msg\" || exit\n+\trm -f \"$fixup_msg\"\n+\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n+\twarn\n+\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tdie_with_patch $sha1 \"\"\n+}\n+\n+flush_rewritten_pending() {\n+\ttest -s \"$rewritten_pending\" || return\n+\tnewsha1=\"$(git rev-parse HEAD^0)\"\n+\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n+\trm -f \"$rewritten_pending\"\n+}\n+\n+record_in_rewritten() {\n+\toldsha1=\"$(git rev-parse $1)\"\n+\techo \"$oldsha1\" >> \"$rewritten_pending\"\n+\n+\tcase \"$(peek_next_command)\" in\n+\tsquash|s|fixup|f)\n+\t\t;;\n+\t*)\n+\t\tflush_rewritten_pending\n+\t\t;;\n+\tesac\n+}\n+\n+do_pick () {\n+\tsha1=$1\n+\trest=$2\n+\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n+\tthen\n+\t\t# Set the correct commit message and author info on the\n+\t\t# sentinel root before cherry-picking the original changes\n+\t\t# without committing (-n).  Finally, update the sentinel again\n+\t\t# to include these changes.  If the cherry-pick results in a\n+\t\t# conflict, this means our behaviour is similar to a standard\n+\t\t# failed cherry-pick during rebase, with a dirty index to\n+\t\t# resolve before manually running git commit --amend then git\n+\t\t# rebase --continue.\n+\t\tgit commit --allow-empty --allow-empty-message --amend \\\n+\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n+\t\t\tpick_one -n $sha1 &&\n+\t\t\tgit commit --allow-empty --allow-empty-message \\\n+\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n+\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n+\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\telse\n+\t\tpick_one $sha1 ||\n+\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tfi\n+}\n+\n+do_next () {\n+\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n+\tread -r command sha1 rest < \"$todo\"\n+\tcase \"$command\" in\n+\t\"$comment_char\"*|''|noop|drop|d)\n+\t\tmark_action_done\n+\t\t;;\n+\t\"$cr\")\n+\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n+\t\tmark_action_done\n+\t\t;;\n+\tpick|p)\n+\t\tcomment_for_reflog pick\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\treword|r)\n+\t\tcomment_for_reflog reword\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n+\t\t\t$allow_empty_message || {\n+\t\t\twarn \"$(eval_gettext \"\\\n+Could not amend commit after successfully picking \\$sha1... \\$rest\n+This is most likely due to an empty commit message, or the pre-commit hook\n+failed. If the pre-commit hook failed, you may need to resolve the issue before\n+you are able to reword the commit.\")\"\n+\t\t\texit_with_patch $sha1 1\n+\t\t}\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tedit|e)\n+\t\tcomment_for_reflog edit\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n+\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n+\t\texit_with_patch $sha1 0\n+\t\t;;\n+\tsquash|s|fixup|f)\n+\t\tcase \"$command\" in\n+\t\tsquash|s)\n+\t\t\tsquash_style=squash\n+\t\t\t;;\n+\t\tfixup|f)\n+\t\t\tsquash_style=fixup\n+\t\t\t;;\n+\t\tesac\n+\t\tcomment_for_reflog $squash_style\n+\n+\t\ttest -f \"$done\" && has_action \"$done\" ||\n+\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n+\n+\t\tmark_action_done\n+\t\tupdate_squash_messages $squash_style $sha1\n+\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n+\t\techo \"$author_script_content\" > \"$author_script\"\n+\t\teval \"$author_script_content\"\n+\t\tif ! pick_one -n $sha1\n+\t\tthen\n+\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n+\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\tfi\n+\t\tcase \"$(peek_next_command)\" in\n+\t\tsquash|s|fixup|f)\n+\t\t\t# This is an intermediate commit; its message will only be\n+\t\t\t# used in case of trouble.  So use the long version:\n+\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n+\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# This is the final command of this squash/fixup group\n+\t\t\tif test -f \"$fixup_msg\"\n+\t\t\tthen\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\telse\n+\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n+\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\tfi\n+\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n+\t\t\t;;\n+\t\tesac\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tx|\"exec\")\n+\t\tread -r command rest < \"$todo\"\n+\t\tmark_action_done\n+\t\teval_gettextln \"Executing: \\$rest\"\n+\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n+\t\tstatus=$?\n+\t\t# Run in subshell because require_clean_work_tree can die.\n+\t\tdirty=f\n+\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n+\t\tif test \"$status\" -ne 0\n+\t\tthen\n+\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n+\t\t\ttest \"$dirty\" = f ||\n+\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n+\n+\t\t\twarn \"$(gettext \"\\\n+You can fix the problem, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\tif test $status -eq 127\t\t# command not found\n+\t\t\tthen\n+\t\t\t\tstatus=1\n+\t\t\tfi\n+\t\t\texit \"$status\"\n+\t\telif test \"$dirty\" = t\n+\t\tthen\n+\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n+\t\t\twarn \"$(eval_gettext \"\\\n+Execution succeeded: \\$rest\n+but left changes to the index and/or the working tree\n+Commit or stash your changes, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\texit 1\n+\t\tfi\n+\t\t;;\n+\t*)\n+\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n+\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n+\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n+\t\tthen\n+\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n+\t\telse\n+\t\t\tdie \"$fixtodo\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\ttest -s \"$todo\" && return\n+\n+\tcomment_for_reflog finish &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\tcase $head_name in\n+\trefs/*)\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n+\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n+\t\tgit symbolic-ref \\\n+\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n+\t\t  HEAD $head_name\n+\t\t;;\n+\tesac && {\n+\t\ttest ! -f \"$state_dir\"/verbose ||\n+\t\t\tgit diff-tree --stat $orig_head..HEAD\n+\t} &&\n+\t{\n+\t\ttest -s \"$rewritten_list\" &&\n+\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n+\t\ttrue # we don't care if this copying failed\n+\t} &&\n+\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n+\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n+\t\t\"$hook\" rebase < \"$rewritten_list\"\n+\t\ttrue # we don't care if this hook failed\n+\tfi &&\n+\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n+\n+\treturn 1 # not failure; just to break the do_rest loop\n+}\n+\n+# can only return 0, when the infinite loop breaks\n+do_rest () {\n+\twhile :\n+\tdo\n+\t\tdo_next || break\n+\tdone\n+}\n+\n+expand_todo_ids() {\n+\tgit rebase--helper --expand-ids\n+}\n+\n+collapse_todo_ids() {\n+\tgit rebase--helper --shorten-ids\n+}\n+\n+# Switch to the branch in $into and notify it in the reflog\n+checkout_onto () {\n+\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $onto_name\"\n+\toutput git checkout $onto || die_abort \"$(gettext \"could not detach HEAD\")\"\n+\tgit update-ref ORIG_HEAD $orig_head\n+}\n+\n+get_missing_commit_check_level () {\n+\tcheck_level=$(git config --get rebase.missingCommitsCheck)\n+\tcheck_level=${check_level:-ignore}\n+\t# Don't be case sensitive\n+\tprintf '%s' \"$check_level\" | tr 'A-Z' 'a-z'\n+}\n+\n+# Initiate an action. If the cannot be any\n+# further action it  may exec a command\n+# or exit and not return.\n+#\n+# TODO: Consider a cleaner return model so it\n+# never exits and always return 0 if process\n+# is complete.\n+#\n+# Parameter 1 is the action to initiate.\n+#\n+# Returns 0 if the action was able to complete\n+# and if 1 if further processing is required.\n+initiate_action () {\n+\tcase \"$1\" in\n+\tcontinue)\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\t# do we have anything to commit?\n+\t\tif git diff-index --cached --quiet HEAD --\n+\t\tthen\n+\t\t\t# Nothing to commit -- skip this commit\n+\n+\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n+\t\telse\n+\t\t\tif ! test -f \"$author_script\"\n+\t\t\tthen\n+\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\t\t\t\tdie \"$(eval_gettext \"\\\n+You have staged changes in your working tree.\n+If these changes are meant to be\n+squashed into the previous commit, run:\n+\n+  git commit --amend \\$gpg_sign_opt_quoted\n+\n+If they are meant to go into a new commit, run:\n+\n+  git commit \\$gpg_sign_opt_quoted\n+\n+In both cases, once you're done, continue with:\n+\n+  git rebase --continue\n+\")\"\n+\t\t\tfi\n+\t\t\t. \"$author_script\" ||\n+\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n+\t\t\tif test -f \"$amend\"\n+\t\t\tthen\n+\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n+\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n+\t\t\t\tdie \"$(gettext \"\\\n+You have uncommitted changes in your working tree. Please commit them\n+first and then run 'git rebase --continue' again.\")\"\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\telse\n+\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\tfi\n+\t\tfi\n+\n+\t\tif test -r \"$state_dir\"/stopped-sha\n+\t\tthen\n+\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n+\t\tfi\n+\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tskip)\n+\t\tgit rerere clear\n+\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tedit-todo)\n+\t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n+\t\tmv -f \"$todo\".new \"$todo\"\n+\t\tcollapse_todo_ids\n+\t\tappend_todo_help\n+\t\tgettext \"\n+You are editing the todo file of an ongoing interactive rebase.\n+To continue rebase after editing, run:\n+    git rebase --continue\n+\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\t\tgit_sequence_editor \"$todo\" ||\n+\t\t\tdie \"$(gettext \"Could not execute editor\")\"\n+\t\texpand_todo_ids\n+\n+\t\texit\n+\t\t;;\n+\tshow-current-patch)\n+\t\texec git show REBASE_HEAD --\n+\t\t;;\n+\t*)\n+\t\treturn 1 # continue\n+\t\t;;\n+\tesac\n+}\n+\n+setup_reflog_action () {\n+\tcomment_for_reflog start\n+\n+\tif test ! -z \"$switch_to\"\n+\tthen\n+\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\"\n+\t\toutput git checkout \"$switch_to\" -- ||\n+\t\t\tdie \"$(eval_gettext \"Could not checkout \\$switch_to\")\"\n+\n+\t\tcomment_for_reflog start\n+\tfi\n+}\n+\n+init_basic_state () {\n+\torig_head=$(git rev-parse --verify HEAD) || die \"$(gettext \"No HEAD?\")\"\n+\tmkdir -p \"$state_dir\" || die \"$(eval_gettext \"Could not create temporary \\$state_dir\")\"\n+\trm -f \"$(git rev-parse --git-path REBASE_HEAD)\"\n+\n+\t: > \"$state_dir\"/interactive || die \"$(gettext \"Could not mark as interactive\")\"\n+\twrite_basic_state\n+}\n+\n+init_revisions_and_shortrevisions () {\n+\tshorthead=$(git rev-parse --short $orig_head)\n+\tshortonto=$(git rev-parse --short $onto)\n+\tif test -z \"$rebase_root\"\n+\t\t# this is now equivalent to ! -z \"$upstream\"\n+\tthen\n+\t\tshortupstream=$(git rev-parse --short $upstream)\n+\t\trevisions=$upstream...$orig_head\n+\t\tshortrevisions=$shortupstream..$shorthead\n+\telse\n+\t\trevisions=$onto...$orig_head\n+\t\tshortrevisions=$shorthead\n+\t\ttest -z \"$squash_onto\" ||\n+\t\techo \"$squash_onto\" >\"$state_dir\"/squash-onto\n+\tfi\n+}\n+\n+complete_action() {\n+\ttest -s \"$todo\" || echo noop >> \"$todo\"\n+\ttest -z \"$autosquash\" || git rebase--helper --rearrange-squash || exit\n+\ttest -n \"$cmd\" && git rebase--helper --add-exec-commands \"$cmd\"\n+\n+\ttodocount=$(git stripspace --strip-comments <\"$todo\" | wc -l)\n+\ttodocount=${todocount##* }\n+\n+cat >>\"$todo\" <<EOF\n+\n+$comment_char $(eval_ngettext \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount command)\" \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n+\t\"$todocount\")\n+EOF\n+\tappend_todo_help\n+\tgettext \"\n+\tHowever, if you remove everything, the rebase will be aborted.\n+\n+\t\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test -z \"$keep_empty\"\n+\tthen\n+\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n+\tfi\n+\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tcp \"$todo\" \"$todo\".backup\n+\tcollapse_todo_ids\n+\tgit_sequence_editor \"$todo\" ||\n+\t\tdie_abort \"$(gettext \"Could not execute editor\")\"\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tgit rebase--helper --check-todo-list || {\n+\t\tret=$?\n+\t\tcheckout_onto\n+\t\texit $ret\n+\t}\n+\n+\texpand_todo_ids\n+\n+\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n+\tdie \"Could not skip unnecessary pick commands\"\n+\n+\tcheckout_onto\n+\tif test ! -d \"$rewritten\"\n+\tthen\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t--continue\n+\tfi\n+\tdo_rest\n+}\n+\n+git_rebase__interactive () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n+\t\t${rebase_merges:+--rebase-merges} \\\n+\t\t${rebase_cousins:+--rebase-cousins} \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n+\tdie \"$(gettext \"Could not generate todo list\")\"\n+\n+\tcomplete_action\n+}\n+\n+git_rebase__interactive__preserve_merges () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tif test -z \"$rebase_root\"\n+\tthen\n+\t\tmkdir \"$rewritten\" &&\n+\t\tfor c in $(git merge-base --all $orig_head $upstream)\n+\t\tdo\n+\t\t\techo $onto > \"$rewritten\"/$c ||\n+\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\t\tdone\n+\telse\n+\t\tmkdir \"$rewritten\" &&\n+\t\techo $onto > \"$rewritten\"/root ||\n+\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\tfi\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tformat=$(git config --get rebase.instructionFormat)\n+\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n+\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n+\t\t--reverse --left-right --topo-order \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n+\t\tsed -n \"s/^>//p\" |\n+\twhile read -r sha1 rest\n+\tdo\n+\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n+\t\tthen\n+\t\t\tcomment_out=\"$comment_char \"\n+\t\telse\n+\t\t\tcomment_out=\n+\t\tfi\n+\n+\t\tif test -z \"$rebase_root\"\n+\t\tthen\n+\t\t\tpreserve=t\n+\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n+\t\t\tdo\n+\t\t\t\tif test -f \"$rewritten\"/$p\n+\t\t\t\tthen\n+\t\t\t\t\tpreserve=f\n+\t\t\t\tfi\n+\t\t\tdone\n+\t\telse\n+\t\t\tpreserve=f\n+\t\tfi\n+\t\tif test f = \"$preserve\"\n+\t\tthen\n+\t\t\ttouch \"$rewritten\"/$sha1\n+\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n+\t\tfi\n+\tdone\n+\n+\t# Watch for commits that been dropped by --cherry-pick\n+\tmkdir \"$dropped\"\n+\t# Save all non-cherry-picked changes\n+\tgit rev-list $revisions --left-right --cherry-pick | \\\n+\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n+\t# Now all commits and note which ones are missing in\n+\t# not-cherry-picks and hence being dropped\n+\tgit rev-list $revisions |\n+\twhile read rev\n+\tdo\n+\t\tif test -f \"$rewritten\"/$rev &&\n+\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n+\t\tthen\n+\t\t\t# Use -f2 because if rev-list is telling us this commit is\n+\t\t\t# not worthwhile, we don't want to track its multiple heads,\n+\t\t\t# just the history of its first-parent for others that will\n+\t\t\t# be rebasing on top of it\n+\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n+\t\t\tsha1=$(git rev-list -1 $rev)\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n+\t\t\trm \"$rewritten\"/$rev\n+\t\tfi\n+\tdone\n+\n+\tcomplete_action\n+}\n-- \n2.16.1\n\n"},{"id":"348427","messageId":"06839a64-1790-4c1d-9666-e5388446bee4@gmail.com","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v3 0/4] rebase: split rebase -p from rebase -i","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-24T11:52:24Z","receivedAt":"2018-05-24T11:52:36Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi,\n\nLe 24/05/2018 à 13:49, Alban Gruin a écrit :\n> Changes since v2:\n\n - Removing `mark_action_done()` from git-rebase--interactive.sh\n\n - Removing unused variables from git-rebase--interactive.sh\n\n\nCheers,\nAlban\n\n"},{"id":"348533","messageId":"nycvar.QRO.7.76.6.1805251150040.77@tvgsbejvaqbjf.bet","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v3 0/4] rebase: split rebase -p from rebase -i","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-05-25T09:51:20Z","receivedAt":"2018-05-25T09:51:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Alban,\n\nOn Thu, 24 May 2018, Alban Gruin wrote:\n\n> This splits the `rebase --preserve-merges` functionnality from\n> git-rebase--interactive.sh. All the dead code left by the duplication of\n> git-rebase--interactive.sh is also removed. This will make it easier to rewrite\n> this script in C.\n> \n> This patch series is based of js/sequencer-and-root-commits.\n\nSince you got such copious feedback, I'll just stick to reviewing on\nGitHub if you don't mind.\n\nI added a couple of suggestions there.\n\nCiao,\nDscho\n"},{"id":"348578","messageId":"xmqqk1rrm8ic.fsf@gitster-ct.c.googlers.com","threadId":"48547","inReplyTo":"20180524114958.26521-2-alban.gruin@gmail.com","subject":"Re: [GSoC][PATCH v3 1/4] rebase: duplicate git-rebase--interactive.sh to git-rebase--preserve-merges.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-05-26T02:54:35Z","receivedAt":"2018-05-26T02:54:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alban Gruin <alban.gruin@gmail.com> writes:\n\n> This duplicates git-rebase--interactive.sh to\n> git-rebase--preserve-merges.sh. This is done to split -p from -i. No\n> modifications are made to this file here, but any code that is not used by -p\n> will be stripped in the next commit.\n>\n> Signed-off-by: Alban Gruin <alban.gruin@gmail.com>\n> ---\n>  .gitignore                     |    1 +\n>  Makefile                       |    2 +\n>  git-rebase--preserve-merges.sh | 1069 ++++++++++++++++++++++++++++++++++++++++\n\nI would normally say \"Yuck\" to an approach like this series, because\nit does not force us to make any explicit effort to share as much\ncode between the two codepaths.\n\nBut the codepath for \"-p\" is something that has been abandoned even\nby its original author and would be going away, so the net effect of\nthis series to the project in the longer term is to remove the \"dead\ncode\" that will be made unnecessary from \"git-rebase--interactive\"\nwhen support for \"-p\" gets discarded in a distant future, and do so\nbefore we actually remove \"-p\" (and replace it with the \"recreate\nmerges\" feature).\n\nSo I won't have objection to the approach taken in this series.  I\nmay still raise issues on individual changes, though.\n\nThanks.\n"},{"id":"348659","messageId":"20180528123422.6718-1-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180524114958.26521-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 0/4] rebase: split rebase -p from rebase -i","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-28T12:34:18Z","receivedAt":"2018-05-28T12:35:34Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This splits the `rebase --preserve-merges` functionnality from\ngit-rebase--interactive.sh. All the dead code left by the duplication of\ngit-rebase--interactive.sh is also removed. This will make it easier to rewrite\nthis script in C.\n\nThis patch series is based of js/sequencer-and-root-commits.\n\nChanges since v3:\n\n - Rewording the commits to be more descriptive, and to respect the 72\n   characters limit.\n\nAlban Gruin (4):\n  rebase: introduce a dedicated backend for --preserve-merges\n  rebase: strip unused code in git-rebase--preserve-merges.sh\n  rebase: use the new git-rebase--preserve-merges.sh\n  rebase: remove -p code from git-rebase--interactive.sh\n\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--interactive.sh     |  802 +------------------------------\n git-rebase--preserve-merges.sh | 1012 ++++++++++++++++++++++++++++++++++++++++\n git-rebase.sh                  |   32 +-\n 5 files changed, 1048 insertions(+), 801 deletions(-)\n create mode 100644 git-rebase--preserve-merges.sh\n\n-- \n2.16.1\n\n"},{"id":"348660","messageId":"20180528123422.6718-2-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180528123422.6718-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 1/4] rebase: introduce a dedicated backend for --preserve-merges","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-28T12:34:19Z","receivedAt":"2018-05-28T12:35:45Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This duplicates git-rebase--interactive.sh to\ngit-rebase--preserve-merges.sh. This is done to split -p from -i. No\nmodifications are made to this file here, but any code that is not used\nby -p will be stripped in the next commit.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n .gitignore                     |    1 +\n Makefile                       |    2 +\n git-rebase--preserve-merges.sh | 1069 ++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 1072 insertions(+)\n create mode 100644 git-rebase--preserve-merges.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 833ef3b0b..ef4925485 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -117,6 +117,7 @@\n /git-rebase--helper\n /git-rebase--interactive\n /git-rebase--merge\n+/git-rebase--preserve-merges\n /git-receive-pack\n /git-reflog\n /git-remote\ndiff --git a/Makefile b/Makefile\nindex 50da82b01..810a0d0f4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -582,6 +582,7 @@ SCRIPT_LIB += git-mergetool--lib\n SCRIPT_LIB += git-parse-remote\n SCRIPT_LIB += git-rebase--am\n SCRIPT_LIB += git-rebase--interactive\n+SCRIPT_LIB += git-rebase--preserve-merges\n SCRIPT_LIB += git-rebase--merge\n SCRIPT_LIB += git-sh-setup\n SCRIPT_LIB += git-sh-i18n\n@@ -2271,6 +2272,7 @@ LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)\n LOCALIZED_SH = $(SCRIPT_SH)\n LOCALIZED_SH += git-parse-remote.sh\n LOCALIZED_SH += git-rebase--interactive.sh\n+LOCALIZED_SH += git-rebase--preserve-merges.sh\n LOCALIZED_SH += git-sh-setup.sh\n LOCALIZED_PERL = $(SCRIPT_PERL)\n \ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nnew file mode 100644\nindex 000000000..2f4941d0f\n--- /dev/null\n+++ b/git-rebase--preserve-merges.sh\n@@ -0,0 +1,1069 @@\n+# This shell script fragment is sourced by git-rebase to implement\n+# its interactive mode.  \"git rebase --interactive\" makes it easy\n+# to fix up commits in the middle of a series and rearrange commits.\n+#\n+# Copyright (c) 2006 Johannes E. Schindelin\n+#\n+# The original idea comes from Eric W. Biederman, in\n+# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n+#\n+# The file containing rebase commands, comments, and empty lines.\n+# This file is created by \"git rebase -i\" then edited by the user.  As\n+# the lines are processed, they are removed from the front of this\n+# file and written to the tail of $done.\n+todo=\"$state_dir\"/git-rebase-todo\n+\n+# The rebase command lines that have already been processed.  A line\n+# is moved here when it is first handled, before any associated user\n+# actions.\n+done=\"$state_dir\"/done\n+\n+# The commit message that is planned to be used for any changes that\n+# need to be committed following a user interaction.\n+msg=\"$state_dir\"/message\n+\n+# The file into which is accumulated the suggested commit message for\n+# squash/fixup commands.  When the first of a series of squash/fixups\n+# is seen, the file is created and the commit message from the\n+# previous commit and from the first squash/fixup commit are written\n+# to it.  The commit message for each subsequent squash/fixup commit\n+# is appended to the file as it is processed.\n+#\n+# The first line of the file is of the form\n+#     # This is a combination of $count commits.\n+# where $count is the number of commits whose messages have been\n+# written to the file so far (including the initial \"pick\" commit).\n+# Each time that a commit message is processed, this line is read and\n+# updated.  It is deleted just before the combined commit is made.\n+squash_msg=\"$state_dir\"/message-squash\n+\n+# If the current series of squash/fixups has not yet included a squash\n+# command, then this file exists and holds the commit message of the\n+# original \"pick\" commit.  (If the series ends without a \"squash\"\n+# command, then this can be used as the commit message of the combined\n+# commit without opening the editor.)\n+fixup_msg=\"$state_dir\"/message-fixup\n+\n+# $rewritten is the name of a directory containing files for each\n+# commit that is reachable by at least one merge base of $head and\n+# $upstream. They are not necessarily rewritten, but their children\n+# might be.  This ensures that commits on merged, but otherwise\n+# unrelated side branches are left alone. (Think \"X\" in the man page's\n+# example.)\n+rewritten=\"$state_dir\"/rewritten\n+\n+dropped=\"$state_dir\"/dropped\n+\n+end=\"$state_dir\"/end\n+msgnum=\"$state_dir\"/msgnum\n+\n+# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE that will be used for the commit that is currently\n+# being rebased.\n+author_script=\"$state_dir\"/author-script\n+\n+# When an \"edit\" rebase command is being processed, the SHA1 of the\n+# commit to be edited is recorded in this file.  When \"git rebase\n+# --continue\" is executed, if there are any staged changes then they\n+# will be amended to the HEAD commit, but only provided the HEAD\n+# commit is still the commit to be edited.  When any other rebase\n+# command is processed, this file is deleted.\n+amend=\"$state_dir\"/amend\n+\n+# For the post-rewrite hook, we make a list of rewritten commits and\n+# their new sha1s.  The rewritten-pending list keeps the sha1s of\n+# commits that have been processed, but not committed yet,\n+# e.g. because they are waiting for a 'squash' command.\n+rewritten_list=\"$state_dir\"/rewritten-list\n+rewritten_pending=\"$state_dir\"/rewritten-pending\n+\n+# Work around Git for Windows' Bash whose \"read\" does not strip CRLF\n+# and leaves CR at the end instead.\n+cr=$(printf \"\\015\")\n+\n+strategy_args=${strategy:+--strategy=$strategy}\n+test -n \"$strategy_opts\" &&\n+eval '\n+\tfor strategy_opt in '\"$strategy_opts\"'\n+\tdo\n+\t\tstrategy_args=\"$strategy_args -X$(git rev-parse --sq-quote \"${strategy_opt#--}\")\"\n+\tdone\n+'\n+\n+GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n+export GIT_CHERRY_PICK_HELP\n+\n+comment_char=$(git config --get core.commentchar 2>/dev/null)\n+case \"$comment_char\" in\n+'' | auto)\n+\tcomment_char=\"#\"\n+\t;;\n+?)\n+\t;;\n+*)\n+\tcomment_char=$(echo \"$comment_char\" | cut -c1)\n+\t;;\n+esac\n+\n+warn () {\n+\tprintf '%s\\n' \"$*\" >&2\n+}\n+\n+# Output the commit message for the specified commit.\n+commit_message () {\n+\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n+}\n+\n+orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n+\n+comment_for_reflog () {\n+\tcase \"$orig_reflog_action\" in\n+\t''|rebase*)\n+\t\tGIT_REFLOG_ACTION=\"rebase -i ($1)\"\n+\t\texport GIT_REFLOG_ACTION\n+\t\t;;\n+\tesac\n+}\n+\n+last_count=\n+mark_action_done () {\n+\tsed -e 1q < \"$todo\" >> \"$done\"\n+\tsed -e 1d < \"$todo\" >> \"$todo\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tnew_count=$(( $(git stripspace --strip-comments <\"$done\" | wc -l) ))\n+\techo $new_count >\"$msgnum\"\n+\ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n+\techo $total >\"$end\"\n+\tif test \"$last_count\" != \"$new_count\"\n+\tthen\n+\t\tlast_count=$new_count\n+\t\teval_gettext \"Rebasing (\\$new_count/\\$total)\"; printf \"\\r\"\n+\t\ttest -z \"$verbose\" || echo\n+\tfi\n+}\n+\n+# Put the last action marked done at the beginning of the todo list\n+# again. If there has not been an action marked done yet, leave the list of\n+# items on the todo list unchanged.\n+reschedule_last_action () {\n+\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n+\tsed -e \\$d <\"$done\" >\"$done\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tmv -f \"$done\".new \"$done\"\n+}\n+\n+append_todo_help () {\n+\tgettext \"\n+Commands:\n+p, pick <commit> = use commit\n+r, reword <commit> = use commit, but edit the commit message\n+e, edit <commit> = use commit, but stop for amending\n+s, squash <commit> = use commit, but meld into previous commit\n+f, fixup <commit> = like \\\"squash\\\", but discard this commit's log message\n+x, exec <commit> = run command (the rest of the line) using shell\n+d, drop <commit> = remove commit\n+l, label <label> = label current HEAD with a name\n+t, reset <label> = reset HEAD to a label\n+m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n+.       create a merge commit using the original merge commit's\n+.       message (or the oneline, if no original merge commit was\n+.       specified). Use -c <commit> to reword the commit message.\n+\n+These lines can be re-ordered; they are executed from top to bottom.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test $(get_missing_commit_check_level) = error\n+\tthen\n+\t\tgettext \"\n+Do not remove any line. Use 'drop' explicitly to remove a commit.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\telse\n+\t\tgettext \"\n+If you remove a line here THAT COMMIT WILL BE LOST.\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\tfi\n+}\n+\n+make_patch () {\n+\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n+\tcase \"$sha1_and_parents\" in\n+\t?*' '?*' '?*)\n+\t\tgit diff --cc $sha1_and_parents\n+\t\t;;\n+\t?*' '?*)\n+\t\tgit diff-tree -p \"$1^!\"\n+\t\t;;\n+\t*)\n+\t\techo \"Root commit\"\n+\t\t;;\n+\tesac > \"$state_dir\"/patch\n+\ttest -f \"$msg\" ||\n+\t\tcommit_message \"$1\" > \"$msg\"\n+\ttest -f \"$author_script\" ||\n+\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n+}\n+\n+die_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch \"$1\"\n+\tdie \"$2\"\n+}\n+\n+exit_with_patch () {\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n+\tgit update-ref REBASE_HEAD \"$1\"\n+\tmake_patch $1\n+\tgit rev-parse --verify HEAD > \"$amend\"\n+\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\twarn \"$(eval_gettext \"\\\n+You can amend the commit now, with\n+\n+\tgit commit --amend \\$gpg_sign_opt_quoted\n+\n+Once you are satisfied with your changes, run\n+\n+\tgit rebase --continue\")\"\n+\twarn\n+\texit $2\n+}\n+\n+die_abort () {\n+\tapply_autostash\n+\trm -rf \"$state_dir\"\n+\tdie \"$1\"\n+}\n+\n+has_action () {\n+\ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n+}\n+\n+is_empty_commit() {\n+\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n+\t\tsha1=$1\n+\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n+\t}\n+\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n+\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n+\ttest \"$tree\" = \"$ptree\"\n+}\n+\n+is_merge_commit()\n+{\n+\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n+}\n+\n+# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n+# GIT_AUTHOR_DATE exported from the current environment.\n+do_with_author () {\n+\t(\n+\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n+\t\t\"$@\"\n+\t)\n+}\n+\n+git_sequence_editor () {\n+\tif test -z \"$GIT_SEQUENCE_EDITOR\"\n+\tthen\n+\t\tGIT_SEQUENCE_EDITOR=\"$(git config sequence.editor)\"\n+\t\tif [ -z \"$GIT_SEQUENCE_EDITOR\" ]\n+\t\tthen\n+\t\t\tGIT_SEQUENCE_EDITOR=\"$(git var GIT_EDITOR)\" || return $?\n+\t\tfi\n+\tfi\n+\n+\teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n+}\n+\n+pick_one () {\n+\tff=--ff\n+\n+\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n+\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n+\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n+\n+\tif is_empty_commit \"$sha1\"\n+\tthen\n+\t\tempty_args=\"--allow-empty\"\n+\tfi\n+\n+\ttest -d \"$rewritten\" &&\n+\t\tpick_one_preserving_merges \"$@\" && return\n+\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n+\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n+\n+\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n+\t# previous task so this commit is not lost.\n+\tret=$?\n+\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n+\treturn $ret\n+}\n+\n+pick_one_preserving_merges () {\n+\tfast_forward=t\n+\tcase \"$1\" in\n+\t-n)\n+\t\tfast_forward=f\n+\t\tsha1=$2\n+\t\t;;\n+\t*)\n+\t\tsha1=$1\n+\t\t;;\n+\tesac\n+\tsha1=$(git rev-parse $sha1)\n+\n+\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n+\tthen\n+\t\twhile read current_commit\n+\t\tdo\n+\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n+\t\tdone <\"$state_dir\"/current-commit\n+\t\trm \"$state_dir\"/current-commit ||\n+\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n+\tfi\n+\n+\techo $sha1 >> \"$state_dir\"/current-commit\n+\n+\t# rewrite parents; if none were rewritten, we can fast-forward.\n+\tnew_parents=\n+\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n+\tif test \"$pend\" = \" \"\n+\tthen\n+\t\tpend=\" root\"\n+\tfi\n+\twhile [ \"$pend\" != \"\" ]\n+\tdo\n+\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n+\t\tpend=\"${pend# $p}\"\n+\n+\t\tif test -f \"$rewritten\"/$p\n+\t\tthen\n+\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n+\n+\t\t\t# If the todo reordered commits, and our parent is marked for\n+\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n+\t\t\t# drop it on top of the current HEAD\n+\t\t\tif test -z \"$new_p\"\n+\t\t\tthen\n+\t\t\t\tnew_p=$(git rev-parse HEAD)\n+\t\t\tfi\n+\n+\t\t\ttest $p != $new_p && fast_forward=f\n+\t\t\tcase \"$new_parents\" in\n+\t\t\t*$new_p*)\n+\t\t\t\t;; # do nothing; that parent is already there\n+\t\t\t*)\n+\t\t\t\tnew_parents=\"$new_parents $new_p\"\n+\t\t\t\t;;\n+\t\t\tesac\n+\t\telse\n+\t\t\tif test -f \"$dropped\"/$p\n+\t\t\tthen\n+\t\t\t\tfast_forward=f\n+\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n+\t\t\t\ttest -z \"$replacement\" && replacement=root\n+\t\t\t\tpend=\" $replacement$pend\"\n+\t\t\telse\n+\t\t\t\tnew_parents=\"$new_parents $p\"\n+\t\t\tfi\n+\t\tfi\n+\tdone\n+\tcase $fast_forward in\n+\tt)\n+\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n+\t\toutput git reset --hard $sha1 ||\n+\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n+\t\t;;\n+\tf)\n+\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n+\n+\t\tif [ \"$1\" != \"-n\" ]\n+\t\tthen\n+\t\t\t# detach HEAD to current parent\n+\t\t\toutput git checkout $first_parent 2> /dev/null ||\n+\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n+\t\tfi\n+\n+\t\tcase \"$new_parents\" in\n+\t\t' '*' '*)\n+\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n+\n+\t\t\t# redo merge\n+\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n+\t\t\teval \"$author_script_content\"\n+\t\t\tmsg_content=\"$(commit_message $sha1)\"\n+\t\t\t# No point in merging the first parent, that's HEAD\n+\t\t\tnew_parents=${new_parents# $first_parent}\n+\t\t\tmerge_args=\"--no-log --no-ff\"\n+\t\t\tif ! do_with_author output eval \\\n+\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n+\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n+\t\t\t\t\"$strategy_args\" \\\n+\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n+\t\t\t\t\"$new_parents\"\n+\t\t\tthen\n+\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n+\t\t\tfi\n+\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n+\t\t\t\t$allow_empty_message \\\n+\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n+\t\t\t\t\"$strategy_args\" \"$@\" ||\n+\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n+\t\t\t;;\n+\t\tesac\n+\t\t;;\n+\tesac\n+}\n+\n+this_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"This is the commit message #\\${n}:\"\n+}\n+\n+skip_nth_commit_message () {\n+\tn=$1\n+\teval_gettext \"The commit message #\\${n} will be skipped:\"\n+}\n+\n+update_squash_messages () {\n+\tif test -f \"$squash_msg\"; then\n+\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n+\t\tcount=$(($(sed -n \\\n+\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n+\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n+\t\t\t\t\"This is a combination of \\$count commit.\" \\\n+\t\t\t\t\"This is a combination of \\$count commits.\" \\\n+\t\t\t\t$count)\"\n+\t\t\tsed -e 1d -e '2,/^./{\n+\t\t\t\t/^$/d\n+\t\t\t}' <\"$squash_msg\".bak\n+\t\t} >\"$squash_msg\"\n+\telse\n+\t\tcommit_message HEAD >\"$fixup_msg\" ||\n+\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n+\t\tcount=2\n+\t\t{\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n+\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n+\t\t\techo\n+\t\t\tcat \"$fixup_msg\"\n+\t\t} >\"$squash_msg\"\n+\tfi\n+\tcase $1 in\n+\tsquash)\n+\t\trm -f \"$fixup_msg\"\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n+\t\techo\n+\t\tcommit_message $2\n+\t\t;;\n+\tfixup)\n+\t\techo\n+\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n+\t\techo\n+\t\t# Change the space after the comment character to TAB:\n+\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n+\t\t;;\n+\tesac >>\"$squash_msg\"\n+}\n+\n+peek_next_command () {\n+\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n+}\n+\n+# A squash/fixup has failed.  Prepare the long version of the squash\n+# commit message, then die_with_patch.  This code path requires the\n+# user to edit the combined commit message for all commits that have\n+# been squashed/fixedup so far.  So also erase the old squash\n+# messages, effectively causing the combined commit to be used as the\n+# new basis for any further squash/fixups.  Args: sha1 rest\n+die_failed_squash() {\n+\tsha1=$1\n+\trest=$2\n+\tmv \"$squash_msg\" \"$msg\" || exit\n+\trm -f \"$fixup_msg\"\n+\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n+\twarn\n+\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tdie_with_patch $sha1 \"\"\n+}\n+\n+flush_rewritten_pending() {\n+\ttest -s \"$rewritten_pending\" || return\n+\tnewsha1=\"$(git rev-parse HEAD^0)\"\n+\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n+\trm -f \"$rewritten_pending\"\n+}\n+\n+record_in_rewritten() {\n+\toldsha1=\"$(git rev-parse $1)\"\n+\techo \"$oldsha1\" >> \"$rewritten_pending\"\n+\n+\tcase \"$(peek_next_command)\" in\n+\tsquash|s|fixup|f)\n+\t\t;;\n+\t*)\n+\t\tflush_rewritten_pending\n+\t\t;;\n+\tesac\n+}\n+\n+do_pick () {\n+\tsha1=$1\n+\trest=$2\n+\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n+\tthen\n+\t\t# Set the correct commit message and author info on the\n+\t\t# sentinel root before cherry-picking the original changes\n+\t\t# without committing (-n).  Finally, update the sentinel again\n+\t\t# to include these changes.  If the cherry-pick results in a\n+\t\t# conflict, this means our behaviour is similar to a standard\n+\t\t# failed cherry-pick during rebase, with a dirty index to\n+\t\t# resolve before manually running git commit --amend then git\n+\t\t# rebase --continue.\n+\t\tgit commit --allow-empty --allow-empty-message --amend \\\n+\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n+\t\t\tpick_one -n $sha1 &&\n+\t\t\tgit commit --allow-empty --allow-empty-message \\\n+\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n+\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n+\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\telse\n+\t\tpick_one $sha1 ||\n+\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n+\tfi\n+}\n+\n+do_next () {\n+\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n+\tread -r command sha1 rest < \"$todo\"\n+\tcase \"$command\" in\n+\t\"$comment_char\"*|''|noop|drop|d)\n+\t\tmark_action_done\n+\t\t;;\n+\t\"$cr\")\n+\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n+\t\tmark_action_done\n+\t\t;;\n+\tpick|p)\n+\t\tcomment_for_reflog pick\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\treword|r)\n+\t\tcomment_for_reflog reword\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n+\t\t\t$allow_empty_message || {\n+\t\t\twarn \"$(eval_gettext \"\\\n+Could not amend commit after successfully picking \\$sha1... \\$rest\n+This is most likely due to an empty commit message, or the pre-commit hook\n+failed. If the pre-commit hook failed, you may need to resolve the issue before\n+you are able to reword the commit.\")\"\n+\t\t\texit_with_patch $sha1 1\n+\t\t}\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tedit|e)\n+\t\tcomment_for_reflog edit\n+\n+\t\tmark_action_done\n+\t\tdo_pick $sha1 \"$rest\"\n+\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n+\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n+\t\texit_with_patch $sha1 0\n+\t\t;;\n+\tsquash|s|fixup|f)\n+\t\tcase \"$command\" in\n+\t\tsquash|s)\n+\t\t\tsquash_style=squash\n+\t\t\t;;\n+\t\tfixup|f)\n+\t\t\tsquash_style=fixup\n+\t\t\t;;\n+\t\tesac\n+\t\tcomment_for_reflog $squash_style\n+\n+\t\ttest -f \"$done\" && has_action \"$done\" ||\n+\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n+\n+\t\tmark_action_done\n+\t\tupdate_squash_messages $squash_style $sha1\n+\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n+\t\techo \"$author_script_content\" > \"$author_script\"\n+\t\teval \"$author_script_content\"\n+\t\tif ! pick_one -n $sha1\n+\t\tthen\n+\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n+\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\tfi\n+\t\tcase \"$(peek_next_command)\" in\n+\t\tsquash|s|fixup|f)\n+\t\t\t# This is an intermediate commit; its message will only be\n+\t\t\t# used in case of trouble.  So use the long version:\n+\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n+\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\t# This is the final command of this squash/fixup group\n+\t\t\tif test -f \"$fixup_msg\"\n+\t\t\tthen\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\telse\n+\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n+\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n+\t\t\tfi\n+\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n+\t\t\t;;\n+\t\tesac\n+\t\trecord_in_rewritten $sha1\n+\t\t;;\n+\tx|\"exec\")\n+\t\tread -r command rest < \"$todo\"\n+\t\tmark_action_done\n+\t\teval_gettextln \"Executing: \\$rest\"\n+\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n+\t\tstatus=$?\n+\t\t# Run in subshell because require_clean_work_tree can die.\n+\t\tdirty=f\n+\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n+\t\tif test \"$status\" -ne 0\n+\t\tthen\n+\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n+\t\t\ttest \"$dirty\" = f ||\n+\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n+\n+\t\t\twarn \"$(gettext \"\\\n+You can fix the problem, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\tif test $status -eq 127\t\t# command not found\n+\t\t\tthen\n+\t\t\t\tstatus=1\n+\t\t\tfi\n+\t\t\texit \"$status\"\n+\t\telif test \"$dirty\" = t\n+\t\tthen\n+\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n+\t\t\twarn \"$(eval_gettext \"\\\n+Execution succeeded: \\$rest\n+but left changes to the index and/or the working tree\n+Commit or stash your changes, and then run\n+\n+\tgit rebase --continue\")\"\n+\t\t\twarn\n+\t\t\texit 1\n+\t\tfi\n+\t\t;;\n+\t*)\n+\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n+\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n+\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n+\t\tthen\n+\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n+\t\telse\n+\t\t\tdie \"$fixtodo\"\n+\t\tfi\n+\t\t;;\n+\tesac\n+\ttest -s \"$todo\" && return\n+\n+\tcomment_for_reflog finish &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\tcase $head_name in\n+\trefs/*)\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n+\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n+\t\tgit symbolic-ref \\\n+\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n+\t\t  HEAD $head_name\n+\t\t;;\n+\tesac && {\n+\t\ttest ! -f \"$state_dir\"/verbose ||\n+\t\t\tgit diff-tree --stat $orig_head..HEAD\n+\t} &&\n+\t{\n+\t\ttest -s \"$rewritten_list\" &&\n+\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n+\t\ttrue # we don't care if this copying failed\n+\t} &&\n+\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n+\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n+\t\t\"$hook\" rebase < \"$rewritten_list\"\n+\t\ttrue # we don't care if this hook failed\n+\tfi &&\n+\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n+\n+\treturn 1 # not failure; just to break the do_rest loop\n+}\n+\n+# can only return 0, when the infinite loop breaks\n+do_rest () {\n+\twhile :\n+\tdo\n+\t\tdo_next || break\n+\tdone\n+}\n+\n+expand_todo_ids() {\n+\tgit rebase--helper --expand-ids\n+}\n+\n+collapse_todo_ids() {\n+\tgit rebase--helper --shorten-ids\n+}\n+\n+# Switch to the branch in $into and notify it in the reflog\n+checkout_onto () {\n+\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $onto_name\"\n+\toutput git checkout $onto || die_abort \"$(gettext \"could not detach HEAD\")\"\n+\tgit update-ref ORIG_HEAD $orig_head\n+}\n+\n+get_missing_commit_check_level () {\n+\tcheck_level=$(git config --get rebase.missingCommitsCheck)\n+\tcheck_level=${check_level:-ignore}\n+\t# Don't be case sensitive\n+\tprintf '%s' \"$check_level\" | tr 'A-Z' 'a-z'\n+}\n+\n+# Initiate an action. If the cannot be any\n+# further action it  may exec a command\n+# or exit and not return.\n+#\n+# TODO: Consider a cleaner return model so it\n+# never exits and always return 0 if process\n+# is complete.\n+#\n+# Parameter 1 is the action to initiate.\n+#\n+# Returns 0 if the action was able to complete\n+# and if 1 if further processing is required.\n+initiate_action () {\n+\tcase \"$1\" in\n+\tcontinue)\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\t# do we have anything to commit?\n+\t\tif git diff-index --cached --quiet HEAD --\n+\t\tthen\n+\t\t\t# Nothing to commit -- skip this commit\n+\n+\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n+\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n+\t\telse\n+\t\t\tif ! test -f \"$author_script\"\n+\t\t\tthen\n+\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n+\t\t\t\tdie \"$(eval_gettext \"\\\n+You have staged changes in your working tree.\n+If these changes are meant to be\n+squashed into the previous commit, run:\n+\n+  git commit --amend \\$gpg_sign_opt_quoted\n+\n+If they are meant to go into a new commit, run:\n+\n+  git commit \\$gpg_sign_opt_quoted\n+\n+In both cases, once you're done, continue with:\n+\n+  git rebase --continue\n+\")\"\n+\t\t\tfi\n+\t\t\t. \"$author_script\" ||\n+\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n+\t\t\tif test -f \"$amend\"\n+\t\t\tthen\n+\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n+\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n+\t\t\t\tdie \"$(gettext \"\\\n+You have uncommitted changes in your working tree. Please commit them\n+first and then run 'git rebase --continue' again.\")\"\n+\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\telse\n+\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n+\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n+\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n+\t\t\tfi\n+\t\tfi\n+\n+\t\tif test -r \"$state_dir\"/stopped-sha\n+\t\tthen\n+\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n+\t\tfi\n+\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tskip)\n+\t\tgit rerere clear\n+\n+\t\tif test ! -d \"$rewritten\"\n+\t\tthen\n+\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t\t--continue\n+\t\tfi\n+\t\tdo_rest\n+\t\treturn 0\n+\t\t;;\n+\tedit-todo)\n+\t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n+\t\tmv -f \"$todo\".new \"$todo\"\n+\t\tcollapse_todo_ids\n+\t\tappend_todo_help\n+\t\tgettext \"\n+You are editing the todo file of an ongoing interactive rebase.\n+To continue rebase after editing, run:\n+    git rebase --continue\n+\n+\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\t\tgit_sequence_editor \"$todo\" ||\n+\t\t\tdie \"$(gettext \"Could not execute editor\")\"\n+\t\texpand_todo_ids\n+\n+\t\texit\n+\t\t;;\n+\tshow-current-patch)\n+\t\texec git show REBASE_HEAD --\n+\t\t;;\n+\t*)\n+\t\treturn 1 # continue\n+\t\t;;\n+\tesac\n+}\n+\n+setup_reflog_action () {\n+\tcomment_for_reflog start\n+\n+\tif test ! -z \"$switch_to\"\n+\tthen\n+\t\tGIT_REFLOG_ACTION=\"$GIT_REFLOG_ACTION: checkout $switch_to\"\n+\t\toutput git checkout \"$switch_to\" -- ||\n+\t\t\tdie \"$(eval_gettext \"Could not checkout \\$switch_to\")\"\n+\n+\t\tcomment_for_reflog start\n+\tfi\n+}\n+\n+init_basic_state () {\n+\torig_head=$(git rev-parse --verify HEAD) || die \"$(gettext \"No HEAD?\")\"\n+\tmkdir -p \"$state_dir\" || die \"$(eval_gettext \"Could not create temporary \\$state_dir\")\"\n+\trm -f \"$(git rev-parse --git-path REBASE_HEAD)\"\n+\n+\t: > \"$state_dir\"/interactive || die \"$(gettext \"Could not mark as interactive\")\"\n+\twrite_basic_state\n+}\n+\n+init_revisions_and_shortrevisions () {\n+\tshorthead=$(git rev-parse --short $orig_head)\n+\tshortonto=$(git rev-parse --short $onto)\n+\tif test -z \"$rebase_root\"\n+\t\t# this is now equivalent to ! -z \"$upstream\"\n+\tthen\n+\t\tshortupstream=$(git rev-parse --short $upstream)\n+\t\trevisions=$upstream...$orig_head\n+\t\tshortrevisions=$shortupstream..$shorthead\n+\telse\n+\t\trevisions=$onto...$orig_head\n+\t\tshortrevisions=$shorthead\n+\t\ttest -z \"$squash_onto\" ||\n+\t\techo \"$squash_onto\" >\"$state_dir\"/squash-onto\n+\tfi\n+}\n+\n+complete_action() {\n+\ttest -s \"$todo\" || echo noop >> \"$todo\"\n+\ttest -z \"$autosquash\" || git rebase--helper --rearrange-squash || exit\n+\ttest -n \"$cmd\" && git rebase--helper --add-exec-commands \"$cmd\"\n+\n+\ttodocount=$(git stripspace --strip-comments <\"$todo\" | wc -l)\n+\ttodocount=${todocount##* }\n+\n+cat >>\"$todo\" <<EOF\n+\n+$comment_char $(eval_ngettext \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount command)\" \\\n+\t\"Rebase \\$shortrevisions onto \\$shortonto (\\$todocount commands)\" \\\n+\t\"$todocount\")\n+EOF\n+\tappend_todo_help\n+\tgettext \"\n+\tHowever, if you remove everything, the rebase will be aborted.\n+\n+\t\" | git stripspace --comment-lines >>\"$todo\"\n+\n+\tif test -z \"$keep_empty\"\n+\tthen\n+\t\tprintf '%s\\n' \"$comment_char $(gettext \"Note that empty commits are commented out\")\" >>\"$todo\"\n+\tfi\n+\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tcp \"$todo\" \"$todo\".backup\n+\tcollapse_todo_ids\n+\tgit_sequence_editor \"$todo\" ||\n+\t\tdie_abort \"$(gettext \"Could not execute editor\")\"\n+\n+\thas_action \"$todo\" ||\n+\t\treturn 2\n+\n+\tgit rebase--helper --check-todo-list || {\n+\t\tret=$?\n+\t\tcheckout_onto\n+\t\texit $ret\n+\t}\n+\n+\texpand_todo_ids\n+\n+\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n+\tdie \"Could not skip unnecessary pick commands\"\n+\n+\tcheckout_onto\n+\tif test ! -d \"$rewritten\"\n+\tthen\n+\t\trequire_clean_work_tree \"rebase\"\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t\t--continue\n+\tfi\n+\tdo_rest\n+}\n+\n+git_rebase__interactive () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n+\t\t${rebase_merges:+--rebase-merges} \\\n+\t\t${rebase_cousins:+--rebase-cousins} \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n+\tdie \"$(gettext \"Could not generate todo list\")\"\n+\n+\tcomplete_action\n+}\n+\n+git_rebase__interactive__preserve_merges () {\n+\tinitiate_action \"$action\"\n+\tret=$?\n+\tif test $ret = 0; then\n+\t\treturn 0\n+\tfi\n+\n+\tsetup_reflog_action\n+\tinit_basic_state\n+\n+\tif test -z \"$rebase_root\"\n+\tthen\n+\t\tmkdir \"$rewritten\" &&\n+\t\tfor c in $(git merge-base --all $orig_head $upstream)\n+\t\tdo\n+\t\t\techo $onto > \"$rewritten\"/$c ||\n+\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\t\tdone\n+\telse\n+\t\tmkdir \"$rewritten\" &&\n+\t\techo $onto > \"$rewritten\"/root ||\n+\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n+\tfi\n+\n+\tinit_revisions_and_shortrevisions\n+\n+\tformat=$(git config --get rebase.instructionFormat)\n+\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n+\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n+\t\t--reverse --left-right --topo-order \\\n+\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n+\t\tsed -n \"s/^>//p\" |\n+\twhile read -r sha1 rest\n+\tdo\n+\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n+\t\tthen\n+\t\t\tcomment_out=\"$comment_char \"\n+\t\telse\n+\t\t\tcomment_out=\n+\t\tfi\n+\n+\t\tif test -z \"$rebase_root\"\n+\t\tthen\n+\t\t\tpreserve=t\n+\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n+\t\t\tdo\n+\t\t\t\tif test -f \"$rewritten\"/$p\n+\t\t\t\tthen\n+\t\t\t\t\tpreserve=f\n+\t\t\t\tfi\n+\t\t\tdone\n+\t\telse\n+\t\t\tpreserve=f\n+\t\tfi\n+\t\tif test f = \"$preserve\"\n+\t\tthen\n+\t\t\ttouch \"$rewritten\"/$sha1\n+\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n+\t\tfi\n+\tdone\n+\n+\t# Watch for commits that been dropped by --cherry-pick\n+\tmkdir \"$dropped\"\n+\t# Save all non-cherry-picked changes\n+\tgit rev-list $revisions --left-right --cherry-pick | \\\n+\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n+\t# Now all commits and note which ones are missing in\n+\t# not-cherry-picks and hence being dropped\n+\tgit rev-list $revisions |\n+\twhile read rev\n+\tdo\n+\t\tif test -f \"$rewritten\"/$rev &&\n+\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n+\t\tthen\n+\t\t\t# Use -f2 because if rev-list is telling us this commit is\n+\t\t\t# not worthwhile, we don't want to track its multiple heads,\n+\t\t\t# just the history of its first-parent for others that will\n+\t\t\t# be rebasing on top of it\n+\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n+\t\t\tsha1=$(git rev-list -1 $rev)\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n+\t\t\trm \"$rewritten\"/$rev\n+\t\tfi\n+\tdone\n+\n+\tcomplete_action\n+}\n-- \n2.16.1\n\n"},{"id":"348661","messageId":"20180528123422.6718-3-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180528123422.6718-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 2/4] rebase: strip unused code in git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-28T12:34:20Z","receivedAt":"2018-05-28T12:36:11Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"This removes the code coming from git-rebase--interactive.sh that is not\nneeded by preserve-merges, and changes the header comment accordingly.\n\nIn a following commit, the -p code from git-rebase--interactive.sh will\nbe stripped out. As preserve-merges’ successor is already in the works,\nthis will be the only script to be converted.\n\nThis also seems to fix a bug where a failure in\n`pick_one_preserving_merges()` would fallback to the non-preserve-merges\n`pick_one()`.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--preserve-merges.sh | 65 +++---------------------------------------\n 1 file changed, 4 insertions(+), 61 deletions(-)\n\ndiff --git a/git-rebase--preserve-merges.sh b/git-rebase--preserve-merges.sh\nindex 2f4941d0f..c51c7828e 100644\n--- a/git-rebase--preserve-merges.sh\n+++ b/git-rebase--preserve-merges.sh\n@@ -1,12 +1,8 @@\n-# This shell script fragment is sourced by git-rebase to implement\n-# its interactive mode.  \"git rebase --interactive\" makes it easy\n-# to fix up commits in the middle of a series and rearrange commits.\n+# This shell script fragment is sourced by git-rebase to implement its\n+# preserve-merges mode.\n #\n # Copyright (c) 2006 Johannes E. Schindelin\n #\n-# The original idea comes from Eric W. Biederman, in\n-# https://public-inbox.org/git/m1odwkyuf5.fsf_-_@ebiederm.dsl.xmission.com/\n-#\n # The file containing rebase commands, comments, and empty lines.\n # This file is created by \"git rebase -i\" then edited by the user.  As\n # the lines are processed, they are removed from the front of this\n@@ -287,17 +283,7 @@ pick_one () {\n \t\tempty_args=\"--allow-empty\"\n \tfi\n \n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n+\tpick_one_preserving_merges \"$@\"\n }\n \n pick_one_preserving_merges () {\n@@ -761,11 +747,6 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\t# do we have anything to commit?\n \t\tif git diff-index --cached --quiet HEAD --\n \t\tthen\n@@ -824,12 +805,6 @@ first and then run 'git rebase --continue' again.\")\"\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n \t\tdo_rest\n \t\treturn 0\n \t\t;;\n@@ -944,43 +919,11 @@ EOF\n \t}\n \n \texpand_todo_ids\n-\n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n-\tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n-\tdie \"Could not skip unnecessary pick commands\"\n-\n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n \tdo_rest\n }\n \n-git_rebase__interactive () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tgit rebase--helper --make-script ${keep_empty:+--keep-empty} \\\n-\t\t${rebase_merges:+--rebase-merges} \\\n-\t\t${rebase_cousins:+--rebase-cousins} \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} >\"$todo\" ||\n-\tdie \"$(gettext \"Could not generate todo list\")\"\n-\n-\tcomplete_action\n-}\n-\n-git_rebase__interactive__preserve_merges () {\n+git_rebase__preserve_merges () {\n \tinitiate_action \"$action\"\n \tret=$?\n \tif test $ret = 0; then\n-- \n2.16.1\n\n"},{"id":"348662","messageId":"20180528123422.6718-4-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180528123422.6718-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 3/4] rebase: use the new git-rebase--preserve-merges.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-28T12:34:21Z","receivedAt":"2018-05-28T12:36:17Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Create a new type of rebase, \"preserve-merges\", used when rebase is\ncalled with -p.\n\nBefore that, the type for preserve-merges was \"interactive\", and some\nplaces of this script compared $type to \"interactive\". Instead, the code\nnow checks if $interactive_rebase is empty or not, as it is set to\n\"explicit\" when calling an interactive rebase (and, possibly, one of its\nsubmodes), and \"implied\" when calling one of its\nsubmodes (eg. preserve-merges) *without* interactive rebase.\n\nIt also detects the presence of the directory \"$merge_dir\"/rewritten\nleft by the preserve-merges script when calling rebase --continue,\n--skip, etc., and, if it exists, sets the rebase mode to\npreserve-merges. In this case, interactive_rebase is set to \"explicit\",\nas \"implied\" would break some tests.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase.sh | 32 +++++++++++++++++++++++++-------\n 1 file changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 40be59ecc..19bdebb48 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -207,7 +207,14 @@ run_specific_rebase () {\n \t\tautosquash=\n \tfi\n \t. git-rebase--$type\n-\tgit_rebase__$type${preserve_merges:+__preserve_merges}\n+\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\tgit_rebase__$type\n+\telse\n+\t\tgit_rebase__preserve_merges\n+\tfi\n+\n \tret=$?\n \tif test $ret -eq 0\n \tthen\n@@ -239,7 +246,12 @@ then\n \tstate_dir=\"$apply_dir\"\n elif test -d \"$merge_dir\"\n then\n-\tif test -f \"$merge_dir\"/interactive\n+\tif test -d \"$merge_dir\"/rewritten\n+\tthen\n+\t\ttype=preserve-merges\n+\t\tinteractive_rebase=explicit\n+\t\tpreserve_merges=t\n+\telif test -f \"$merge_dir\"/interactive\n \tthen\n \t\ttype=interactive\n \t\tinteractive_rebase=explicit\n@@ -402,14 +414,14 @@ if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"$(gettext \"No rebase in progress?\")\"\n \t# Only interactive rebase uses detailed reflog messages\n-\tif test \"$type\" = interactive && test \"$GIT_REFLOG_ACTION\" = rebase\n+\tif test -n \"$interactive_rebase\" && test \"$GIT_REFLOG_ACTION\" = rebase\n \tthen\n \t\tGIT_REFLOG_ACTION=\"rebase -i ($action)\"\n \t\texport GIT_REFLOG_ACTION\n \tfi\n fi\n \n-if test \"$action\" = \"edit-todo\" && test \"$type\" != \"interactive\"\n+if test \"$action\" = \"edit-todo\" && test -z \"$interactive_rebase\"\n then\n \tdie \"$(gettext \"The --edit-todo action can only be used during interactive rebase.\")\"\n fi\n@@ -487,7 +499,13 @@ fi\n \n if test -n \"$interactive_rebase\"\n then\n-\ttype=interactive\n+\tif test -z \"$preserve_merges\"\n+\tthen\n+\t\ttype=interactive\n+\telse\n+\t\ttype=preserve-merges\n+\tfi\n+\n \tstate_dir=\"$merge_dir\"\n elif test -n \"$do_merge\"\n then\n@@ -647,7 +665,7 @@ require_clean_work_tree \"rebase\" \"$(gettext \"Please commit or stash them.\")\"\n # but this should be done only when upstream and onto are the same\n # and if this is not an interactive rebase.\n mb=$(git merge-base \"$onto\" \"$orig_head\")\n-if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n+if test -z \"$interactive_rebase\" && test \"$upstream\" = \"$onto\" &&\n \ttest \"$mb\" = \"$onto\" && test -z \"$restrict_revision\" &&\n \t# linear history?\n \t! (git rev-list --parents \"$onto\"..\"$orig_head\" | sane_grep \" .* \") > /dev/null\n@@ -691,7 +709,7 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n-test \"$type\" = interactive && run_specific_rebase\n+test -n \"$interactive_rebase\" && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"$(gettext \"First, rewinding head to replay your work on top of it...\")\"\n-- \n2.16.1\n\n"},{"id":"348663","messageId":"20180528123422.6718-5-alban.gruin@gmail.com","threadId":"48547","inReplyTo":"20180528123422.6718-1-alban.gruin@gmail.com","subject":"[GSoC][PATCH v4 4/4] rebase: remove -p code from git-rebase--interactive.sh","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2018-05-28T12:34:22Z","receivedAt":"2018-05-28T12:36:25Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"All the code specific to preserve-merges was moved to\ngit-rebase--preserve-merges.sh, and so it’s useless to keep it\nhere.\n\nThe intent of this commit is to clean this script as much as possible to\nprepare a peaceful conversion as a builtin written in C.\n\nSigned-off-by: Alban Gruin <alban.gruin@gmail.com>\n---\n git-rebase--interactive.sh | 802 +--------------------------------------------\n 1 file changed, 8 insertions(+), 794 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2f4941d0f..9884ecd71 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -13,83 +13,6 @@\n # file and written to the tail of $done.\n todo=\"$state_dir\"/git-rebase-todo\n \n-# The rebase command lines that have already been processed.  A line\n-# is moved here when it is first handled, before any associated user\n-# actions.\n-done=\"$state_dir\"/done\n-\n-# The commit message that is planned to be used for any changes that\n-# need to be committed following a user interaction.\n-msg=\"$state_dir\"/message\n-\n-# The file into which is accumulated the suggested commit message for\n-# squash/fixup commands.  When the first of a series of squash/fixups\n-# is seen, the file is created and the commit message from the\n-# previous commit and from the first squash/fixup commit are written\n-# to it.  The commit message for each subsequent squash/fixup commit\n-# is appended to the file as it is processed.\n-#\n-# The first line of the file is of the form\n-#     # This is a combination of $count commits.\n-# where $count is the number of commits whose messages have been\n-# written to the file so far (including the initial \"pick\" commit).\n-# Each time that a commit message is processed, this line is read and\n-# updated.  It is deleted just before the combined commit is made.\n-squash_msg=\"$state_dir\"/message-squash\n-\n-# If the current series of squash/fixups has not yet included a squash\n-# command, then this file exists and holds the commit message of the\n-# original \"pick\" commit.  (If the series ends without a \"squash\"\n-# command, then this can be used as the commit message of the combined\n-# commit without opening the editor.)\n-fixup_msg=\"$state_dir\"/message-fixup\n-\n-# $rewritten is the name of a directory containing files for each\n-# commit that is reachable by at least one merge base of $head and\n-# $upstream. They are not necessarily rewritten, but their children\n-# might be.  This ensures that commits on merged, but otherwise\n-# unrelated side branches are left alone. (Think \"X\" in the man page's\n-# example.)\n-rewritten=\"$state_dir\"/rewritten\n-\n-dropped=\"$state_dir\"/dropped\n-\n-end=\"$state_dir\"/end\n-msgnum=\"$state_dir\"/msgnum\n-\n-# A script to set the GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n-# GIT_AUTHOR_DATE that will be used for the commit that is currently\n-# being rebased.\n-author_script=\"$state_dir\"/author-script\n-\n-# When an \"edit\" rebase command is being processed, the SHA1 of the\n-# commit to be edited is recorded in this file.  When \"git rebase\n-# --continue\" is executed, if there are any staged changes then they\n-# will be amended to the HEAD commit, but only provided the HEAD\n-# commit is still the commit to be edited.  When any other rebase\n-# command is processed, this file is deleted.\n-amend=\"$state_dir\"/amend\n-\n-# For the post-rewrite hook, we make a list of rewritten commits and\n-# their new sha1s.  The rewritten-pending list keeps the sha1s of\n-# commits that have been processed, but not committed yet,\n-# e.g. because they are waiting for a 'squash' command.\n-rewritten_list=\"$state_dir\"/rewritten-list\n-rewritten_pending=\"$state_dir\"/rewritten-pending\n-\n-# Work around Git for Windows' Bash whose \"read\" does not strip CRLF\n-# and leaves CR at the end instead.\n-cr=$(printf \"\\015\")\n-\n-strategy_args=${strategy:+--strategy=$strategy}\n-test -n \"$strategy_opts\" &&\n-eval '\n-\tfor strategy_opt in '\"$strategy_opts\"'\n-\tdo\n-\t\tstrategy_args=\"$strategy_args -X$(git rev-parse --sq-quote \"${strategy_opt#--}\")\"\n-\tdone\n-'\n-\n GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n export GIT_CHERRY_PICK_HELP\n \n@@ -105,15 +28,6 @@ case \"$comment_char\" in\n \t;;\n esac\n \n-warn () {\n-\tprintf '%s\\n' \"$*\" >&2\n-}\n-\n-# Output the commit message for the specified commit.\n-commit_message () {\n-\tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n-}\n-\n orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n@@ -125,33 +39,6 @@ comment_for_reflog () {\n \tesac\n }\n \n-last_count=\n-mark_action_done () {\n-\tsed -e 1q < \"$todo\" >> \"$done\"\n-\tsed -e 1d < \"$todo\" >> \"$todo\".new\n-\tmv -f \"$todo\".new \"$todo\"\n-\tnew_count=$(( $(git stripspace --strip-comments <\"$done\" | wc -l) ))\n-\techo $new_count >\"$msgnum\"\n-\ttotal=$(($new_count + $(git stripspace --strip-comments <\"$todo\" | wc -l)))\n-\techo $total >\"$end\"\n-\tif test \"$last_count\" != \"$new_count\"\n-\tthen\n-\t\tlast_count=$new_count\n-\t\teval_gettext \"Rebasing (\\$new_count/\\$total)\"; printf \"\\r\"\n-\t\ttest -z \"$verbose\" || echo\n-\tfi\n-}\n-\n-# Put the last action marked done at the beginning of the todo list\n-# again. If there has not been an action marked done yet, leave the list of\n-# items on the todo list unchanged.\n-reschedule_last_action () {\n-\ttail -n 1 \"$done\" | cat - \"$todo\" >\"$todo\".new\n-\tsed -e \\$d <\"$done\" >\"$done\".new\n-\tmv -f \"$todo\".new \"$todo\"\n-\tmv -f \"$done\".new \"$done\"\n-}\n-\n append_todo_help () {\n \tgettext \"\n Commands:\n@@ -184,50 +71,6 @@ If you remove a line here THAT COMMIT WILL BE LOST.\n \tfi\n }\n \n-make_patch () {\n-\tsha1_and_parents=\"$(git rev-list --parents -1 \"$1\")\"\n-\tcase \"$sha1_and_parents\" in\n-\t?*' '?*' '?*)\n-\t\tgit diff --cc $sha1_and_parents\n-\t\t;;\n-\t?*' '?*)\n-\t\tgit diff-tree -p \"$1^!\"\n-\t\t;;\n-\t*)\n-\t\techo \"Root commit\"\n-\t\t;;\n-\tesac > \"$state_dir\"/patch\n-\ttest -f \"$msg\" ||\n-\t\tcommit_message \"$1\" > \"$msg\"\n-\ttest -f \"$author_script\" ||\n-\t\tget_author_ident_from_commit \"$1\" > \"$author_script\"\n-}\n-\n-die_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch \"$1\"\n-\tdie \"$2\"\n-}\n-\n-exit_with_patch () {\n-\techo \"$1\" > \"$state_dir\"/stopped-sha\n-\tgit update-ref REBASE_HEAD \"$1\"\n-\tmake_patch $1\n-\tgit rev-parse --verify HEAD > \"$amend\"\n-\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\twarn \"$(eval_gettext \"\\\n-You can amend the commit now, with\n-\n-\tgit commit --amend \\$gpg_sign_opt_quoted\n-\n-Once you are satisfied with your changes, run\n-\n-\tgit rebase --continue\")\"\n-\twarn\n-\texit $2\n-}\n-\n die_abort () {\n \tapply_autostash\n \trm -rf \"$state_dir\"\n@@ -238,30 +81,6 @@ has_action () {\n \ttest -n \"$(git stripspace --strip-comments <\"$1\")\"\n }\n \n-is_empty_commit() {\n-\ttree=$(git rev-parse -q --verify \"$1\"^{tree} 2>/dev/null) || {\n-\t\tsha1=$1\n-\t\tdie \"$(eval_gettext \"\\$sha1: not a commit that can be picked\")\"\n-\t}\n-\tptree=$(git rev-parse -q --verify \"$1\"^^{tree} 2>/dev/null) ||\n-\t\tptree=4b825dc642cb6eb9a060e54bf8d69288fbee4904\n-\ttest \"$tree\" = \"$ptree\"\n-}\n-\n-is_merge_commit()\n-{\n-\tgit rev-parse --verify --quiet \"$1\"^2 >/dev/null 2>&1\n-}\n-\n-# Run command with GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and\n-# GIT_AUTHOR_DATE exported from the current environment.\n-do_with_author () {\n-\t(\n-\t\texport GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_AUTHOR_DATE\n-\t\t\"$@\"\n-\t)\n-}\n-\n git_sequence_editor () {\n \tif test -z \"$GIT_SEQUENCE_EDITOR\"\n \tthen\n@@ -275,455 +94,6 @@ git_sequence_editor () {\n \teval \"$GIT_SEQUENCE_EDITOR\" '\"$@\"'\n }\n \n-pick_one () {\n-\tff=--ff\n-\n-\tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n-\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n-\toutput git rev-parse --verify $sha1 || die \"$(eval_gettext \"Invalid commit name: \\$sha1\")\"\n-\n-\tif is_empty_commit \"$sha1\"\n-\tthen\n-\t\tempty_args=\"--allow-empty\"\n-\tfi\n-\n-\ttest -d \"$rewritten\" &&\n-\t\tpick_one_preserving_merges \"$@\" && return\n-\toutput eval git cherry-pick $allow_rerere_autoupdate $allow_empty_message \\\n-\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t$signoff \"$strategy_args\" $empty_args $ff \"$@\"\n-\n-\t# If cherry-pick dies it leaves the to-be-picked commit unrecorded. Reschedule\n-\t# previous task so this commit is not lost.\n-\tret=$?\n-\tcase \"$ret\" in [01]) ;; *) reschedule_last_action ;; esac\n-\treturn $ret\n-}\n-\n-pick_one_preserving_merges () {\n-\tfast_forward=t\n-\tcase \"$1\" in\n-\t-n)\n-\t\tfast_forward=f\n-\t\tsha1=$2\n-\t\t;;\n-\t*)\n-\t\tsha1=$1\n-\t\t;;\n-\tesac\n-\tsha1=$(git rev-parse $sha1)\n-\n-\tif test -f \"$state_dir\"/current-commit && test \"$fast_forward\" = t\n-\tthen\n-\t\twhile read current_commit\n-\t\tdo\n-\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n-\t\tdone <\"$state_dir\"/current-commit\n-\t\trm \"$state_dir\"/current-commit ||\n-\t\t\tdie \"$(gettext \"Cannot write current commit's replacement sha1\")\"\n-\tfi\n-\n-\techo $sha1 >> \"$state_dir\"/current-commit\n-\n-\t# rewrite parents; if none were rewritten, we can fast-forward.\n-\tnew_parents=\n-\tpend=\" $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\"\n-\tif test \"$pend\" = \" \"\n-\tthen\n-\t\tpend=\" root\"\n-\tfi\n-\twhile [ \"$pend\" != \"\" ]\n-\tdo\n-\t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n-\t\tpend=\"${pend# $p}\"\n-\n-\t\tif test -f \"$rewritten\"/$p\n-\t\tthen\n-\t\t\tnew_p=$(cat \"$rewritten\"/$p)\n-\n-\t\t\t# If the todo reordered commits, and our parent is marked for\n-\t\t\t# rewriting, but hasn't been gotten to yet, assume the user meant to\n-\t\t\t# drop it on top of the current HEAD\n-\t\t\tif test -z \"$new_p\"\n-\t\t\tthen\n-\t\t\t\tnew_p=$(git rev-parse HEAD)\n-\t\t\tfi\n-\n-\t\t\ttest $p != $new_p && fast_forward=f\n-\t\t\tcase \"$new_parents\" in\n-\t\t\t*$new_p*)\n-\t\t\t\t;; # do nothing; that parent is already there\n-\t\t\t*)\n-\t\t\t\tnew_parents=\"$new_parents $new_p\"\n-\t\t\t\t;;\n-\t\t\tesac\n-\t\telse\n-\t\t\tif test -f \"$dropped\"/$p\n-\t\t\tthen\n-\t\t\t\tfast_forward=f\n-\t\t\t\treplacement=\"$(cat \"$dropped\"/$p)\"\n-\t\t\t\ttest -z \"$replacement\" && replacement=root\n-\t\t\t\tpend=\" $replacement$pend\"\n-\t\t\telse\n-\t\t\t\tnew_parents=\"$new_parents $p\"\n-\t\t\tfi\n-\t\tfi\n-\tdone\n-\tcase $fast_forward in\n-\tt)\n-\t\toutput warn \"$(eval_gettext \"Fast-forward to \\$sha1\")\"\n-\t\toutput git reset --hard $sha1 ||\n-\t\t\tdie \"$(eval_gettext \"Cannot fast-forward to \\$sha1\")\"\n-\t\t;;\n-\tf)\n-\t\tfirst_parent=$(expr \"$new_parents\" : ' \\([^ ]*\\)')\n-\n-\t\tif [ \"$1\" != \"-n\" ]\n-\t\tthen\n-\t\t\t# detach HEAD to current parent\n-\t\t\toutput git checkout $first_parent 2> /dev/null ||\n-\t\t\t\tdie \"$(eval_gettext \"Cannot move HEAD to \\$first_parent\")\"\n-\t\tfi\n-\n-\t\tcase \"$new_parents\" in\n-\t\t' '*' '*)\n-\t\t\ttest \"a$1\" = a-n && die \"$(eval_gettext \"Refusing to squash a merge: \\$sha1\")\"\n-\n-\t\t\t# redo merge\n-\t\t\tauthor_script_content=$(get_author_ident_from_commit $sha1)\n-\t\t\teval \"$author_script_content\"\n-\t\t\tmsg_content=\"$(commit_message $sha1)\"\n-\t\t\t# No point in merging the first parent, that's HEAD\n-\t\t\tnew_parents=${new_parents# $first_parent}\n-\t\t\tmerge_args=\"--no-log --no-ff\"\n-\t\t\tif ! do_with_author output eval \\\n-\t\t\t\tgit merge ${gpg_sign_opt:+$(git rev-parse \\\n-\t\t\t\t\t--sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t$allow_rerere_autoupdate \"$merge_args\" \\\n-\t\t\t\t\"$strategy_args\" \\\n-\t\t\t\t-m \"$(git rev-parse --sq-quote \"$msg_content\")\" \\\n-\t\t\t\t\"$new_parents\"\n-\t\t\tthen\n-\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Error redoing merge \\$sha1\")\"\n-\t\t\tfi\n-\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\toutput eval git cherry-pick $allow_rerere_autoupdate \\\n-\t\t\t\t$allow_empty_message \\\n-\t\t\t\t${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")} \\\n-\t\t\t\t\"$strategy_args\" \"$@\" ||\n-\t\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not pick \\$sha1\")\"\n-\t\t\t;;\n-\t\tesac\n-\t\t;;\n-\tesac\n-}\n-\n-this_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"This is the commit message #\\${n}:\"\n-}\n-\n-skip_nth_commit_message () {\n-\tn=$1\n-\teval_gettext \"The commit message #\\${n} will be skipped:\"\n-}\n-\n-update_squash_messages () {\n-\tif test -f \"$squash_msg\"; then\n-\t\tmv \"$squash_msg\" \"$squash_msg\".bak || exit\n-\t\tcount=$(($(sed -n \\\n-\t\t\t-e \"1s/^$comment_char[^0-9]*\\([0-9][0-9]*\\).*/\\1/p\" \\\n-\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(eval_ngettext \\\n-\t\t\t\t\"This is a combination of \\$count commit.\" \\\n-\t\t\t\t\"This is a combination of \\$count commits.\" \\\n-\t\t\t\t$count)\"\n-\t\t\tsed -e 1d -e '2,/^./{\n-\t\t\t\t/^$/d\n-\t\t\t}' <\"$squash_msg\".bak\n-\t\t} >\"$squash_msg\"\n-\telse\n-\t\tcommit_message HEAD >\"$fixup_msg\" ||\n-\t\tdie \"$(eval_gettext \"Cannot write \\$fixup_msg\")\"\n-\t\tcount=2\n-\t\t{\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is a combination of 2 commits.\")\"\n-\t\t\tprintf '%s\\n' \"$comment_char $(gettext \"This is the 1st commit message:\")\"\n-\t\t\techo\n-\t\t\tcat \"$fixup_msg\"\n-\t\t} >\"$squash_msg\"\n-\tfi\n-\tcase $1 in\n-\tsquash)\n-\t\trm -f \"$fixup_msg\"\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(this_nth_commit_message $count)\"\n-\t\techo\n-\t\tcommit_message $2\n-\t\t;;\n-\tfixup)\n-\t\techo\n-\t\tprintf '%s\\n' \"$comment_char $(skip_nth_commit_message $count)\"\n-\t\techo\n-\t\t# Change the space after the comment character to TAB:\n-\t\tcommit_message $2 | git stripspace --comment-lines | sed -e 's/ /\t/'\n-\t\t;;\n-\tesac >>\"$squash_msg\"\n-}\n-\n-peek_next_command () {\n-\tgit stripspace --strip-comments <\"$todo\" | sed -n -e 's/ .*//p' -e q\n-}\n-\n-# A squash/fixup has failed.  Prepare the long version of the squash\n-# commit message, then die_with_patch.  This code path requires the\n-# user to edit the combined commit message for all commits that have\n-# been squashed/fixedup so far.  So also erase the old squash\n-# messages, effectively causing the combined commit to be used as the\n-# new basis for any further squash/fixups.  Args: sha1 rest\n-die_failed_squash() {\n-\tsha1=$1\n-\trest=$2\n-\tmv \"$squash_msg\" \"$msg\" || exit\n-\trm -f \"$fixup_msg\"\n-\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n-\twarn\n-\twarn \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tdie_with_patch $sha1 \"\"\n-}\n-\n-flush_rewritten_pending() {\n-\ttest -s \"$rewritten_pending\" || return\n-\tnewsha1=\"$(git rev-parse HEAD^0)\"\n-\tsed \"s/$/ $newsha1/\" < \"$rewritten_pending\" >> \"$rewritten_list\"\n-\trm -f \"$rewritten_pending\"\n-}\n-\n-record_in_rewritten() {\n-\toldsha1=\"$(git rev-parse $1)\"\n-\techo \"$oldsha1\" >> \"$rewritten_pending\"\n-\n-\tcase \"$(peek_next_command)\" in\n-\tsquash|s|fixup|f)\n-\t\t;;\n-\t*)\n-\t\tflush_rewritten_pending\n-\t\t;;\n-\tesac\n-}\n-\n-do_pick () {\n-\tsha1=$1\n-\trest=$2\n-\tif test \"$(git rev-parse HEAD)\" = \"$squash_onto\"\n-\tthen\n-\t\t# Set the correct commit message and author info on the\n-\t\t# sentinel root before cherry-picking the original changes\n-\t\t# without committing (-n).  Finally, update the sentinel again\n-\t\t# to include these changes.  If the cherry-pick results in a\n-\t\t# conflict, this means our behaviour is similar to a standard\n-\t\t# failed cherry-pick during rebase, with a dirty index to\n-\t\t# resolve before manually running git commit --amend then git\n-\t\t# rebase --continue.\n-\t\tgit commit --allow-empty --allow-empty-message --amend \\\n-\t\t\t   --no-post-rewrite -n -q -C $sha1 $signoff &&\n-\t\t\tpick_one -n $sha1 &&\n-\t\t\tgit commit --allow-empty --allow-empty-message \\\n-\t\t\t\t   --amend --no-post-rewrite -n -q -C $sha1 $signoff \\\n-\t\t\t\t   ${gpg_sign_opt:+\"$gpg_sign_opt\"} ||\n-\t\t\t\t   die_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\telse\n-\t\tpick_one $sha1 ||\n-\t\t\tdie_with_patch $sha1 \"$(eval_gettext \"Could not apply \\$sha1... \\$rest\")\"\n-\tfi\n-}\n-\n-do_next () {\n-\trm -f \"$msg\" \"$author_script\" \"$amend\" \"$state_dir\"/stopped-sha || exit\n-\tread -r command sha1 rest < \"$todo\"\n-\tcase \"$command\" in\n-\t\"$comment_char\"*|''|noop|drop|d)\n-\t\tmark_action_done\n-\t\t;;\n-\t\"$cr\")\n-\t\t# Work around CR left by \"read\" (e.g. with Git for Windows' Bash).\n-\t\tmark_action_done\n-\t\t;;\n-\tpick|p)\n-\t\tcomment_for_reflog pick\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\treword|r)\n-\t\tcomment_for_reflog reword\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tgit commit --amend --no-post-rewrite ${gpg_sign_opt:+\"$gpg_sign_opt\"} \\\n-\t\t\t$allow_empty_message || {\n-\t\t\twarn \"$(eval_gettext \"\\\n-Could not amend commit after successfully picking \\$sha1... \\$rest\n-This is most likely due to an empty commit message, or the pre-commit hook\n-failed. If the pre-commit hook failed, you may need to resolve the issue before\n-you are able to reword the commit.\")\"\n-\t\t\texit_with_patch $sha1 1\n-\t\t}\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tedit|e)\n-\t\tcomment_for_reflog edit\n-\n-\t\tmark_action_done\n-\t\tdo_pick $sha1 \"$rest\"\n-\t\tsha1_abbrev=$(git rev-parse --short $sha1)\n-\t\twarn \"$(eval_gettext \"Stopped at \\$sha1_abbrev... \\$rest\")\"\n-\t\texit_with_patch $sha1 0\n-\t\t;;\n-\tsquash|s|fixup|f)\n-\t\tcase \"$command\" in\n-\t\tsquash|s)\n-\t\t\tsquash_style=squash\n-\t\t\t;;\n-\t\tfixup|f)\n-\t\t\tsquash_style=fixup\n-\t\t\t;;\n-\t\tesac\n-\t\tcomment_for_reflog $squash_style\n-\n-\t\ttest -f \"$done\" && has_action \"$done\" ||\n-\t\t\tdie \"$(eval_gettext \"Cannot '\\$squash_style' without a previous commit\")\"\n-\n-\t\tmark_action_done\n-\t\tupdate_squash_messages $squash_style $sha1\n-\t\tauthor_script_content=$(get_author_ident_from_commit HEAD)\n-\t\techo \"$author_script_content\" > \"$author_script\"\n-\t\teval \"$author_script_content\"\n-\t\tif ! pick_one -n $sha1\n-\t\tthen\n-\t\t\tgit rev-parse --verify HEAD >\"$amend\"\n-\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\tfi\n-\t\tcase \"$(peek_next_command)\" in\n-\t\tsquash|s|fixup|f)\n-\t\t\t# This is an intermediate commit; its message will only be\n-\t\t\t# used in case of trouble.  So use the long version:\n-\t\t\tdo_with_author output git commit --amend --no-verify -F \"$squash_msg\" \\\n-\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\t;;\n-\t\t*)\n-\t\t\t# This is the final command of this squash/fixup group\n-\t\t\tif test -f \"$fixup_msg\"\n-\t\t\tthen\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$fixup_msg\" \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\telse\n-\t\t\t\tcp \"$squash_msg\" \"$GIT_DIR\"/SQUASH_MSG || exit\n-\t\t\t\trm -f \"$GIT_DIR\"/MERGE_MSG\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$GIT_DIR\"/SQUASH_MSG -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie_failed_squash $sha1 \"$rest\"\n-\t\t\tfi\n-\t\t\trm -f \"$squash_msg\" \"$fixup_msg\"\n-\t\t\t;;\n-\t\tesac\n-\t\trecord_in_rewritten $sha1\n-\t\t;;\n-\tx|\"exec\")\n-\t\tread -r command rest < \"$todo\"\n-\t\tmark_action_done\n-\t\teval_gettextln \"Executing: \\$rest\"\n-\t\t\"${SHELL:-@SHELL_PATH@}\" -c \"$rest\" # Actual execution\n-\t\tstatus=$?\n-\t\t# Run in subshell because require_clean_work_tree can die.\n-\t\tdirty=f\n-\t\t(require_clean_work_tree \"rebase\" 2>/dev/null) || dirty=t\n-\t\tif test \"$status\" -ne 0\n-\t\tthen\n-\t\t\twarn \"$(eval_gettext \"Execution failed: \\$rest\")\"\n-\t\t\ttest \"$dirty\" = f ||\n-\t\t\t\twarn \"$(gettext \"and made changes to the index and/or the working tree\")\"\n-\n-\t\t\twarn \"$(gettext \"\\\n-You can fix the problem, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\tif test $status -eq 127\t\t# command not found\n-\t\t\tthen\n-\t\t\t\tstatus=1\n-\t\t\tfi\n-\t\t\texit \"$status\"\n-\t\telif test \"$dirty\" = t\n-\t\tthen\n-\t\t\t# TRANSLATORS: after these lines is a command to be issued by the user\n-\t\t\twarn \"$(eval_gettext \"\\\n-Execution succeeded: \\$rest\n-but left changes to the index and/or the working tree\n-Commit or stash your changes, and then run\n-\n-\tgit rebase --continue\")\"\n-\t\t\twarn\n-\t\t\texit 1\n-\t\tfi\n-\t\t;;\n-\t*)\n-\t\twarn \"$(eval_gettext \"Unknown command: \\$command \\$sha1 \\$rest\")\"\n-\t\tfixtodo=\"$(gettext \"Please fix this using 'git rebase --edit-todo'.\")\"\n-\t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n-\t\tthen\n-\t\t\tdie_with_patch $sha1 \"$fixtodo\"\n-\t\telse\n-\t\t\tdie \"$fixtodo\"\n-\t\tfi\n-\t\t;;\n-\tesac\n-\ttest -s \"$todo\" && return\n-\n-\tcomment_for_reflog finish &&\n-\tnewhead=$(git rev-parse HEAD) &&\n-\tcase $head_name in\n-\trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $onto\" &&\n-\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n-\t\tgit symbolic-ref \\\n-\t\t  -m \"$GIT_REFLOG_ACTION: returning to $head_name\" \\\n-\t\t  HEAD $head_name\n-\t\t;;\n-\tesac && {\n-\t\ttest ! -f \"$state_dir\"/verbose ||\n-\t\t\tgit diff-tree --stat $orig_head..HEAD\n-\t} &&\n-\t{\n-\t\ttest -s \"$rewritten_list\" &&\n-\t\tgit notes copy --for-rewrite=rebase < \"$rewritten_list\" ||\n-\t\ttrue # we don't care if this copying failed\n-\t} &&\n-\thook=\"$(git rev-parse --git-path hooks/post-rewrite)\"\n-\tif test -x \"$hook\" && test -s \"$rewritten_list\"; then\n-\t\t\"$hook\" rebase < \"$rewritten_list\"\n-\t\ttrue # we don't care if this hook failed\n-\tfi &&\n-\t\twarn \"$(eval_gettext \"Successfully rebased and updated \\$head_name.\")\"\n-\n-\treturn 1 # not failure; just to break the do_rest loop\n-}\n-\n-# can only return 0, when the infinite loop breaks\n-do_rest () {\n-\twhile :\n-\tdo\n-\t\tdo_next || break\n-\tdone\n-}\n-\n expand_todo_ids() {\n \tgit rebase--helper --expand-ids\n }\n@@ -761,77 +131,13 @@ get_missing_commit_check_level () {\n initiate_action () {\n \tcase \"$1\" in\n \tcontinue)\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\t# do we have anything to commit?\n-\t\tif git diff-index --cached --quiet HEAD --\n-\t\tthen\n-\t\t\t# Nothing to commit -- skip this commit\n-\n-\t\t\ttest ! -f \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\trm \"$GIT_DIR\"/CHERRY_PICK_HEAD ||\n-\t\t\tdie \"$(gettext \"Could not remove CHERRY_PICK_HEAD\")\"\n-\t\telse\n-\t\t\tif ! test -f \"$author_script\"\n-\t\t\tthen\n-\t\t\t\tgpg_sign_opt_quoted=${gpg_sign_opt:+$(git rev-parse --sq-quote \"$gpg_sign_opt\")}\n-\t\t\t\tdie \"$(eval_gettext \"\\\n-You have staged changes in your working tree.\n-If these changes are meant to be\n-squashed into the previous commit, run:\n-\n-  git commit --amend \\$gpg_sign_opt_quoted\n-\n-If they are meant to go into a new commit, run:\n-\n-  git commit \\$gpg_sign_opt_quoted\n-\n-In both cases, once you're done, continue with:\n-\n-  git rebase --continue\n-\")\"\n-\t\t\tfi\n-\t\t\t. \"$author_script\" ||\n-\t\t\t\tdie \"$(gettext \"Error trying to find the author identity to amend commit\")\"\n-\t\t\tif test -f \"$amend\"\n-\t\t\tthen\n-\t\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n-\t\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n-\t\t\t\tdie \"$(gettext \"\\\n-You have uncommitted changes in your working tree. Please commit them\n-first and then run 'git rebase --continue' again.\")\"\n-\t\t\t\tdo_with_author git commit --amend --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\telse\n-\t\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e \\\n-\t\t\t\t\t${gpg_sign_opt:+\"$gpg_sign_opt\"} $allow_empty_message ||\n-\t\t\t\t\tdie \"$(gettext \"Could not commit staged changes.\")\"\n-\t\t\tfi\n-\t\tfi\n-\n-\t\tif test -r \"$state_dir\"/stopped-sha\n-\t\tthen\n-\t\t\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n-\t\tfi\n-\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tskip)\n \t\tgit rerere clear\n-\n-\t\tif test ! -d \"$rewritten\"\n-\t\tthen\n-\t\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t\t--continue\n-\t\tfi\n-\t\tdo_rest\n-\t\treturn 0\n+\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t\t     --continue\n \t\t;;\n \tedit-todo)\n \t\tgit stripspace --strip-comments <\"$todo\" >\"$todo\".new\n@@ -945,18 +251,14 @@ EOF\n \n \texpand_todo_ids\n \n-\ttest -d \"$rewritten\" || test -n \"$force_rebase\" ||\n+\ttest -n \"$force_rebase\" ||\n \tonto=\"$(git rebase--helper --skip-unnecessary-picks)\" ||\n \tdie \"Could not skip unnecessary pick commands\"\n \n \tcheckout_onto\n-\tif test ! -d \"$rewritten\"\n-\tthen\n-\t\trequire_clean_work_tree \"rebase\"\n-\t\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n-\t\t\t--continue\n-\tfi\n-\tdo_rest\n+\trequire_clean_work_tree \"rebase\"\n+\texec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \\\n+\t     --continue\n }\n \n git_rebase__interactive () {\n@@ -979,91 +281,3 @@ git_rebase__interactive () {\n \n \tcomplete_action\n }\n-\n-git_rebase__interactive__preserve_merges () {\n-\tinitiate_action \"$action\"\n-\tret=$?\n-\tif test $ret = 0; then\n-\t\treturn 0\n-\tfi\n-\n-\tsetup_reflog_action\n-\tinit_basic_state\n-\n-\tif test -z \"$rebase_root\"\n-\tthen\n-\t\tmkdir \"$rewritten\" &&\n-\t\tfor c in $(git merge-base --all $orig_head $upstream)\n-\t\tdo\n-\t\t\techo $onto > \"$rewritten\"/$c ||\n-\t\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\t\tdone\n-\telse\n-\t\tmkdir \"$rewritten\" &&\n-\t\techo $onto > \"$rewritten\"/root ||\n-\t\t\tdie \"$(gettext \"Could not init rewritten commits\")\"\n-\tfi\n-\n-\tinit_revisions_and_shortrevisions\n-\n-\tformat=$(git config --get rebase.instructionFormat)\n-\t# the 'rev-list .. | sed' requires %m to parse; the instruction requires %H to parse\n-\tgit rev-list --format=\"%m%H ${format:-%s}\" \\\n-\t\t--reverse --left-right --topo-order \\\n-\t\t$revisions ${restrict_revision+^$restrict_revision} | \\\n-\t\tsed -n \"s/^>//p\" |\n-\twhile read -r sha1 rest\n-\tdo\n-\t\tif test -z \"$keep_empty\" && is_empty_commit $sha1 && ! is_merge_commit $sha1\n-\t\tthen\n-\t\t\tcomment_out=\"$comment_char \"\n-\t\telse\n-\t\t\tcomment_out=\n-\t\tfi\n-\n-\t\tif test -z \"$rebase_root\"\n-\t\tthen\n-\t\t\tpreserve=t\n-\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n-\t\t\tdo\n-\t\t\t\tif test -f \"$rewritten\"/$p\n-\t\t\t\tthen\n-\t\t\t\t\tpreserve=f\n-\t\t\t\tfi\n-\t\t\tdone\n-\t\telse\n-\t\t\tpreserve=f\n-\t\tfi\n-\t\tif test f = \"$preserve\"\n-\t\tthen\n-\t\t\ttouch \"$rewritten\"/$sha1\n-\t\t\tprintf '%s\\n' \"${comment_out}pick $sha1 $rest\" >>\"$todo\"\n-\t\tfi\n-\tdone\n-\n-\t# Watch for commits that been dropped by --cherry-pick\n-\tmkdir \"$dropped\"\n-\t# Save all non-cherry-picked changes\n-\tgit rev-list $revisions --left-right --cherry-pick | \\\n-\t\tsed -n \"s/^>//p\" > \"$state_dir\"/not-cherry-picks\n-\t# Now all commits and note which ones are missing in\n-\t# not-cherry-picks and hence being dropped\n-\tgit rev-list $revisions |\n-\twhile read rev\n-\tdo\n-\t\tif test -f \"$rewritten\"/$rev &&\n-\t\t   ! sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks >/dev/null\n-\t\tthen\n-\t\t\t# Use -f2 because if rev-list is telling us this commit is\n-\t\t\t# not worthwhile, we don't want to track its multiple heads,\n-\t\t\t# just the history of its first-parent for others that will\n-\t\t\t# be rebasing on top of it\n-\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n-\t\t\tsha1=$(git rev-list -1 $rev)\n-\t\t\tsane_grep -v \"^[a-z][a-z]* $sha1\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n-\t\t\trm \"$rewritten\"/$rev\n-\t\tfi\n-\tdone\n-\n-\tcomplete_action\n-}\n-- \n2.16.1\n\n"}]}