{"thread":{"id":"26148","subject":"[PATCH 00/31] Refactor rebase","startedAt":"2010-12-28T09:30:17Z","lastAt":"2011-07-06T01:48:16Z","messageCount":118,"participants":["Martin von Zweigbergk","Thomas Rast","Johannes Schindelin","Junio C Hamano","Johannes Sixt","Christian Couder","Jeff King","Jakub Narebski","Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":31},"messages":[{"id":"158640","messageId":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":null,"subject":"[PATCH 00/31] Refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:17Z","receivedAt":"2010-12-28T09:30:17Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"For the past two months, I have been working on refactoring the rebase\ncode. See [1] for background information. I have been trying to polish\nthe patch set for some time, but now I don't think I will get much\nfurther without your help.\n\nMy goals with this series were:\n\n (1) Make it easier to add new features to git rebase by reducing the\n amount of duplicated code. FWIW, this series removes about 140 lines\n non-test code.\n\n (2) Make the behavior (towards the user) more consistent between\n interactive and non-interactive rebase. This mainly involves error\n messages and command line options.\n\nWhile not being a goal from the beginning, I have also tried to make\nthe code more readable. This is of course very subjective, so we'll\nsee - maybe in your eyes I just made things worse :-).\n\n\nAt a high level, I tried to do what was suggested by Johannes Sixt in\nthe second entry on [1], namely\n\n\"... to write a command line processor, git-rebase.sh, that sets shell\nvariables from options that it collects from various sources, then\ndispatches to one of git-rebase--interactive.sh, git-rebase--merge.sh,\nor git-rebase--am.sh (the latter two would be stripped-down copies of\nthe current git-rebase.sh).\"\n\n\nPatches 01-04 try to make git-rebase.sh more readable and extensible\nby factoring out the code that reads the saved state from\n.git/rebase-apply or .git/rebase-merge.\n\nPatches 05-09 set the stage for further refactoring by aligning\ngit-rebase.sh and git-rebase--interactive.sh.\n\nPatches 10-16 factor out parts from git-rebase--interactive.sh and let\nit rely on the corresponding code in git-rebase.sh.\n\nPatch 17 just removes a duplicated variable.\n\nPatches 18 and 19 extract the am-specific and merge-specifc rebase\ncode into two new source files (as suggested by Hannes).\n\nPatch 20 makes interactive rebase print the same message as\nnon-interactive rebase in case of conflict.\n\nPatches 21 and 22 prepare for further refactoring by aligning\ninteractive and non-interactive rebase a bit more.\n\nPatch 23 factors out part or all of the handling of --continue, --skip\nand --abort from git-rebase--interactive to git-rebase.sh.\n\nPatches 24-27 makes rebase remember more options passed on the command\nline thoughout the rebase (past any conflicts).\n\nPatches 28-31 remove some unnecessary code.\n\n\nI have tried to separate pure refactoring from changes that make\nfunctional changes, but there are still some functional changes hiding\nin the \"refactoring\" patches. I have tried to point this out in the\ncommit message where applicable, but I'm sure I have missed a lot of\nplaces.\n\n\n/Martin\n\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/160517\n\n\nMartin von Zweigbergk (31):\n  rebase: clearer names for directory variables\n  rebase: refactor reading of state\n  rebase: read state outside loop\n  rebase: remove unused rebase state 'prev_head'\n  rebase: improve detection of rebase in progress\n  rebase: act on command line outside parsing loop\n  rebase: stricter check of standalone sub command\n  rebase: align variable names\n  rebase: align variable content\n  rebase: factor out command line option processing\n  rebase -i: remove now unnecessary directory checks\n  rebase: reorder validation steps\n  rebase: factor out reference parsing\n  rebase: factor out clean work tree check\n  rebase: factor out call to pre-rebase hook\n  rebase -i: support --stat\n  rebase: remove $branch as synonym for $orig_head\n  rebase: extract merge code to new source file\n  rebase: extract am code to new source file\n  rebase: show consistent conflict resolution hint\n  rebase -i: align variable names\n  rebase: make -v a tiny bit more verbose\n  rebase: factor out sub command handling\n  rebase: extract code for writing basic state\n  rebase: remember verbose option\n  rebase: remember strategy and strategy options\n  rebase -m: remember allow_rerere_autoupdate option\n  rebase -m: don't print exit code 2 when merge fails\n  git-rebase--am: remove unnecessary --3way option\n  rebase -i: don't read unused variable preserve_merges\n  rebase -i: remove unnecessary state rebase-root\n\n .gitignore                 |    2 +\n Makefile                   |    2 +\n git-rebase--am.sh          |   30 +++\n git-rebase--interactive.sh |  589 ++++++++++++++------------------------------\n git-rebase--merge.sh       |  151 +++++++++++\n git-rebase.sh              |  477 ++++++++++++++---------------------\n t/t3403-rebase-skip.sh     |    5 +\n t/t3407-rebase-abort.sh    |   10 +\n t/t3418-rebase-continue.sh |   55 ++++\n 9 files changed, 627 insertions(+), 694 deletions(-)\n create mode 100644 git-rebase--am.sh\n create mode 100644 git-rebase--merge.sh\n\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158671","messageId":"1293528648-21873-2-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 01/31] rebase: clearer names for directory variables","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:18Z","receivedAt":"2010-12-28T09:30:18Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Instead of using the old variable name 'dotest' for\n\"$GIT_DIR\"/rebase-merge and no variable for \"$GIT_DIR\"/rebase-apply,\nintroduce two variables 'merge_dir' and 'apply_dir' for these paths.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |  141 +++++++++++++++++++++++++++++----------------------------\n 1 files changed, 71 insertions(+), 70 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d8e1903..79f8008 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -46,7 +46,8 @@ unset newbase\n strategy=recursive\n strategy_opts=\n do_merge=\n-dotest=\"$GIT_DIR\"/rebase-merge\n+merge_dir=\"$GIT_DIR\"/rebase-merge\n+apply_dir=\"$GIT_DIR\"/rebase-apply\n prec=4\n verbose=\n diffstat=\n@@ -58,7 +59,7 @@ allow_rerere_autoupdate=\n \n continue_merge () {\n \ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n-\ttest -d \"$dotest\" || die \"$dotest directory does not exist\"\n+\ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n \n \tunmerged=$(git ls-files -u)\n \tif test -n \"$unmerged\"\n@@ -68,7 +69,7 @@ continue_merge () {\n \t\tdie \"$RESOLVEMSG\"\n \tfi\n \n-\tcmt=`cat \"$dotest/current\"`\n+\tcmt=`cat \"$merge_dir/current\"`\n \tif ! git diff-index --quiet --ignore-submodules HEAD --\n \tthen\n \t\tif ! git commit --no-verify -C \"$cmt\"\n@@ -81,7 +82,7 @@ continue_merge () {\n \t\tthen\n \t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n \t\tfi\n-\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$dotest/rewritten\"\n+\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$merge_dir/rewritten\"\n \telse\n \t\tif test -z \"$GIT_QUIET\"\n \t\tthen\n@@ -93,22 +94,22 @@ continue_merge () {\n \n \tprev_head=`git rev-parse HEAD^0`\n \t# save the resulting commit so we can read-tree on it later\n-\techo \"$prev_head\" > \"$dotest/prev_head\"\n+\techo \"$prev_head\" > \"$merge_dir/prev_head\"\n \n \t# onto the next patch:\n \tmsgnum=$(($msgnum + 1))\n-\techo \"$msgnum\" >\"$dotest/msgnum\"\n+\techo \"$msgnum\" >\"$merge_dir/msgnum\"\n }\n \n call_merge () {\n-\tcmt=\"$(cat \"$dotest/cmt.$1\")\"\n-\techo \"$cmt\" > \"$dotest/current\"\n+\tcmt=\"$(cat \"$merge_dir/cmt.$1\")\"\n+\techo \"$cmt\" > \"$merge_dir/current\"\n \thd=$(git rev-parse --verify HEAD)\n \tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n-\tmsgnum=$(cat \"$dotest/msgnum\")\n-\tend=$(cat \"$dotest/end\")\n+\tmsgnum=$(cat \"$merge_dir/msgnum\")\n+\tend=$(cat \"$merge_dir/end\")\n \teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n-\teval GITHEAD_$hd='$(cat \"$dotest/onto_name\")'\n+\teval GITHEAD_$hd='$(cat \"$merge_dir/onto_name\")'\n \texport GITHEAD_$cmt GITHEAD_$hd\n \tif test -n \"$GIT_QUIET\"\n \tthen\n@@ -138,9 +139,9 @@ call_merge () {\n \n move_to_original_branch () {\n \ttest -z \"$head_name\" &&\n-\t\thead_name=\"$(cat \"$dotest\"/head-name)\" &&\n-\t\tonto=\"$(cat \"$dotest\"/onto)\" &&\n-\t\torig_head=\"$(cat \"$dotest\"/orig-head)\"\n+\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n+\t\tonto=\"$(cat \"$merge_dir\"/onto)\" &&\n+\t\torig_head=\"$(cat \"$merge_dir\"/orig-head)\"\n \tcase \"$head_name\" in\n \trefs/*)\n \t\tmessage=\"rebase finished: $head_name onto $onto\"\n@@ -154,12 +155,12 @@ move_to_original_branch () {\n \n finish_rb_merge () {\n \tmove_to_original_branch\n-\tgit notes copy --for-rewrite=rebase < \"$dotest\"/rewritten\n+\tgit notes copy --for-rewrite=rebase < \"$merge_dir\"/rewritten\n \tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n-\t\ttest -s \"$dotest\"/rewritten; then\n-\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$dotest\"/rewritten\n+\t\ttest -s \"$merge_dir\"/rewritten; then\n+\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$merge_dir\"/rewritten\n \tfi\n-\trm -r \"$dotest\"\n+\trm -r \"$merge_dir\"\n \tsay All done.\n }\n \n@@ -183,7 +184,7 @@ is_interactive () {\n \t\texport GIT_EDITOR\n \tfi\n \n-\ttest -n \"$interactive_rebase\" || test -f \"$dotest\"/interactive\n+\ttest -n \"$interactive_rebase\" || test -f \"$merge_dir\"/interactive\n }\n \n run_pre_rebase_hook () {\n@@ -195,7 +196,7 @@ run_pre_rebase_hook () {\n \tfi\n }\n \n-test -f \"$GIT_DIR\"/rebase-apply/applying &&\n+test -f \"$apply_dir\"/applying &&\n \tdie 'It looks like git-am is in progress. Cannot rebase.'\n \n is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n@@ -210,7 +211,7 @@ do\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n \t--continue)\n-\t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n+\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit update-index --ignore-submodules --refresh &&\n@@ -219,13 +220,13 @@ do\n \t\t\techo \"mark them as resolved using git add\"\n \t\t\texit 1\n \t\t}\n-\t\tif test -d \"$dotest\"\n+\t\tif test -d \"$merge_dir\"\n \t\tthen\n-\t\t\tprev_head=$(cat \"$dotest/prev_head\")\n-\t\t\tend=$(cat \"$dotest/end\")\n-\t\t\tmsgnum=$(cat \"$dotest/msgnum\")\n-\t\t\tonto=$(cat \"$dotest/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n+\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n+\t\t\tend=$(cat \"$merge_dir/end\")\n+\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n+\t\t\tonto=$(cat \"$merge_dir/onto\")\n+\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\tcontinue_merge\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n@@ -235,28 +236,28 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n-\t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n-\t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$GIT_DIR\"/rebase-apply/quiet)\n+\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n+\t\tonto=$(cat \"$apply_dir\"/onto) &&\n+\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n+\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n \t\t;;\n \t--skip)\n-\t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n+\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit reset --hard HEAD || exit $?\n-\t\tif test -d \"$dotest\"\n+\t\tif test -d \"$merge_dir\"\n \t\tthen\n \t\t\tgit rerere clear\n-\t\t\tprev_head=$(cat \"$dotest/prev_head\")\n-\t\t\tend=$(cat \"$dotest/end\")\n-\t\t\tmsgnum=$(cat \"$dotest/msgnum\")\n+\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n+\t\t\tend=$(cat \"$merge_dir/end\")\n+\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n \t\t\tmsgnum=$(($msgnum + 1))\n-\t\t\tonto=$(cat \"$dotest/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n+\t\t\tonto=$(cat \"$merge_dir/onto\")\n+\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n \t\t\t\tcall_merge \"$msgnum\"\n@@ -265,31 +266,31 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n-\t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n-\t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$GIT_DIR\"/rebase-apply/quiet)\n+\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n+\t\tonto=$(cat \"$apply_dir\"/onto) &&\n+\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n+\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n \t\t;;\n \t--abort)\n-\t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n+\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit rerere clear\n \n-\t\ttest -d \"$dotest\" || dotest=\"$GIT_DIR\"/rebase-apply\n+\t\ttest -d \"$merge_dir\" || merge_dir=\"$apply_dir\"\n \n-\t\thead_name=\"$(cat \"$dotest\"/head-name)\" &&\n+\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n \t\tcase \"$head_name\" in\n \t\trefs/*)\n \t\t\tgit symbolic-ref HEAD $head_name ||\n \t\t\tdie \"Could not move back to $head_name\"\n \t\t\t;;\n \t\tesac\n-\t\tgit reset --hard $(cat \"$dotest/orig-head\")\n-\t\trm -r \"$dotest\"\n+\t\tgit reset --hard $(cat \"$merge_dir/orig-head\")\n+\t\trm -r \"$merge_dir\"\n \t\texit\n \t\t;;\n \t--onto)\n@@ -388,31 +389,31 @@ test $# -gt 2 && usage\n \n if test $# -eq 0 && test -z \"$rebase_root\"\n then\n-\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply || usage\n-\ttest -d \"$dotest\" -o -f \"$GIT_DIR\"/rebase-apply/rebasing &&\n+\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" || usage\n+\ttest -d \"$merge_dir\" -o -f \"$apply_dir\"/rebasing &&\n \t\tdie 'A rebase is in progress, try --continue, --skip or --abort.'\n fi\n \n-# Make sure we do not have $GIT_DIR/rebase-apply\n+# Make sure we do not have $apply_dir or $merge_dir\n if test -z \"$do_merge\"\n then\n-\tif mkdir \"$GIT_DIR\"/rebase-apply 2>/dev/null\n+\tif mkdir \"$apply_dir\" 2>/dev/null\n \tthen\n-\t\trmdir \"$GIT_DIR\"/rebase-apply\n+\t\trmdir \"$apply_dir\"\n \telse\n \t\techo >&2 '\n It seems that I cannot create a rebase-apply directory, and\n I wonder if you are in the middle of patch application or another\n rebase.  If that is not the case, please\n-\trm -fr '\"$GIT_DIR\"'/rebase-apply\n+\trm -fr '\"$apply_dir\"'\n and run me again.  I am stopping in case you still have something\n valuable there.'\n \t\texit 1\n \tfi\n else\n-\tif test -d \"$dotest\"\n+\tif test -d \"$merge_dir\"\n \tthen\n-\t\tdie \"previous rebase directory $dotest still exists.\" \\\n+\t\tdie \"previous rebase directory $merge_dir still exists.\" \\\n \t\t\t'Try git rebase (--continue | --abort | --skip)'\n \tfi\n fi\n@@ -560,35 +561,35 @@ then\n \tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \tret=$?\n-\ttest 0 != $ret -a -d \"$GIT_DIR\"/rebase-apply &&\n-\t\techo $head_name > \"$GIT_DIR\"/rebase-apply/head-name &&\n-\t\techo $onto > \"$GIT_DIR\"/rebase-apply/onto &&\n-\t\techo $orig_head > \"$GIT_DIR\"/rebase-apply/orig-head &&\n-\t\techo \"$GIT_QUIET\" > \"$GIT_DIR\"/rebase-apply/quiet\n+\ttest 0 != $ret -a -d \"$apply_dir\" &&\n+\t\techo $head_name > \"$apply_dir/head-name\" &&\n+\t\techo $onto > \"$apply_dir/onto\" &&\n+\t\techo $orig_head > \"$apply_dir/orig-head\" &&\n+\t\techo \"$GIT_QUIET\" > \"$apply_dir/quiet\"\n \texit $ret\n fi\n \n # start doing a rebase with git-merge\n # this is rename-aware if the recursive (default) strategy is used\n \n-mkdir -p \"$dotest\"\n-echo \"$onto\" > \"$dotest/onto\"\n-echo \"$onto_name\" > \"$dotest/onto_name\"\n+mkdir -p \"$merge_dir\"\n+echo \"$onto\" > \"$merge_dir/onto\"\n+echo \"$onto_name\" > \"$merge_dir/onto_name\"\n prev_head=$orig_head\n-echo \"$prev_head\" > \"$dotest/prev_head\"\n-echo \"$orig_head\" > \"$dotest/orig-head\"\n-echo \"$head_name\" > \"$dotest/head-name\"\n-echo \"$GIT_QUIET\" > \"$dotest/quiet\"\n+echo \"$prev_head\" > \"$merge_dir/prev_head\"\n+echo \"$orig_head\" > \"$merge_dir/orig-head\"\n+echo \"$head_name\" > \"$merge_dir/head-name\"\n+echo \"$GIT_QUIET\" > \"$merge_dir/quiet\"\n \n msgnum=0\n for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n do\n \tmsgnum=$(($msgnum + 1))\n-\techo \"$cmt\" > \"$dotest/cmt.$msgnum\"\n+\techo \"$cmt\" > \"$merge_dir/cmt.$msgnum\"\n done\n \n-echo 1 >\"$dotest/msgnum\"\n-echo $msgnum >\"$dotest/end\"\n+echo 1 >\"$merge_dir/msgnum\"\n+echo $msgnum >\"$merge_dir/end\"\n \n end=$msgnum\n msgnum=1\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158660","messageId":"1293528648-21873-3-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 02/31] rebase: refactor reading of state","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:19Z","receivedAt":"2010-12-28T09:30:19Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The code reading the state saved in $merge_dir or $rebase_dir is\ncurrently spread out in many places, making it harder to read and to\nintroduce additional state. Extract this code into one method that reads\nthe state.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |   53 +++++++++++++++++++++++------------------------------\n 1 files changed, 23 insertions(+), 30 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 79f8008..bf144dc 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -57,6 +57,22 @@ rebase_root=\n force_rebase=\n allow_rerere_autoupdate=\n \n+read_state () {\n+\tif test -d \"$merge_dir\"\n+\tthen\n+\t\tstate_dir=\"$merge_dir\"\n+\t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n+\t\tend=$(cat \"$merge_dir\"/end) &&\n+\t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n+\telse\n+\t\tstate_dir=\"$apply_dir\"\n+\tfi &&\n+\thead_name=$(cat \"$state_dir\"/head-name) &&\n+\tonto=$(cat \"$state_dir\"/onto) &&\n+\torig_head=$(cat \"$state_dir\"/orig-head) &&\n+\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n+}\n+\n continue_merge () {\n \ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n \ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n@@ -138,10 +154,6 @@ call_merge () {\n }\n \n move_to_original_branch () {\n-\ttest -z \"$head_name\" &&\n-\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n-\t\tonto=\"$(cat \"$merge_dir\"/onto)\" &&\n-\t\torig_head=\"$(cat \"$merge_dir\"/orig-head)\"\n \tcase \"$head_name\" in\n \trefs/*)\n \t\tmessage=\"rebase finished: $head_name onto $onto\"\n@@ -220,13 +232,9 @@ do\n \t\t\techo \"mark them as resolved using git add\"\n \t\t\texit 1\n \t\t}\n+\t\tread_state\n \t\tif test -d \"$merge_dir\"\n \t\tthen\n-\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n-\t\t\tend=$(cat \"$merge_dir/end\")\n-\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n-\t\t\tonto=$(cat \"$merge_dir/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\tcontinue_merge\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n@@ -236,10 +244,6 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n-\t\tonto=$(cat \"$apply_dir\"/onto) &&\n-\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n@@ -249,15 +253,11 @@ do\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit reset --hard HEAD || exit $?\n+\t\tread_state\n \t\tif test -d \"$merge_dir\"\n \t\tthen\n \t\t\tgit rerere clear\n-\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n-\t\t\tend=$(cat \"$merge_dir/end\")\n-\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n \t\t\tmsgnum=$(($msgnum + 1))\n-\t\t\tonto=$(cat \"$merge_dir/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n \t\t\t\tcall_merge \"$msgnum\"\n@@ -266,10 +266,6 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n-\t\tonto=$(cat \"$apply_dir\"/onto) &&\n-\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n@@ -279,18 +275,15 @@ do\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit rerere clear\n-\n-\t\ttest -d \"$merge_dir\" || merge_dir=\"$apply_dir\"\n-\n-\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n+\t\tread_state\n \t\tcase \"$head_name\" in\n \t\trefs/*)\n \t\t\tgit symbolic-ref HEAD $head_name ||\n \t\t\tdie \"Could not move back to $head_name\"\n \t\t\t;;\n \t\tesac\n-\t\tgit reset --hard $(cat \"$merge_dir/orig-head\")\n-\t\trm -r \"$merge_dir\"\n+\t\tgit reset --hard $orig_head\n+\t\trm -r \"$state_dir\"\n \t\texit\n \t\t;;\n \t--onto)\n@@ -573,12 +566,12 @@ fi\n # this is rename-aware if the recursive (default) strategy is used\n \n mkdir -p \"$merge_dir\"\n-echo \"$onto\" > \"$merge_dir/onto\"\n echo \"$onto_name\" > \"$merge_dir/onto_name\"\n prev_head=$orig_head\n echo \"$prev_head\" > \"$merge_dir/prev_head\"\n-echo \"$orig_head\" > \"$merge_dir/orig-head\"\n echo \"$head_name\" > \"$merge_dir/head-name\"\n+echo \"$onto\" > \"$merge_dir/onto\"\n+echo \"$orig_head\" > \"$merge_dir/orig-head\"\n echo \"$GIT_QUIET\" > \"$merge_dir/quiet\"\n \n msgnum=0\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158666","messageId":"1293528648-21873-4-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 03/31] rebase: read state outside loop","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:20Z","receivedAt":"2010-12-28T09:30:20Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The 'onto_name' state used in 'git rebase --merge' is currently read\nonce for each commit that need to be applied. It doesn't change\nbetween each iteration, however, so it should be moved out of the\nloop. This also makes the code more readable. Also remove the unused\nvariable 'end'.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex bf144dc..9be831e 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -62,6 +62,7 @@ read_state () {\n \tthen\n \t\tstate_dir=\"$merge_dir\"\n \t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n+\t\tonto_name=$(cat \"$merge_dir\"/onto_name) &&\n \t\tend=$(cat \"$merge_dir\"/end) &&\n \t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n \telse\n@@ -123,9 +124,8 @@ call_merge () {\n \thd=$(git rev-parse --verify HEAD)\n \tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n \tmsgnum=$(cat \"$merge_dir/msgnum\")\n-\tend=$(cat \"$merge_dir/end\")\n \teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n-\teval GITHEAD_$hd='$(cat \"$merge_dir/onto_name\")'\n+\teval GITHEAD_$hd='$onto_name'\n \texport GITHEAD_$cmt GITHEAD_$hd\n \tif test -n \"$GIT_QUIET\"\n \tthen\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158642","messageId":"1293528648-21873-5-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 04/31] rebase: remove unused rebase state 'prev_head'","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:21Z","receivedAt":"2010-12-28T09:30:21Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The state stored in $GIT_DIR/rebase-merge/prev_head was introduced in\n58634db (rebase: Allow merge strategies to be used when rebasing,\n2006-06-21), but it was never used and should therefore be removed.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |    8 --------\n 1 files changed, 0 insertions(+), 8 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 9be831e..af9bd14 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -61,7 +61,6 @@ read_state () {\n \tif test -d \"$merge_dir\"\n \tthen\n \t\tstate_dir=\"$merge_dir\"\n-\t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n \t\tonto_name=$(cat \"$merge_dir\"/onto_name) &&\n \t\tend=$(cat \"$merge_dir\"/end) &&\n \t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n@@ -75,7 +74,6 @@ read_state () {\n }\n \n continue_merge () {\n-\ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n \ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n \n \tunmerged=$(git ls-files -u)\n@@ -109,10 +107,6 @@ continue_merge () {\n \ttest -z \"$GIT_QUIET\" &&\n \tGIT_PAGER='' git log --format=%s -1 \"$cmt\"\n \n-\tprev_head=`git rev-parse HEAD^0`\n-\t# save the resulting commit so we can read-tree on it later\n-\techo \"$prev_head\" > \"$merge_dir/prev_head\"\n-\n \t# onto the next patch:\n \tmsgnum=$(($msgnum + 1))\n \techo \"$msgnum\" >\"$merge_dir/msgnum\"\n@@ -567,8 +561,6 @@ fi\n \n mkdir -p \"$merge_dir\"\n echo \"$onto_name\" > \"$merge_dir/onto_name\"\n-prev_head=$orig_head\n-echo \"$prev_head\" > \"$merge_dir/prev_head\"\n echo \"$head_name\" > \"$merge_dir/head-name\"\n echo \"$onto\" > \"$merge_dir/onto\"\n echo \"$orig_head\" > \"$merge_dir/orig-head\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158641","messageId":"1293528648-21873-6-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 05/31] rebase: improve detection of rebase in progress","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:22Z","receivedAt":"2010-12-28T09:30:22Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Detect early on if a rebase is in progress and what type of rebase it\nis (interactive, merge-based or am-based). This prepares for further\nrefactoring where am-based rebase will be dispatched to\ngit-rebase--am.sh and merge-based rebase will be dispatched to\ngit-rebase--merge.sh.\n\nThe idea is to use the same variables whether the type of rebase was\ndetected from rebase-apply/ or rebase-merge/ directories or from the\ncommand line options. This will make the code more readable and will\nlater also make it easier to dispatch to the type-specific scripts.\n\nAlso show a consistent error message independent of the type of rebase\nthat was in progress and remove the obsolete wording about being in\nthe middle of a 'patch application', since that (an existing\n\"$GIT_DIR\"/rebase-apply/applying) aborts 'git rebase' at an earlier\nstage.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nCurrently, the existence of rebase-merge/ is tested with 'test -d',\nwhile the existence of rebase-apply/ is tested by creating the\ndirectory and then deleting it again. Any good reason for this?\n\n git-rebase.sh |   80 +++++++++++++++++++++++++++++---------------------------\n 1 files changed, 41 insertions(+), 39 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex af9bd14..718cb26 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -56,16 +56,19 @@ git_am_opt=\n rebase_root=\n force_rebase=\n allow_rerere_autoupdate=\n+# Non-empty if a rebase was in progress when 'git rebase' was invoked\n+in_progress=\n+# One of {am, merge, interactive}\n+type=\n+# One of {\"$GIT_DIR\"/rebase-apply, \"$GIT_DIR\"/rebase-merge}\n+state_dir=\n \n read_state () {\n-\tif test -d \"$merge_dir\"\n+\tif test \"$type\" = merge\n \tthen\n-\t\tstate_dir=\"$merge_dir\"\n-\t\tonto_name=$(cat \"$merge_dir\"/onto_name) &&\n-\t\tend=$(cat \"$merge_dir\"/end) &&\n-\t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n-\telse\n-\t\tstate_dir=\"$apply_dir\"\n+\t\tonto_name=$(cat \"$state_dir\"/onto_name) &&\n+\t\tend=$(cat \"$state_dir\"/end) &&\n+\t\tmsgnum=$(cat \"$state_dir\"/msgnum)\n \tfi &&\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n@@ -207,6 +210,23 @@ test -f \"$apply_dir\"/applying &&\n \n is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n \n+if test -d \"$apply_dir\"\n+then\n+\ttype=am\n+\tstate_dir=\"$apply_dir\"\n+elif test -d \"$merge_dir\"\n+then\n+\tif test -f \"$merge_dir\"/interactive\n+\tthen\n+\t\ttype=interactive\n+\t\tinteractive_rebase=explicit\n+\telse\n+\t\ttype=merge\n+\tfi\n+\tstate_dir=\"$merge_dir\"\n+fi\n+test -n \"$type\" && in_progress=t\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -217,8 +237,7 @@ do\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n \t--continue)\n-\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n-\t\t\tdie \"No rebase in progress?\"\n+\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \n \t\tgit update-index --ignore-submodules --refresh &&\n \t\tgit diff-files --quiet --ignore-submodules || {\n@@ -243,8 +262,7 @@ do\n \t\texit\n \t\t;;\n \t--skip)\n-\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n-\t\t\tdie \"No rebase in progress?\"\n+\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \n \t\tgit reset --hard HEAD || exit $?\n \t\tread_state\n@@ -265,8 +283,7 @@ do\n \t\texit\n \t\t;;\n \t--abort)\n-\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n-\t\t\tdie \"No rebase in progress?\"\n+\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \n \t\tgit rerere clear\n \t\tread_state\n@@ -374,37 +391,22 @@ do\n done\n test $# -gt 2 && usage\n \n-if test $# -eq 0 && test -z \"$rebase_root\"\n+# Make sure no rebase is in progress\n+if test -n \"$in_progress\"\n then\n-\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" || usage\n-\ttest -d \"$merge_dir\" -o -f \"$apply_dir\"/rebasing &&\n-\t\tdie 'A rebase is in progress, try --continue, --skip or --abort.'\n-fi\n-\n-# Make sure we do not have $apply_dir or $merge_dir\n-if test -z \"$do_merge\"\n-then\n-\tif mkdir \"$apply_dir\" 2>/dev/null\n-\tthen\n-\t\trmdir \"$apply_dir\"\n-\telse\n-\t\techo >&2 '\n-It seems that I cannot create a rebase-apply directory, and\n-I wonder if you are in the middle of patch application or another\n-rebase.  If that is not the case, please\n-\trm -fr '\"$apply_dir\"'\n+\tdie '\n+It seems that there is already a '\"${state_dir##*/}\"' directory, and\n+I wonder if you are in the middle of another rebase.  If that is the\n+case, please try\n+\tgit rebase (--continue | --abort | --skip)\n+If that is not the case, please\n+\trm -fr '\"$state_dir\"'\n and run me again.  I am stopping in case you still have something\n valuable there.'\n-\t\texit 1\n-\tfi\n-else\n-\tif test -d \"$merge_dir\"\n-\tthen\n-\t\tdie \"previous rebase directory $merge_dir still exists.\" \\\n-\t\t\t'Try git rebase (--continue | --abort | --skip)'\n-\tfi\n fi\n \n+test $# -eq 0 && test -z \"$rebase_root\" && usage\n+\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n if test -z \"$rebase_root\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158643","messageId":"1293528648-21873-7-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 06/31] rebase: act on command line outside parsing loop","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:23Z","receivedAt":"2010-12-28T09:30:23Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"To later be able to use the command line processing in git-rebase.sh\nfor both interactive and non-interactive rebases, move anything that\nis specific to non-interactive rebase outside of the parsing\nloop. Keep only parsing and validation of command line options in the\nloop.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nMay want to view this patch with --ignore-all-space.\n\n git-rebase--interactive.sh |  300 ++++++++++++++++++++++----------------------\n git-rebase.sh              |  126 ++++++++++---------\n 2 files changed, 217 insertions(+), 209 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a5ffd9a..8cbdd3f 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -866,152 +866,158 @@ first and then run 'git rebase --continue' again.\"\n \t\t;;\n \t--)\n \t\tshift\n-\t\ttest -z \"$REBASE_ROOT\" -a $# -ge 1 -a $# -le 2 ||\n-\t\ttest ! -z \"$REBASE_ROOT\" -a $# -le 1 || usage\n-\t\ttest -d \"$DOTEST\" &&\n-\t\t\tdie \"Interactive rebase already started\"\n-\n-\t\tgit var GIT_COMMITTER_IDENT >/dev/null ||\n-\t\t\tdie \"You need to set your committer info first\"\n-\n-\t\tif test -z \"$REBASE_ROOT\"\n-\t\tthen\n-\t\t\tUPSTREAM_ARG=\"$1\"\n-\t\t\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\t\t\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n-\t\t\tshift\n-\t\telse\n-\t\t\tUPSTREAM=\n-\t\t\tUPSTREAM_ARG=--root\n-\t\t\ttest -z \"$ONTO\" &&\n-\t\t\t\tdie \"You must specify --onto when using --root\"\n-\t\tfi\n-\t\trun_pre_rebase_hook \"$UPSTREAM_ARG\" \"$@\"\n-\n-\t\tcomment_for_reflog start\n-\n-\t\trequire_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n-\t\tif test ! -z \"$1\"\n-\t\tthen\n-\t\t\toutput git checkout \"$1\" ||\n-\t\t\t\tdie \"Could not checkout $1\"\n-\t\tfi\n+\t\tbreak\n+\t\t;;\n+\tesac\n+\tshift\n+done\n \n-\t\tHEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n-\t\tmkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n+test -z \"$REBASE_ROOT\" -a $# -ge 1 -a $# -le 2 ||\n+test ! -z \"$REBASE_ROOT\" -a $# -le 1 || usage\n+test -d \"$DOTEST\" &&\n+\tdie \"Interactive rebase already started\"\n \n-\t\t: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n-\t\tgit symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n-\t\t\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n+git var GIT_COMMITTER_IDENT >/dev/null ||\n+\tdie \"You need to set your committer info first\"\n \n-\t\techo $HEAD > \"$DOTEST\"/head\n-\t\tcase \"$REBASE_ROOT\" in\n-\t\t'')\n-\t\t\trm -f \"$DOTEST\"/rebase-root ;;\n-\t\t*)\n-\t\t\t: >\"$DOTEST\"/rebase-root ;;\n-\t\tesac\n-\t\techo $ONTO > \"$DOTEST\"/onto\n-\t\ttest -z \"$STRATEGY\" || echo \"$STRATEGY\" > \"$DOTEST\"/strategy\n-\t\ttest t = \"$VERBOSE\" && : > \"$DOTEST\"/verbose\n-\t\tif test t = \"$PRESERVE_MERGES\"\n-\t\tthen\n-\t\t\tif test -z \"$REBASE_ROOT\"\n-\t\t\tthen\n-\t\t\t\tmkdir \"$REWRITTEN\" &&\n-\t\t\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\n-\t\t\t\tdo\n-\t\t\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n-\t\t\t\t\t\tdie \"Could not init rewritten commits\"\n-\t\t\t\tdone\n-\t\t\telse\n-\t\t\t\tmkdir \"$REWRITTEN\" &&\n-\t\t\t\techo $ONTO > \"$REWRITTEN\"/root ||\n-\t\t\t\t\tdie \"Could not init rewritten commits\"\n-\t\t\tfi\n-\t\t\t# No cherry-pick because our first pass is to determine\n-\t\t\t# parents to rewrite and skipping dropped commits would\n-\t\t\t# prematurely end our probe\n-\t\t\tMERGES_OPTION=\n-\t\t\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n-\t\telse\n-\t\t\tMERGES_OPTION=\"--no-merges --cherry-pick\"\n-\t\tfi\n-\n-\t\tSHORTHEAD=$(git rev-parse --short $HEAD)\n-\t\tSHORTONTO=$(git rev-parse --short $ONTO)\n-\t\tif test -z \"$REBASE_ROOT\"\n-\t\t\t# this is now equivalent to ! -z \"$UPSTREAM\"\n-\t\tthen\n-\t\t\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\n-\t\t\tREVISIONS=$UPSTREAM...$HEAD\n-\t\t\tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n-\t\telse\n-\t\t\tREVISIONS=$ONTO...$HEAD\n-\t\t\tSHORTREVISIONS=$SHORTHEAD\n-\t\tfi\n-\t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n-\t\t\t--abbrev=7 --reverse --left-right --topo-order \\\n-\t\t\t$REVISIONS | \\\n-\t\t\tsed -n \"s/^>//p\" |\n-\t\twhile read -r shortsha1 rest\n+if test -z \"$REBASE_ROOT\"\n+then\n+\tUPSTREAM_ARG=\"$1\"\n+\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n+\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n+\tshift\n+else\n+\tUPSTREAM=\n+\tUPSTREAM_ARG=--root\n+\ttest -z \"$ONTO\" &&\n+\tdie \"You must specify --onto when using --root\"\n+fi\n+run_pre_rebase_hook \"$UPSTREAM_ARG\" \"$@\"\n+\n+comment_for_reflog start\n+\n+require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n+\n+if test ! -z \"$1\"\n+then\n+\toutput git checkout \"$1\" ||\n+\t\tdie \"Could not checkout $1\"\n+fi\n+\n+HEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n+mkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n+\n+: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n+git symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n+\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n+\n+echo $HEAD > \"$DOTEST\"/head\n+case \"$REBASE_ROOT\" in\n+'')\n+\trm -f \"$DOTEST\"/rebase-root ;;\n+*)\n+\t: >\"$DOTEST\"/rebase-root ;;\n+esac\n+echo $ONTO > \"$DOTEST\"/onto\n+test -z \"$STRATEGY\" || echo \"$STRATEGY\" > \"$DOTEST\"/strategy\n+test t = \"$VERBOSE\" && : > \"$DOTEST\"/verbose\n+if test t = \"$PRESERVE_MERGES\"\n+then\n+\tif test -z \"$REBASE_ROOT\"\n+\tthen\n+\t\tmkdir \"$REWRITTEN\" &&\n+\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\n \t\tdo\n-\t\t\tif test t != \"$PRESERVE_MERGES\"\n-\t\t\tthen\n-\t\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n-\t\t\telse\n-\t\t\t\tsha1=$(git rev-parse $shortsha1)\n-\t\t\t\tif test -z \"$REBASE_ROOT\"\n-\t\t\t\tthen\n-\t\t\t\t\tpreserve=t\n-\t\t\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n-\t\t\t\t\tdo\n-\t\t\t\t\t\tif test -f \"$REWRITTEN\"/$p -a \\( $p != $ONTO -o $sha1 = $first_after_upstream \\)\n-\t\t\t\t\t\tthen\n-\t\t\t\t\t\t\tpreserve=f\n-\t\t\t\t\t\tfi\n-\t\t\t\t\tdone\n-\t\t\t\telse\n-\t\t\t\t\tpreserve=f\n-\t\t\t\tfi\n-\t\t\t\tif test f = \"$preserve\"\n-\t\t\t\tthen\n-\t\t\t\t\ttouch \"$REWRITTEN\"/$sha1\n-\t\t\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n-\t\t\t\tfi\n-\t\t\tfi\n+\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n+\t\t\t\tdie \"Could not init rewritten commits\"\n \t\tdone\n-\n-\t\t# Watch for commits that been dropped by --cherry-pick\n-\t\tif test t = \"$PRESERVE_MERGES\"\n+\telse\n+\t\tmkdir \"$REWRITTEN\" &&\n+\t\techo $ONTO > \"$REWRITTEN\"/root ||\n+\t\t\tdie \"Could not init rewritten commits\"\n+\tfi\n+\t# No cherry-pick because our first pass is to determine\n+\t# parents to rewrite and skipping dropped commits would\n+\t# prematurely end our probe\n+\tMERGES_OPTION=\n+\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n+else\n+\tMERGES_OPTION=\"--no-merges --cherry-pick\"\n+fi\n+\n+SHORTHEAD=$(git rev-parse --short $HEAD)\n+SHORTONTO=$(git rev-parse --short $ONTO)\n+if test -z \"$REBASE_ROOT\"\n+\t# this is now equivalent to ! -z \"$UPSTREAM\"\n+then\n+\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\n+\tREVISIONS=$UPSTREAM...$HEAD\n+\tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n+else\n+\tREVISIONS=$ONTO...$HEAD\n+\tSHORTREVISIONS=$SHORTHEAD\n+fi\n+git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n+\t--abbrev=7 --reverse --left-right --topo-order \\\n+\t$REVISIONS | \\\n+\tsed -n \"s/^>//p\" |\n+while read -r shortsha1 rest\n+do\n+\tif test t != \"$PRESERVE_MERGES\"\n+\tthen\n+\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\telse\n+\t\tsha1=$(git rev-parse $shortsha1)\n+\t\tif test -z \"$REBASE_ROOT\"\n \t\tthen\n-\t\t\tmkdir \"$DROPPED\"\n-\t\t\t# Save all non-cherry-picked changes\n-\t\t\tgit rev-list $REVISIONS --left-right --cherry-pick | \\\n-\t\t\t\tsed -n \"s/^>//p\" > \"$DOTEST\"/not-cherry-picks\n-\t\t\t# Now all commits and note which ones are missing in\n-\t\t\t# not-cherry-picks and hence being dropped\n-\t\t\tgit rev-list $REVISIONS |\n-\t\t\twhile read rev\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\"/$rev -a \"$(sane_grep \"$rev\" \"$DOTEST\"/not-cherry-picks)\" = \"\"\n+\t\t\t\tif test -f \"$REWRITTEN\"/$p -a \\( $p != $ONTO -o $sha1 = $first_after_upstream \\)\n \t\t\t\tthen\n-\t\t\t\t\t# Use -f2 because if rev-list is telling us this commit is\n-\t\t\t\t\t# not worthwhile, we don't want to track its multiple heads,\n-\t\t\t\t\t# just the history of its first-parent for others that will\n-\t\t\t\t\t# be rebasing on top of it\n-\t\t\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$DROPPED\"/$rev\n-\t\t\t\t\tshort=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)\n-\t\t\t\t\tsane_grep -v \"^[a-z][a-z]* $short\" <\"$TODO\" > \"${TODO}2\" ; mv \"${TODO}2\" \"$TODO\"\n-\t\t\t\t\trm \"$REWRITTEN\"/$rev\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' \"pick $shortsha1 $rest\" >> \"$TODO\"\n \t\tfi\n+\tfi\n+done\n \n-\t\ttest -s \"$TODO\" || echo noop >> \"$TODO\"\n-\t\ttest -n \"$AUTOSQUASH\" && rearrange_squash \"$TODO\"\n-\t\tcat >> \"$TODO\" << EOF\n+# Watch for commits that been dropped by --cherry-pick\n+if test t = \"$PRESERVE_MERGES\"\n+then\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\" > \"$DOTEST\"/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 -a \"$(sane_grep \"$rev\" \"$DOTEST\"/not-cherry-picks)\" = \"\"\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\tshort=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $short\" <\"$TODO\" > \"${TODO}2\" ; mv \"${TODO}2\" \"$TODO\"\n+\t\t\trm \"$REWRITTEN\"/$rev\n+\t\tfi\n+\tdone\n+fi\n+\n+test -s \"$TODO\" || echo noop >> \"$TODO\"\n+test -n \"$AUTOSQUASH\" && rearrange_squash \"$TODO\"\n+cat >> \"$TODO\" << EOF\n \n # Rebase $SHORTREVISIONS onto $SHORTONTO\n #\n@@ -1028,22 +1034,18 @@ first and then run 'git rebase --continue' again.\"\n #\n EOF\n \n-\t\thas_action \"$TODO\" ||\n-\t\t\tdie_abort \"Nothing to do\"\n+has_action \"$TODO\" ||\n+\tdie_abort \"Nothing to do\"\n \n-\t\tcp \"$TODO\" \"$TODO\".backup\n-\t\tgit_editor \"$TODO\" ||\n-\t\t\tdie_abort \"Could not execute editor\"\n+cp \"$TODO\" \"$TODO\".backup\n+git_editor \"$TODO\" ||\n+\tdie_abort \"Could not execute editor\"\n \n-\t\thas_action \"$TODO\" ||\n-\t\t\tdie_abort \"Nothing to do\"\n+has_action \"$TODO\" ||\n+\tdie_abort \"Nothing to do\"\n \n-\t\ttest -d \"$REWRITTEN\" || test -n \"$NEVER_FF\" || skip_unnecessary_picks\n+test -d \"$REWRITTEN\" || test -n \"$NEVER_FF\" || skip_unnecessary_picks\n \n-\t\toutput git checkout $ONTO || die_abort \"could not detach HEAD\"\n-\t\tgit update-ref ORIG_HEAD $HEAD\n-\t\tdo_rest\n-\t\t;;\n-\tesac\n-\tshift\n-done\n+output git checkout $ONTO || die_abort \"could not detach HEAD\"\n+git update-ref ORIG_HEAD $HEAD\n+do_rest\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 718cb26..29f1214 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -62,6 +62,8 @@ in_progress=\n type=\n # One of {\"$GIT_DIR\"/rebase-apply, \"$GIT_DIR\"/rebase-merge}\n state_dir=\n+# One of {'', continue, skip, abort}, as parsed from command line\n+action=\n \n read_state () {\n \tif test \"$type\" = merge\n@@ -236,66 +238,10 @@ do\n \t--verify)\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n-\t--continue)\n-\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\n-\t\tgit update-index --ignore-submodules --refresh &&\n-\t\tgit diff-files --quiet --ignore-submodules || {\n-\t\t\techo \"You must edit all merge conflicts and then\"\n-\t\t\techo \"mark them as resolved using git add\"\n-\t\t\texit 1\n-\t\t}\n-\t\tread_state\n-\t\tif test -d \"$merge_dir\"\n-\t\tthen\n-\t\t\tcontinue_merge\n-\t\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\t\tdo\n-\t\t\t\tcall_merge \"$msgnum\"\n-\t\t\t\tcontinue_merge\n-\t\t\tdone\n-\t\t\tfinish_rb_merge\n-\t\t\texit\n-\t\tfi\n-\t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n-\t\tmove_to_original_branch\n-\t\texit\n-\t\t;;\n-\t--skip)\n-\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\n-\t\tgit reset --hard HEAD || exit $?\n-\t\tread_state\n-\t\tif test -d \"$merge_dir\"\n-\t\tthen\n-\t\t\tgit rerere clear\n-\t\t\tmsgnum=$(($msgnum + 1))\n-\t\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\t\tdo\n-\t\t\t\tcall_merge \"$msgnum\"\n-\t\t\t\tcontinue_merge\n-\t\t\tdone\n-\t\t\tfinish_rb_merge\n-\t\t\texit\n-\t\tfi\n-\t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n-\t\tmove_to_original_branch\n-\t\texit\n-\t\t;;\n-\t--abort)\n-\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\n-\t\tgit rerere clear\n-\t\tread_state\n-\t\tcase \"$head_name\" in\n-\t\trefs/*)\n-\t\t\tgit symbolic-ref HEAD $head_name ||\n-\t\t\tdie \"Could not move back to $head_name\"\n-\t\t\t;;\n-\t\tesac\n-\t\tgit reset --hard $orig_head\n-\t\trm -r \"$state_dir\"\n-\t\texit\n+\t--continue|--skip|--abort)\n+\t\taction=${1##--}\n+\t\tshift\n+\t\tbreak\n \t\t;;\n \t--onto)\n \t\ttest 2 -le \"$#\" || usage\n@@ -391,6 +337,66 @@ do\n done\n test $# -gt 2 && usage\n \n+test -n \"$action\" && test -z \"$in_progress\" && die \"No rebase in progress?\"\n+\n+case \"$action\" in\n+continue)\n+\tgit update-index --ignore-submodules --refresh &&\n+\tgit diff-files --quiet --ignore-submodules || {\n+\t\techo \"You must edit all merge conflicts and then\"\n+\t\techo \"mark them as resolved using git add\"\n+\t\texit 1\n+\t}\n+\tread_state\n+\tif test -d \"$merge_dir\"\n+\tthen\n+\t\tcontinue_merge\n+\t\twhile test \"$msgnum\" -le \"$end\"\n+\t\tdo\n+\t\t\tcall_merge \"$msgnum\"\n+\t\t\tcontinue_merge\n+\t\tdone\n+\t\tfinish_rb_merge\n+\t\texit\n+\tfi\n+\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+skip)\n+\tgit reset --hard HEAD || exit $?\n+\tread_state\n+\tif test -d \"$merge_dir\"\n+\tthen\n+\t\tgit rerere clear\n+\t\tmsgnum=$(($msgnum + 1))\n+\t\twhile test \"$msgnum\" -le \"$end\"\n+\t\tdo\n+\t\t\tcall_merge \"$msgnum\"\n+\t\t\tcontinue_merge\n+\t\tdone\n+\t\tfinish_rb_merge\n+\t\texit\n+\tfi\n+\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+abort)\n+\tgit rerere clear\n+\tread_state\n+\tcase \"$head_name\" in\n+\trefs/*)\n+\t\tgit symbolic-ref HEAD $head_name ||\n+\t\tdie \"Could not move back to $head_name\"\n+\t\t;;\n+\tesac\n+\tgit reset --hard $orig_head\n+\trm -r \"$state_dir\"\n+\texit\n+\t;;\n+esac\n+\n # Make sure no rebase is in progress\n if test -n \"$in_progress\"\n then\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158667","messageId":"1293528648-21873-8-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 07/31] rebase: stricter check of standalone sub command","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:24Z","receivedAt":"2010-12-28T09:30:24Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The sub commands '--continue', '--skip' or '--abort' may only be used\nstandalone according to the documentation. Other options following the\nsub command are currently not accepted, but options preceeding them\nare. For example, 'git rebase --continue -v' is not accepted, while\n'git rebase -v --continue' is. Tighten up the check and allow no other\noptions when one of these sub commands are used.\n\nOnly check that it is standalone for non-interactive rebase for\nnow. Once the command line processing for interactive rebase has been\nreplaced by the command line processing in git-rebase.sh, this check\nwill also apply to interactive rebase.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nIs this too simplistic? Do we forsee that we want to support passing\noptions when resuming a rebase? Is it better to check for each other\noption that it is not passed (i.e. no '-v', no '-s' etc.)?\n\nMight some users be depending on the current behavior, even though it\nis undocumented?\n\n git-rebase.sh              |    4 ++--\n t/t3403-rebase-skip.sh     |    5 +++++\n t/t3407-rebase-abort.sh    |   10 ++++++++++\n t/t3418-rebase-continue.sh |    5 +++++\n 4 files changed, 22 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 29f1214..1cb0564 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -229,6 +229,7 @@ then\n fi\n test -n \"$type\" && in_progress=t\n \n+total_argc=$#\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -239,9 +240,8 @@ do\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n \t--continue|--skip|--abort)\n+\t\ttest $total_argc -eq 1 || usage\n \t\taction=${1##--}\n-\t\tshift\n-\t\tbreak\n \t\t;;\n \t--onto)\n \t\ttest 2 -le \"$#\" || usage\ndiff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh\nindex 64446e3..826500b 100755\n--- a/t/t3403-rebase-skip.sh\n+++ b/t/t3403-rebase-skip.sh\n@@ -35,6 +35,11 @@ test_expect_success 'rebase with git am -3 (default)' '\n \ttest_must_fail git rebase master\n '\n \n+test_expect_success 'rebase --skip can not be used with other options' '\n+\ttest_must_fail git rebase -v --skip &&\n+\ttest_must_fail git rebase --skip -v\n+'\n+\n test_expect_success 'rebase --skip with am -3' '\n \tgit rebase --skip\n \t'\ndiff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh\nindex e573dc8..a6a6c40 100755\n--- a/t/t3407-rebase-abort.sh\n+++ b/t/t3407-rebase-abort.sh\n@@ -84,6 +84,16 @@ testrebase() {\n \t\ttest_cmp reflog_before reflog_after &&\n \t\trm reflog_before reflog_after\n \t'\n+\n+\ttest_expect_success 'rebase --abort can not be used with other options' '\n+\t\tcd \"$work_dir\" &&\n+\t\t# Clean up the state from the previous one\n+\t\tgit reset --hard pre-rebase &&\n+\t\ttest_must_fail git rebase$type master &&\n+\t\ttest_must_fail git rebase -v --abort &&\n+\t\ttest_must_fail git rebase --abort -v &&\n+\t\tgit rebase --abort\n+\t'\n }\n \n testrebase \"\" .git/rebase-apply\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 3b0d273..1d90191 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file'\n \tgit rebase --continue\n '\n \n+test_expect_success 'rebase --continue can not be used with other options' '\n+\ttest_must_fail git rebase -v --continue &&\n+\ttest_must_fail git rebase --continue -v\n+'\n+\n test_done\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158646","messageId":"1293528648-21873-9-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 08/31] rebase: align variable names","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:25Z","receivedAt":"2010-12-28T09:30:25Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Use the same names for variables that git-rebase--interactive.sh will\nsoon inherit from git-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |  138 ++++++++++++++++++++++----------------------\n git-rebase.sh              |    8 +-\n 2 files changed, 73 insertions(+), 73 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 8cbdd3f..310d80e 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -77,7 +77,7 @@ FIXUP_MSG=\"$DOTEST\"/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+# $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@@ -105,15 +105,15 @@ AMEND=\"$DOTEST\"/amend\n REWRITTEN_LIST=\"$DOTEST\"/rewritten-list\n REWRITTEN_PENDING=\"$DOTEST\"/rewritten-pending\n \n-PRESERVE_MERGES=\n-STRATEGY=\n-ONTO=\n-VERBOSE=\n+preserve_merges=\n+strategy=\n+onto=\n+verbose=\n OK_TO_SKIP_PRE_REBASE=\n-REBASE_ROOT=\n-AUTOSQUASH=\n-test \"$(git config --bool rebase.autosquash)\" = \"true\" && AUTOSQUASH=t\n-NEVER_FF=\n+rebase_root=\n+autosquash=\n+test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n+force_rebase=\n \n GIT_CHERRY_PICK_HELP=\"\\\n hint: after resolving the conflicts, mark the corrected paths\n@@ -125,7 +125,7 @@ warn () {\n }\n \n output () {\n-\tcase \"$VERBOSE\" in\n+\tcase \"$verbose\" in\n \t'')\n \t\toutput=$(\"$@\" 2>&1 )\n \t\tstatus=$?\n@@ -177,7 +177,7 @@ mark_action_done () {\n \tthen\n \t\tlast_count=$count\n \t\tprintf \"Rebasing (%d/%d)\\r\" $count $total\n-\t\ttest -z \"$VERBOSE\" || echo\n+\t\ttest -z \"$verbose\" || echo\n \tfi\n }\n \n@@ -228,11 +228,11 @@ do_with_author () {\n pick_one () {\n \tff=--ff\n \tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n-\tcase \"$NEVER_FF\" in '') ;; ?*) ff= ;; esac\n+\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n \ttest -d \"$REWRITTEN\" &&\n \t\tpick_one_preserving_merges \"$@\" && return\n-\tif test -n \"$REBASE_ROOT\"\n+\tif test -n \"$rebase_root\"\n \tthen\n \t\toutput git cherry-pick \"$@\"\n \t\treturn\n@@ -339,7 +339,7 @@ pick_one_preserving_merges () {\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\tif ! do_with_author output \\\n-\t\t\t\tgit merge $STRATEGY -m \"$msg\" $new_parents\n+\t\t\t\tgit merge $strategy -m \"$msg\" $new_parents\n \t\t\tthen\n \t\t\t\tprintf \"%s\\n\" \"$msg\" > \"$GIT_DIR\"/MERGE_MSG\n \t\t\t\tdie_with_patch $sha1 \"Error redoing merge $sha1\"\n@@ -618,11 +618,11 @@ skip_unnecessary_picks () {\n \t\t# fd=3 means we skip the command\n \t\tcase \"$fd,$command\" in\n \t\t3,pick|3,p)\n-\t\t\t# pick a commit whose parent is current $ONTO -> skip\n+\t\t\t# pick a commit whose parent is current $onto -> skip\n \t\t\tsha1=${rest%% *}\n \t\t\tcase \"$(git rev-parse --verify --quiet \"$sha1\"^)\" in\n-\t\t\t\"$ONTO\"*)\n-\t\t\t\tONTO=$sha1\n+\t\t\t\"$onto\"*)\n+\t\t\t\tonto=$sha1\n \t\t\t\t;;\n \t\t\t*)\n \t\t\t\tfd=1\n@@ -641,7 +641,7 @@ skip_unnecessary_picks () {\n \tmv -f \"$TODO\".new \"$TODO\" &&\n \tcase \"$(peek_next_command)\" in\n \tsquash|s|fixup|f)\n-\t\trecord_in_rewritten \"$ONTO\"\n+\t\trecord_in_rewritten \"$onto\"\n \t\t;;\n \tesac ||\n \tdie \"Could not skip unnecessary pick commands\"\n@@ -650,17 +650,17 @@ skip_unnecessary_picks () {\n # check if no other options are set\n is_standalone () {\n \ttest $# -eq 2 -a \"$2\" = '--' &&\n-\ttest -z \"$ONTO\" &&\n-\ttest -z \"$PRESERVE_MERGES\" &&\n-\ttest -z \"$STRATEGY\" &&\n-\ttest -z \"$VERBOSE\"\n+\ttest -z \"$onto\" &&\n+\ttest -z \"$preserve_merges\" &&\n+\ttest -z \"$strategy\" &&\n+\ttest -z \"$verbose\"\n }\n \n get_saved_options () {\n-\ttest -d \"$REWRITTEN\" && PRESERVE_MERGES=t\n-\ttest -f \"$DOTEST\"/strategy && STRATEGY=\"$(cat \"$DOTEST\"/strategy)\"\n-\ttest -f \"$DOTEST\"/verbose && VERBOSE=t\n-\ttest -f \"$DOTEST\"/rebase-root && REBASE_ROOT=t\n+\ttest -d \"$REWRITTEN\" && preserve_merges=t\n+\ttest -f \"$DOTEST\"/strategy && strategy=\"$(cat \"$DOTEST\"/strategy)\"\n+\ttest -f \"$DOTEST\"/verbose && verbose=t\n+\ttest -f \"$DOTEST\"/rebase-root && rebase_root=t\n }\n \n # Rearrange the todo list that has both \"pick sha1 msg\" and\n@@ -827,11 +827,11 @@ first and then run 'git rebase --continue' again.\"\n \t-s)\n \t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t\tSTRATEGY=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n+\t\t\tstrategy=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n \t\t1,*)\n \t\t\tusage ;;\n \t\t*)\n-\t\t\tSTRATEGY=\"-s $2\"\n+\t\t\tstrategy=\"-s $2\"\n \t\t\tshift ;;\n \t\tesac\n \t\t;;\n@@ -839,29 +839,29 @@ first and then run 'git rebase --continue' again.\"\n \t\t# we use merge anyway\n \t\t;;\n \t-v)\n-\t\tVERBOSE=t\n+\t\tverbose=t\n \t\t;;\n \t-p)\n-\t\tPRESERVE_MERGES=t\n+\t\tpreserve_merges=t\n \t\t;;\n \t-i)\n \t\t# yeah, we know\n \t\t;;\n \t--no-ff)\n-\t\tNEVER_FF=t\n+\t\tforce_rebase=t\n \t\t;;\n \t--root)\n-\t\tREBASE_ROOT=t\n+\t\trebase_root=t\n \t\t;;\n \t--autosquash)\n-\t\tAUTOSQUASH=t\n+\t\tautosquash=t\n \t\t;;\n \t--no-autosquash)\n-\t\tAUTOSQUASH=\n+\t\tautosquash=\n \t\t;;\n \t--onto)\n \t\tshift\n-\t\tONTO=$(parse_onto \"$1\") ||\n+\t\tonto=$(parse_onto \"$1\") ||\n \t\t\tdie \"Does not point to a valid commit: $1\"\n \t\t;;\n \t--)\n@@ -872,27 +872,27 @@ first and then run 'git rebase --continue' again.\"\n \tshift\n done\n \n-test -z \"$REBASE_ROOT\" -a $# -ge 1 -a $# -le 2 ||\n-test ! -z \"$REBASE_ROOT\" -a $# -le 1 || usage\n+test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n+test ! -z \"$rebase_root\" -a $# -le 1 || usage\n test -d \"$DOTEST\" &&\n \tdie \"Interactive rebase already started\"\n \n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-if test -z \"$REBASE_ROOT\"\n+if test -z \"$rebase_root\"\n then\n-\tUPSTREAM_ARG=\"$1\"\n-\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n+\tupstream_arg=\"$1\"\n+\tupstream=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n+\ttest -z \"$onto\" && onto=$upstream\n \tshift\n else\n-\tUPSTREAM=\n-\tUPSTREAM_ARG=--root\n-\ttest -z \"$ONTO\" &&\n-\tdie \"You must specify --onto when using --root\"\n+\tupstream=\n+\tupstream_arg=--root\n+\ttest -z \"$onto\" &&\n+\t\tdie \"You must specify --onto when using --root\"\n fi\n-run_pre_rebase_hook \"$UPSTREAM_ARG\" \"$@\"\n+run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\n \n@@ -912,49 +912,49 @@ git symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n \techo \"detached HEAD\" > \"$DOTEST\"/head-name\n \n echo $HEAD > \"$DOTEST\"/head\n-case \"$REBASE_ROOT\" in\n+case \"$rebase_root\" in\n '')\n \trm -f \"$DOTEST\"/rebase-root ;;\n *)\n \t: >\"$DOTEST\"/rebase-root ;;\n esac\n-echo $ONTO > \"$DOTEST\"/onto\n-test -z \"$STRATEGY\" || echo \"$STRATEGY\" > \"$DOTEST\"/strategy\n-test t = \"$VERBOSE\" && : > \"$DOTEST\"/verbose\n-if test t = \"$PRESERVE_MERGES\"\n+echo $onto > \"$DOTEST\"/onto\n+test -z \"$strategy\" || echo \"$strategy\" > \"$DOTEST\"/strategy\n+test t = \"$verbose\" && : > \"$DOTEST\"/verbose\n+if test t = \"$preserve_merges\"\n then\n-\tif test -z \"$REBASE_ROOT\"\n+\tif test -z \"$rebase_root\"\n \tthen\n \t\tmkdir \"$REWRITTEN\" &&\n-\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\n+\t\tfor c in $(git merge-base --all $HEAD $upstream)\n \t\tdo\n-\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n+\t\t\techo $onto > \"$REWRITTEN\"/$c ||\n \t\t\t\tdie \"Could not init rewritten commits\"\n \t\tdone\n \telse\n \t\tmkdir \"$REWRITTEN\" &&\n-\t\techo $ONTO > \"$REWRITTEN\"/root ||\n+\t\techo $onto > \"$REWRITTEN\"/root ||\n \t\t\tdie \"Could not init rewritten commits\"\n \tfi\n \t# No cherry-pick because our first pass is to determine\n \t# parents to rewrite and skipping dropped commits would\n \t# prematurely end our probe\n \tMERGES_OPTION=\n-\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n+\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $upstream..$HEAD | head -n 1)\"\n else\n \tMERGES_OPTION=\"--no-merges --cherry-pick\"\n fi\n \n SHORTHEAD=$(git rev-parse --short $HEAD)\n-SHORTONTO=$(git rev-parse --short $ONTO)\n-if test -z \"$REBASE_ROOT\"\n-\t# this is now equivalent to ! -z \"$UPSTREAM\"\n+SHORTONTO=$(git rev-parse --short $onto)\n+if test -z \"$rebase_root\"\n+\t# this is now equivalent to ! -z \"$upstream\"\n then\n-\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\n-\tREVISIONS=$UPSTREAM...$HEAD\n+\tSHORTUPSTREAM=$(git rev-parse --short $upstream)\n+\tREVISIONS=$upstream...$HEAD\n \tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n else\n-\tREVISIONS=$ONTO...$HEAD\n+\tREVISIONS=$onto...$HEAD\n \tSHORTREVISIONS=$SHORTHEAD\n fi\n git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n@@ -963,17 +963,17 @@ git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n \tsed -n \"s/^>//p\" |\n while read -r shortsha1 rest\n do\n-\tif test t != \"$PRESERVE_MERGES\"\n+\tif test t != \"$preserve_merges\"\n \tthen\n \t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n \telse\n \t\tsha1=$(git rev-parse $shortsha1)\n-\t\tif test -z \"$REBASE_ROOT\"\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 -a \\( $p != $ONTO -o $sha1 = $first_after_upstream \\)\n+\t\t\t\tif test -f \"$REWRITTEN\"/$p -a \\( $p != $onto -o $sha1 = $first_after_upstream \\)\n \t\t\t\tthen\n \t\t\t\t\tpreserve=f\n \t\t\t\tfi\n@@ -990,7 +990,7 @@ do\n done\n \n # Watch for commits that been dropped by --cherry-pick\n-if test t = \"$PRESERVE_MERGES\"\n+if test t = \"$preserve_merges\"\n then\n \tmkdir \"$DROPPED\"\n \t# Save all non-cherry-picked changes\n@@ -1016,7 +1016,7 @@ then\n fi\n \n test -s \"$TODO\" || echo noop >> \"$TODO\"\n-test -n \"$AUTOSQUASH\" && rearrange_squash \"$TODO\"\n+test -n \"$autosquash\" && rearrange_squash \"$TODO\"\n cat >> \"$TODO\" << EOF\n \n # Rebase $SHORTREVISIONS onto $SHORTONTO\n@@ -1044,8 +1044,8 @@ git_editor \"$TODO\" ||\n has_action \"$TODO\" ||\n \tdie_abort \"Nothing to do\"\n \n-test -d \"$REWRITTEN\" || test -n \"$NEVER_FF\" || skip_unnecessary_picks\n+test -d \"$REWRITTEN\" || test -n \"$force_rebase\" || skip_unnecessary_picks\n \n-output git checkout $ONTO || die_abort \"could not detach HEAD\"\n+output git checkout $onto || die_abort \"could not detach HEAD\"\n git update-ref ORIG_HEAD $HEAD\n do_rest\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 1cb0564..dc133e3 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -42,7 +42,7 @@ When you have resolved this problem run \\\"git rebase --continue\\\".\n If you would prefer to skip this patch, instead run \\\"git rebase --skip\\\".\n To restore the original branch and stop rebasing run \\\"git rebase --abort\\\".\n \"\n-unset newbase\n+unset onto\n strategy=recursive\n strategy_opts=\n do_merge=\n@@ -245,7 +245,7 @@ do\n \t\t;;\n \t--onto)\n \t\ttest 2 -le \"$#\" || usage\n-\t\tnewbase=\"$2\"\n+\t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n \t-M|-m|--m|--me|--mer|--merg|--merge)\n@@ -425,7 +425,7 @@ then\n \tunset root_flag\n \tupstream_arg=\"$upstream_name\"\n else\n-\ttest -z \"$newbase\" && die \"--root must be used with --onto\"\n+\ttest -z \"$onto\" && die \"--root must be used with --onto\"\n \tunset upstream_name\n \tunset upstream\n \troot_flag=\"--root\"\n@@ -433,7 +433,7 @@ else\n fi\n \n # Make sure the branch to rebase onto is valid.\n-onto_name=${newbase-\"$upstream_name\"}\n+onto_name=${onto-\"$upstream_name\"}\n case \"$onto_name\" in\n *...*)\n \tif\tleft=${onto_name%...*} right=${onto_name#*...} &&\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158644","messageId":"1293528648-21873-10-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 09/31] rebase: align variable content","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:26Z","receivedAt":"2010-12-28T09:30:26Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Make sure to interpret variables with the same name in the same way in\ngit-rebase.sh and git-rebase--interactive.sh. This will make it easier\nto factor out code from git-rebase.sh to git-rebase--interactive and\nexport the variables.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   16 +++++++++++-----\n git-rebase.sh              |    4 +++-\n 2 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 310d80e..1af739a 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -339,7 +339,8 @@ pick_one_preserving_merges () {\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\tif ! do_with_author output \\\n-\t\t\t\tgit merge $strategy -m \"$msg\" $new_parents\n+\t\t\t\tgit merge ${strategy:+-s $strategy} -m \"$msg\" \\\n+\t\t\t\t\t$new_parents\n \t\t\tthen\n \t\t\t\tprintf \"%s\\n\" \"$msg\" > \"$GIT_DIR\"/MERGE_MSG\n \t\t\t\tdie_with_patch $sha1 \"Error redoing merge $sha1\"\n@@ -827,11 +828,11 @@ first and then run 'git rebase --continue' again.\"\n \t-s)\n \t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t\tstrategy=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n+\t\t\tstrategy=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n \t\t1,*)\n \t\t\tusage ;;\n \t\t*)\n-\t\t\tstrategy=\"-s $2\"\n+\t\t\tstrategy=\"$2\"\n \t\t\tshift ;;\n \t\tesac\n \t\t;;\n@@ -860,9 +861,9 @@ first and then run 'git rebase --continue' again.\"\n \t\tautosquash=\n \t\t;;\n \t--onto)\n+\t\ttest 2 -le \"$#\" || usage\n+\t\tonto=\"$2\"\n \t\tshift\n-\t\tonto=$(parse_onto \"$1\") ||\n-\t\t\tdie \"Does not point to a valid commit: $1\"\n \t\t;;\n \t--)\n \t\tshift\n@@ -872,6 +873,11 @@ first and then run 'git rebase --continue' again.\"\n \tshift\n done\n \n+if test -n \"$onto\"\n+then\n+\tonto=$(parse_onto \"$onto\") || die \"Does not point to a valid commit: $1\"\n+fi\n+\n test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n test ! -z \"$rebase_root\" -a $# -le 1 || usage\n test -d \"$DOTEST\" &&\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex dc133e3..21366ba 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -43,7 +43,7 @@ If you would prefer to skip this patch, instead run \\\"git rebase --skip\\\".\n To restore the original branch and stop rebasing run \\\"git rebase --abort\\\".\n \"\n unset onto\n-strategy=recursive\n+strategy=\n strategy_opts=\n do_merge=\n merge_dir=\"$GIT_DIR\"/rebase-merge\n@@ -130,6 +130,7 @@ call_merge () {\n \tthen\n \t\tGIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY\n \tfi\n+\ttest -z \"$strategy\" && strategy=recursive\n \teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n \trv=$?\n \tcase \"$rv\" in\n@@ -267,6 +268,7 @@ do\n \t\tesac\n \t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$newopt\")\"\n \t\tdo_merge=t\n+\t\ttest -z \"$strategy\" && strategy=recursive\n \t\t;;\n \t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n \t\t--strateg=*|--strategy=*|\\\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158647","messageId":"1293528648-21873-11-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 10/31] rebase: factor out command line option processing","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:27Z","receivedAt":"2010-12-28T09:30:27Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Factor out the command line processing in git-rebase--interactive.sh\nto git-rebase.sh. Store the options in variables in git-rebase.sh and\nexport them before calling git-rebase--interactive.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nSince this removes the command line processing from\ngit-rebase--interactive.sh, it completely changes its command line\ninterface. Since it is not listed as even a plumbing command, I hope\nthis is fine.\n\n git-rebase--interactive.sh |  224 ++++++++++++--------------------------------\n git-rebase.sh              |   60 ++++++++----\n 2 files changed, 102 insertions(+), 182 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 1af739a..4d3dc63 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -10,31 +10,7 @@\n # The original idea comes from Eric W. Biederman, in\n # http://article.gmane.org/gmane.comp.version-control.git/22407\n \n-OPTIONS_KEEPDASHDASH=\n-OPTIONS_SPEC=\"\\\n-git-rebase [-i] [options] [--] <upstream> [<branch>]\n-git-rebase [-i] (--continue | --abort | --skip)\n---\n- Available options are\n-v,verbose          display a diffstat of what changed upstream\n-onto=              rebase onto given branch instead of upstream\n-p,preserve-merges  try to recreate merges instead of ignoring them\n-s,strategy=        use the given merge strategy\n-no-ff              cherry-pick all commits, even if unchanged\n-m,merge            always used (no-op)\n-i,interactive      always used (no-op)\n- Actions:\n-continue           continue rebasing process\n-abort              abort rebasing process and restore original branch\n-skip               skip current patch and continue rebasing process\n-no-verify          override pre-rebase hook from stopping the operation\n-verify             allow pre-rebase hook to run\n-root               rebase all reachable commmits up to the root(s)\n-autosquash         move commits that begin with squash!/fixup! under -i\n-\"\n-\n . git-sh-setup\n-require_work_tree\n \n DOTEST=\"$GIT_DIR/rebase-merge\"\n \n@@ -105,16 +81,6 @@ AMEND=\"$DOTEST\"/amend\n REWRITTEN_LIST=\"$DOTEST\"/rewritten-list\n REWRITTEN_PENDING=\"$DOTEST\"/rewritten-pending\n \n-preserve_merges=\n-strategy=\n-onto=\n-verbose=\n-OK_TO_SKIP_PRE_REBASE=\n-rebase_root=\n-autosquash=\n-test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n-force_rebase=\n-\n GIT_CHERRY_PICK_HELP=\"\\\n hint: after resolving the conflicts, mark the corrected paths\n hint: with 'git add <paths>' and run 'git rebase --continue'\"\n@@ -648,15 +614,6 @@ skip_unnecessary_picks () {\n \tdie \"Could not skip unnecessary pick commands\"\n }\n \n-# check if no other options are set\n-is_standalone () {\n-\ttest $# -eq 2 -a \"$2\" = '--' &&\n-\ttest -z \"$onto\" &&\n-\ttest -z \"$preserve_merges\" &&\n-\ttest -z \"$strategy\" &&\n-\ttest -z \"$verbose\"\n-}\n-\n get_saved_options () {\n \ttest -d \"$REWRITTEN\" && preserve_merges=t\n \ttest -f \"$DOTEST\"/strategy && strategy=\"$(cat \"$DOTEST\"/strategy)\"\n@@ -744,134 +701,77 @@ parse_onto () {\n \tgit rev-parse --verify \"$1^0\"\n }\n \n-while test $# != 0\n-do\n-\tcase \"$1\" in\n-\t--no-verify)\n-\t\tOK_TO_SKIP_PRE_REBASE=yes\n-\t\t;;\n-\t--verify)\n-\t\tOK_TO_SKIP_PRE_REBASE=\n-\t\t;;\n-\t--continue)\n-\t\tis_standalone \"$@\" || usage\n-\t\tget_saved_options\n-\t\tcomment_for_reflog continue\n-\n-\t\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n-\n-\t\t# Sanity check\n-\t\tgit rev-parse --verify HEAD >/dev/null ||\n-\t\t\tdie \"Cannot read HEAD\"\n-\t\tgit update-index --ignore-submodules --refresh &&\n-\t\t\tgit diff-files --quiet --ignore-submodules ||\n-\t\t\tdie \"Working tree is dirty\"\n-\n-\t\t# do we have anything to commit?\n-\t\tif git diff-index --cached --quiet --ignore-submodules HEAD --\n+case \"$action\" in\n+continue)\n+\tget_saved_options\n+\tcomment_for_reflog continue\n+\n+\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n+\n+\t# Sanity check\n+\tgit rev-parse --verify HEAD >/dev/null ||\n+\t\tdie \"Cannot read HEAD\"\n+\tgit update-index --ignore-submodules --refresh &&\n+\t\tgit diff-files --quiet --ignore-submodules ||\n+\t\tdie \"Working tree is dirty\"\n+\n+\t# do we have anything to commit?\n+\tif git diff-index --cached --quiet --ignore-submodules HEAD --\n+\tthen\n+\t\t: Nothing to commit -- skip this\n+\telse\n+\t\t. \"$AUTHOR_SCRIPT\" ||\n+\t\t\tdie \"Cannot find the author identity\"\n+\t\tamend=\n+\t\tif test -f \"$AMEND\"\n \t\tthen\n-\t\t\t: Nothing to commit -- skip this\n-\t\telse\n-\t\t\t. \"$AUTHOR_SCRIPT\" ||\n-\t\t\t\tdie \"Cannot find the author identity\"\n-\t\t\tamend=\n-\t\t\tif test -f \"$AMEND\"\n-\t\t\tthen\n-\t\t\t\tamend=$(git rev-parse --verify HEAD)\n-\t\t\t\ttest \"$amend\" = $(cat \"$AMEND\") ||\n-\t\t\t\tdie \"\\\n+\t\t\tamend=$(git rev-parse --verify HEAD)\n+\t\t\ttest \"$amend\" = $(cat \"$AMEND\") ||\n+\t\t\tdie \"\\\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\tgit reset --soft HEAD^ ||\n-\t\t\t\tdie \"Cannot rewind the HEAD\"\n-\t\t\tfi\n-\t\t\tdo_with_author git commit --no-verify -F \"$MSG\" -e || {\n-\t\t\t\ttest -n \"$amend\" && git reset --soft $amend\n-\t\t\t\tdie \"Could not commit staged changes.\"\n-\t\t\t}\n+\t\t\tgit reset --soft HEAD^ ||\n+\t\t\tdie \"Cannot rewind the HEAD\"\n \t\tfi\n+\t\tdo_with_author git commit --no-verify -F \"$MSG\" -e || {\n+\t\t\ttest -n \"$amend\" && git reset --soft $amend\n+\t\t\tdie \"Could not commit staged changes.\"\n+\t\t}\n+\tfi\n \n-\t\trecord_in_rewritten \"$(cat \"$DOTEST\"/stopped-sha)\"\n+\trecord_in_rewritten \"$(cat \"$DOTEST\"/stopped-sha)\"\n \n-\t\trequire_clean_work_tree \"rebase\"\n-\t\tdo_rest\n-\t\t;;\n-\t--abort)\n-\t\tis_standalone \"$@\" || usage\n-\t\tget_saved_options\n-\t\tcomment_for_reflog abort\n-\n-\t\tgit rerere clear\n-\t\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n-\n-\t\tHEADNAME=$(cat \"$DOTEST\"/head-name)\n-\t\tHEAD=$(cat \"$DOTEST\"/head)\n-\t\tcase $HEADNAME in\n-\t\trefs/*)\n-\t\t\tgit symbolic-ref HEAD $HEADNAME\n-\t\t\t;;\n-\t\tesac &&\n-\t\toutput git reset --hard $HEAD &&\n-\t\trm -rf \"$DOTEST\"\n-\t\texit\n-\t\t;;\n-\t--skip)\n-\t\tis_standalone \"$@\" || usage\n-\t\tget_saved_options\n-\t\tcomment_for_reflog skip\n+\trequire_clean_work_tree \"rebase\"\n+\tdo_rest\n+\t;;\n+abort)\n+\tget_saved_options\n+\tcomment_for_reflog abort\n \n-\t\tgit rerere clear\n-\t\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n+\tgit rerere clear\n+\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n \n-\t\toutput git reset --hard && do_rest\n-\t\t;;\n-\t-s)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tstrategy=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tstrategy=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n-\t\t;;\n-\t-m)\n-\t\t# we use merge anyway\n-\t\t;;\n-\t-v)\n-\t\tverbose=t\n-\t\t;;\n-\t-p)\n-\t\tpreserve_merges=t\n-\t\t;;\n-\t-i)\n-\t\t# yeah, we know\n-\t\t;;\n-\t--no-ff)\n-\t\tforce_rebase=t\n-\t\t;;\n-\t--root)\n-\t\trebase_root=t\n-\t\t;;\n-\t--autosquash)\n-\t\tautosquash=t\n-\t\t;;\n-\t--no-autosquash)\n-\t\tautosquash=\n-\t\t;;\n-\t--onto)\n-\t\ttest 2 -le \"$#\" || usage\n-\t\tonto=\"$2\"\n-\t\tshift\n-\t\t;;\n-\t--)\n-\t\tshift\n-\t\tbreak\n+\tHEADNAME=$(cat \"$DOTEST\"/head-name)\n+\tHEAD=$(cat \"$DOTEST\"/head)\n+\tcase $HEADNAME in\n+\trefs/*)\n+\t\tgit symbolic-ref HEAD $HEADNAME\n \t\t;;\n-\tesac\n-\tshift\n-done\n+\tesac &&\n+\toutput git reset --hard $HEAD &&\n+\trm -rf \"$DOTEST\"\n+\texit\n+\t;;\n+skip)\n+\tget_saved_options\n+\tcomment_for_reflog skip\n+\n+\tgit rerere clear\n+\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n+\n+\toutput git reset --hard && do_rest\n+\t;;\n+esac\n \n if test -n \"$onto\"\n then\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 21366ba..e646b8f 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -64,6 +64,9 @@ type=\n state_dir=\n # One of {'', continue, skip, abort}, as parsed from command line\n action=\n+preserve_merges=\n+autosquash=\n+test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n \n read_state () {\n \tif test \"$type\" = merge\n@@ -176,27 +179,14 @@ finish_rb_merge () {\n \tsay All done.\n }\n \n-is_interactive () {\n-\twhile test $# != 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t\t-i|--interactive)\n-\t\t\t\tinteractive_rebase=explicit\n-\t\t\t\tbreak\n-\t\t\t;;\n-\t\t\t-p|--preserve-merges)\n-\t\t\t\tinteractive_rebase=implied\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n+run_interactive_rebase () {\n \tif [ \"$interactive_rebase\" = implied ]; then\n \t\tGIT_EDITOR=:\n \t\texport GIT_EDITOR\n \tfi\n-\n-\ttest -n \"$interactive_rebase\" || test -f \"$merge_dir\"/interactive\n+\texport onto autosquash strategy strategy_opts verbose rebase_root \\\n+\tforce_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE\n+\texec git-rebase--interactive \"$@\"\n }\n \n run_pre_rebase_hook () {\n@@ -211,8 +201,6 @@ run_pre_rebase_hook () {\n test -f \"$apply_dir\"/applying &&\n \tdie 'It looks like git-am is in progress. Cannot rebase.'\n \n-is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n-\n if test -d \"$apply_dir\"\n then\n \ttype=am\n@@ -249,6 +237,19 @@ do\n \t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n+\t-i|--interactive)\n+\t\tinteractive_rebase=explicit\n+\t\t;;\n+\t-p|--preserve-merges)\n+\t\tpreserve_merges=t\n+\t\ttest -z \"$interactive_rebase\" && interactive_rebase=implied\n+\t\t;;\n+\t--autosquash)\n+\t\tautosquash=t\n+\t\t;;\n+\t--no-autosquash)\n+\t\tautosquash=\n+\t\t;;\n \t-M|-m|--m|--me|--mer|--merg|--merge)\n \t\tdo_merge=t\n \t\t;;\n@@ -339,7 +340,11 @@ do\n done\n test $# -gt 2 && usage\n \n-test -n \"$action\" && test -z \"$in_progress\" && die \"No rebase in progress?\"\n+if test -n \"$action\"\n+then\n+\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n+\ttest \"$type\" = interactive && run_interactive_rebase\n+fi\n \n case \"$action\" in\n continue)\n@@ -415,6 +420,21 @@ fi\n \n test $# -eq 0 && test -z \"$rebase_root\" && usage\n \n+if test -n \"$interactive_rebase\"\n+then\n+\ttype=interactive\n+\tstate_dir=\"$merge_dir\"\n+elif test -n \"$do_merge\"\n+then\n+\ttype=merge\n+\tstate_dir=\"$merge_dir\"\n+else\n+\ttype=am\n+\tstate_dir=\"$apply_dir\"\n+fi\n+\n+test \"$type\" = interactive && run_interactive_rebase \"$@\"\n+\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n if test -z \"$rebase_root\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158649","messageId":"1293528648-21873-12-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 11/31] rebase -i: remove now unnecessary directory checks","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:28Z","receivedAt":"2010-12-28T09:30:28Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove directory checks from git-rebase--interactive.sh that are done in\ngit-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nSquash with previous?\n\n git-rebase--interactive.sh |    6 ------\n 1 files changed, 0 insertions(+), 6 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 4d3dc63..21a9774 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -706,8 +706,6 @@ continue)\n \tget_saved_options\n \tcomment_for_reflog continue\n \n-\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n-\n \t# Sanity check\n \tgit rev-parse --verify HEAD >/dev/null ||\n \t\tdie \"Cannot read HEAD\"\n@@ -749,7 +747,6 @@ abort)\n \tcomment_for_reflog abort\n \n \tgit rerere clear\n-\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n \n \tHEADNAME=$(cat \"$DOTEST\"/head-name)\n \tHEAD=$(cat \"$DOTEST\"/head)\n@@ -767,7 +764,6 @@ skip)\n \tcomment_for_reflog skip\n \n \tgit rerere clear\n-\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n \n \toutput git reset --hard && do_rest\n \t;;\n@@ -780,8 +776,6 @@ fi\n \n test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n test ! -z \"$rebase_root\" -a $# -le 1 || usage\n-test -d \"$DOTEST\" &&\n-\tdie \"Interactive rebase already started\"\n \n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158645","messageId":"1293528648-21873-13-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 12/31] rebase: reorder validation steps","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:29Z","receivedAt":"2010-12-28T09:30:29Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Reorder validation steps in preparation for the validation to be factored\nout from git-rebase--interactive.sh into git-rebase.sh.\n\nThe main functional difference is that the pre-rebase hook will no longer\nbe run if the work tree is dirty.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    4 ++--\n git-rebase.sh              |   10 +++++-----\n 2 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 21a9774..5a8f582 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -792,12 +792,12 @@ else\n \ttest -z \"$onto\" &&\n \t\tdie \"You must specify --onto when using --root\"\n fi\n+require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n+\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\n \n-require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n if test ! -z \"$1\"\n then\n \toutput git checkout \"$1\" ||\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e646b8f..26e4218 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -435,8 +435,6 @@ fi\n \n test \"$type\" = interactive && run_interactive_rebase \"$@\"\n \n-require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n if test -z \"$rebase_root\"\n then\n \t# The upstream head must be given.  Make sure it is valid.\n@@ -478,9 +476,6 @@ case \"$onto_name\" in\n \t;;\n esac\n \n-# If a hook exists, give it a chance to interrupt\n-run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n-\n # If the branch to rebase is given, that is the branch we will rebase\n # $branch_name -- branch being rebased, or HEAD (already detached)\n # $orig_head -- commit object name of tip of the branch before rebasing\n@@ -518,6 +513,8 @@ case \"$#\" in\n esac\n orig_head=$branch\n \n+require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n+\n # Now we are rebasing commits $upstream..$branch (or with --root,\n # everything leading up to $branch) on top of $onto\n \n@@ -539,6 +536,9 @@ then\n \tfi\n fi\n \n+# If a hook exists, give it a chance to interrupt\n+run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n+\n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158661","messageId":"1293528648-21873-14-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 13/31] rebase: factor out reference parsing","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:30Z","receivedAt":"2010-12-28T09:30:30Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove the parsing and validation of references (onto, upstream, branch)\nfrom git-rebase--interactive.sh and rely on the information exported from\ngit-rebase.sh.\n\nBy using the parsing of the --onto parameter in git-rebase.sh, this\nimproves the error message when the parameter is invalid.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nShould the check for set GIT_COMMITTER_IDENT be done for\nnon-interactive rebase as well or does it only make sense for\ninteractive rebase?\n\n git-rebase--interactive.sh |   48 +++----------------------------------------\n git-rebase.sh              |   12 ++++++----\n 2 files changed, 11 insertions(+), 49 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5a8f582..c055fc4 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -682,25 +682,6 @@ rearrange_squash () {\n \trm -f \"$1.sq\" \"$1.rearranged\"\n }\n \n-LF='\n-'\n-parse_onto () {\n-\tcase \"$1\" in\n-\t*...*)\n-\t\tif\tleft=${1%...*} right=${1#*...} &&\n-\t\t\tonto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})\n-\t\tthen\n-\t\t\tcase \"$onto\" in\n-\t\t\t?*\"$LF\"?* | '')\n-\t\t\t\texit 1 ;;\n-\t\t\tesac\n-\t\t\techo \"$onto\"\n-\t\t\texit 0\n-\t\tfi\n-\tesac\n-\tgit rev-parse --verify \"$1^0\"\n-}\n-\n case \"$action\" in\n continue)\n \tget_saved_options\n@@ -769,47 +750,26 @@ skip)\n \t;;\n esac\n \n-if test -n \"$onto\"\n-then\n-\tonto=$(parse_onto \"$onto\") || die \"Does not point to a valid commit: $1\"\n-fi\n-\n-test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n-test ! -z \"$rebase_root\" -a $# -le 1 || usage\n-\n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-if test -z \"$rebase_root\"\n-then\n-\tupstream_arg=\"$1\"\n-\tupstream=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\ttest -z \"$onto\" && onto=$upstream\n-\tshift\n-else\n-\tupstream=\n-\tupstream_arg=--root\n-\ttest -z \"$onto\" &&\n-\t\tdie \"You must specify --onto when using --root\"\n-fi\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\n \n-if test ! -z \"$1\"\n+if test ! -z \"$switch_to\"\n then\n-\toutput git checkout \"$1\" ||\n-\t\tdie \"Could not checkout $1\"\n+\toutput git checkout \"$switch_to\" ||\n+\t\tdie \"Could not checkout $switch_to\"\n fi\n \n HEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n mkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n \n : > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n-git symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n-\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n+echo \"$head_name\" > \"$DOTEST\"/head-name\n \n echo $HEAD > \"$DOTEST\"/head\n case \"$rebase_root\" in\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 26e4218..d8c7c8d 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -185,7 +185,8 @@ run_interactive_rebase () {\n \t\texport GIT_EDITOR\n \tfi\n \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n-\tforce_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE\n+\tforce_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE upstream \\\n+\tupstream_arg switch_to head_name\n \texec git-rebase--interactive \"$@\"\n }\n \n@@ -433,8 +434,6 @@ else\n \tstate_dir=\"$apply_dir\"\n fi\n \n-test \"$type\" = interactive && run_interactive_rebase \"$@\"\n-\n if test -z \"$rebase_root\"\n then\n \t# The upstream head must be given.  Make sure it is valid.\n@@ -445,7 +444,7 @@ then\n \tunset root_flag\n \tupstream_arg=\"$upstream_name\"\n else\n-\ttest -z \"$onto\" && die \"--root must be used with --onto\"\n+\ttest -z \"$onto\" && die \"You must specify --onto when using --root\"\n \tunset upstream_name\n \tunset upstream\n \troot_flag=\"--root\"\n@@ -472,7 +471,8 @@ case \"$onto_name\" in\n \tfi\n \t;;\n *)\n-\tonto=$(git rev-parse --verify \"${onto_name}^0\") || exit\n+\tonto=$(git rev-parse --verify \"${onto_name}^0\") ||\n+\tdie \"Does not point to a valid commit: $1\"\n \t;;\n esac\n \n@@ -513,6 +513,8 @@ case \"$#\" in\n esac\n orig_head=$branch\n \n+test \"$type\" = interactive && run_interactive_rebase \"$@\"\n+\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n # Now we are rebasing commits $upstream..$branch (or with --root,\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158651","messageId":"1293528648-21873-15-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 14/31] rebase: factor out clean work tree check","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:31Z","receivedAt":"2010-12-28T09:30:31Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove the check for clean work tree from git-rebase--interactive.sh and\nrely on the check in git-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    2 --\n git-rebase.sh              |    4 ++--\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex c055fc4..edde1e5 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -753,8 +753,6 @@ esac\n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d8c7c8d..e1e5263 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -513,10 +513,10 @@ case \"$#\" in\n esac\n orig_head=$branch\n \n-test \"$type\" = interactive && run_interactive_rebase \"$@\"\n-\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n+test \"$type\" = interactive && run_interactive_rebase \"$@\"\n+\n # Now we are rebasing commits $upstream..$branch (or with --root,\n # everything leading up to $branch) on top of $onto\n \n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158648","messageId":"1293528648-21873-16-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 15/31] rebase: factor out call to pre-rebase hook","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:32Z","receivedAt":"2010-12-28T09:30:32Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove the call to the pre-rebase hook from\ngit-rebase--interactive.sh and rely on the call in\ngit-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   14 --------------\n git-rebase.sh              |   15 ++++++++-------\n 2 files changed, 8 insertions(+), 21 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex edde1e5..0beeb8b 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -109,18 +109,6 @@ commit_message () {\n \tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n }\n \n-run_pre_rebase_hook () {\n-\tif test -z \"$OK_TO_SKIP_PRE_REBASE\" &&\n-\t   test -x \"$GIT_DIR/hooks/pre-rebase\"\n-\tthen\n-\t\t\"$GIT_DIR/hooks/pre-rebase\" ${1+\"$@\"} || {\n-\t\t\techo >&2 \"The pre-rebase hook refused to rebase.\"\n-\t\t\texit 1\n-\t\t}\n-\tfi\n-}\n-\n-\n ORIG_REFLOG_ACTION=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n@@ -753,8 +741,6 @@ esac\n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n-\n comment_for_reflog start\n \n if test ! -z \"$switch_to\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e1e5263..229e8d2 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -185,9 +185,8 @@ run_interactive_rebase () {\n \t\texport GIT_EDITOR\n \tfi\n \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n-\tforce_rebase action preserve_merges OK_TO_SKIP_PRE_REBASE upstream \\\n-\tupstream_arg switch_to head_name\n-\texec git-rebase--interactive \"$@\"\n+\tforce_rebase action preserve_merges upstream switch_to head_name\n+\texec git-rebase--interactive\n }\n \n run_pre_rebase_hook () {\n@@ -515,15 +514,15 @@ orig_head=$branch\n \n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n-test \"$type\" = interactive && run_interactive_rebase \"$@\"\n-\n # Now we are rebasing commits $upstream..$branch (or with --root,\n # everything leading up to $branch) on top of $onto\n \n # Check if we are already based on $onto with linear history,\n-# but this should be done only when upstream and onto are the same.\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\" \"$branch\")\n-if test \"$upstream\" = \"$onto\" && test \"$mb\" = \"$onto\" &&\n+if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n+\ttest \"$mb\" = \"$onto\" &&\n \t# linear history?\n \t! (git rev-list --parents \"$onto\"..\"$branch\" | sane_grep \" .* \") > /dev/null\n then\n@@ -541,6 +540,8 @@ fi\n # If a hook exists, give it a chance to interrupt\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n+test \"$type\" = interactive && run_interactive_rebase\n+\n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158650","messageId":"1293528648-21873-17-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 16/31] rebase -i: support --stat","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:33Z","receivedAt":"2010-12-28T09:30:33Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Move up the code that displays the diffstat if '--stat' is passed, so\nthat it will be executed before calling git-rebase--interactive.sh.\n\nA side effect is that the diffstat is now displayed before \"First,\nrewinding head to replay your work on top of it...\".\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |   14 +++++++-------\n 1 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 229e8d2..0fc580a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -540,13 +540,6 @@ fi\n # If a hook exists, give it a chance to interrupt\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n-test \"$type\" = interactive && run_interactive_rebase\n-\n-# Detach HEAD and reset the tree\n-say \"First, rewinding head to replay your work on top of it...\"\n-git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $branch\n-\n if test -n \"$diffstat\"\n then\n \tif test -n \"$verbose\"\n@@ -557,6 +550,13 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n+test \"$type\" = interactive && run_interactive_rebase\n+\n+# Detach HEAD and reset the tree\n+say \"First, rewinding head to replay your work on top of it...\"\n+git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n+git update-ref ORIG_HEAD $branch\n+\n # If the $onto is a proper descendant of the tip of the branch, then\n # we just fast-forwarded.\n if test \"$mb\" = \"$branch\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158655","messageId":"1293528648-21873-18-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 17/31] rebase: remove $branch as synonym for $orig_head","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:34Z","receivedAt":"2010-12-28T09:30:34Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The variables $branch and $orig_head were used as synonyms. To avoid\nconfusion, remove $branch. The name 'orig_head' seems more suitable,\nsince that is the name used when the variable is persisted.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |   19 +++++++++----------\n 1 files changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 0fc580a..eae2f7a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -487,10 +487,10 @@ case \"$#\" in\n \tswitch_to=\"$1\"\n \n \tif git show-ref --verify --quiet -- \"refs/heads/$1\" &&\n-\t   branch=$(git rev-parse -q --verify \"refs/heads/$1\")\n+\t   orig_head=$(git rev-parse -q --verify \"refs/heads/$1\")\n \tthen\n \t\thead_name=\"refs/heads/$1\"\n-\telif branch=$(git rev-parse -q --verify \"$1\")\n+\telif orig_head=$(git rev-parse -q --verify \"$1\")\n \tthen\n \t\thead_name=\"detached HEAD\"\n \telse\n@@ -507,24 +507,23 @@ case \"$#\" in\n \t\thead_name=\"detached HEAD\"\n \t\tbranch_name=HEAD ;# detached\n \tfi\n-\tbranch=$(git rev-parse --verify \"${branch_name}^0\") || exit\n+\torig_head=$(git rev-parse --verify \"${branch_name}^0\") || exit\n \t;;\n esac\n-orig_head=$branch\n \n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n-# Now we are rebasing commits $upstream..$branch (or with --root,\n-# everything leading up to $branch) on top of $onto\n+# Now we are rebasing commits $upstream..$orig_head (or with --root,\n+# everything leading up to $orig_head) on top of $onto\n \n # Check if we are already based on $onto with linear history,\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\" \"$branch\")\n+mb=$(git merge-base \"$onto\" \"$orig_head\")\n if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n \ttest \"$mb\" = \"$onto\" &&\n \t# linear history?\n-\t! (git rev-list --parents \"$onto\"..\"$branch\" | sane_grep \" .* \") > /dev/null\n+\t! (git rev-list --parents \"$onto\"..\"$orig_head\" | sane_grep \" .* \") > /dev/null\n then\n \tif test -z \"$force_rebase\"\n \tthen\n@@ -555,11 +554,11 @@ test \"$type\" = interactive && run_interactive_rebase\n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $branch\n+git update-ref ORIG_HEAD $orig_head\n \n # If the $onto is a proper descendant of the tip of the branch, then\n # we just fast-forwarded.\n-if test \"$mb\" = \"$branch\"\n+if test \"$mb\" = \"$orig_head\"\n then\n \tsay \"Fast-forwarded $branch_name to $onto_name.\"\n \tmove_to_original_branch\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158653","messageId":"1293528648-21873-19-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:35Z","receivedAt":"2010-12-28T09:30:35Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Extract the code for merge-based rebase to git-rebase--merge.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nWhat copyright year? Most of the code is just extracted from\ngit-rebase.sh, which has copyright year 2005. Does that matter?\n\nWould read_initial_state be a better name than read_basic_state?\n\n .gitignore           |    1 +\n Makefile             |    1 +\n git-rebase--merge.sh |  154 ++++++++++++++++++++++++++++++++++++++++++++++\n git-rebase.sh        |  167 +++++---------------------------------------------\n 4 files changed, 171 insertions(+), 152 deletions(-)\n create mode 100644 git-rebase--merge.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 87b833c..40506ff 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -103,6 +103,7 @@\n /git-read-tree\n /git-rebase\n /git-rebase--interactive\n+/git-rebase--merge\n /git-receive-pack\n /git-reflog\n /git-relink\ndiff --git a/Makefile b/Makefile\nindex ff35154..ffc3a5d 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -370,6 +370,7 @@ SCRIPT_SH += git-mergetool.sh\n SCRIPT_SH += git-pull.sh\n SCRIPT_SH += git-quiltimport.sh\n SCRIPT_SH += git-rebase--interactive.sh\n+SCRIPT_SH += git-rebase--merge.sh\n SCRIPT_SH += git-rebase.sh\n SCRIPT_SH += git-repack.sh\n SCRIPT_SH += git-request-pull.sh\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nnew file mode 100644\nindex 0000000..8cfdcf1\n--- /dev/null\n+++ b/git-rebase--merge.sh\n@@ -0,0 +1,154 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Junio C Hamano.\n+#\n+\n+. git-sh-setup\n+\n+prec=4\n+\n+read_state () {\n+\tonto_name=$(cat \"$state_dir\"/onto_name) &&\n+\tend=$(cat \"$state_dir\"/end) &&\n+\tmsgnum=$(cat \"$state_dir\"/msgnum)\n+}\n+\n+continue_merge () {\n+\ttest -d \"$state_dir\" || die \"$state_dir directory does not exist\"\n+\n+\tunmerged=$(git ls-files -u)\n+\tif test -n \"$unmerged\"\n+\tthen\n+\t\techo \"You still have unmerged paths in your index\"\n+\t\techo \"did you forget to use git add?\"\n+\t\tdie \"$RESOLVEMSG\"\n+\tfi\n+\n+\tcmt=`cat \"$state_dir/current\"`\n+\tif ! git diff-index --quiet --ignore-submodules HEAD --\n+\tthen\n+\t\tif ! git commit --no-verify -C \"$cmt\"\n+\t\tthen\n+\t\t\techo \"Commit failed, please do not call \\\"git commit\\\"\"\n+\t\t\techo \"directly, but instead do one of the following: \"\n+\t\t\tdie \"$RESOLVEMSG\"\n+\t\tfi\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n+\t\tfi\n+\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$state_dir/rewritten\"\n+\telse\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n+\t\tfi\n+\tfi\n+\ttest -z \"$GIT_QUIET\" &&\n+\tGIT_PAGER='' git log --format=%s -1 \"$cmt\"\n+\n+\t# onto the next patch:\n+\tmsgnum=$(($msgnum + 1))\n+\techo \"$msgnum\" >\"$state_dir/msgnum\"\n+}\n+\n+call_merge () {\n+\tcmt=\"$(cat \"$state_dir/cmt.$1\")\"\n+\techo \"$cmt\" > \"$state_dir/current\"\n+\thd=$(git rev-parse --verify HEAD)\n+\tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n+\tmsgnum=$(cat \"$state_dir/msgnum\")\n+\teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n+\teval GITHEAD_$hd='$onto_name'\n+\texport GITHEAD_$cmt GITHEAD_$hd\n+\tif test -n \"$GIT_QUIET\"\n+\tthen\n+\t\tGIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY\n+\tfi\n+\ttest -z \"$strategy\" && strategy=recursive\n+\teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n+\trv=$?\n+\tcase \"$rv\" in\n+\t0)\n+\t\tunset GITHEAD_$cmt GITHEAD_$hd\n+\t\treturn\n+\t\t;;\n+\t1)\n+\t\tgit rerere $allow_rerere_autoupdate\n+\t\tdie \"$RESOLVEMSG\"\n+\t\t;;\n+\t2)\n+\t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n+\t\tdie \"$RESOLVEMSG\"\n+\t\t;;\n+\t*)\n+\t\tdie \"Unknown exit code ($rv) from command:\" \\\n+\t\t\t\"git-merge-$strategy $cmt^ -- HEAD $cmt\"\n+\t\t;;\n+\tesac\n+}\n+\n+finish_rb_merge () {\n+\tmove_to_original_branch\n+\tgit notes copy --for-rewrite=rebase < \"$state_dir\"/rewritten\n+\tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n+\t\ttest -s \"$state_dir\"/rewritten; then\n+\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$state_dir\"/rewritten\n+\tfi\n+\trm -r \"$state_dir\"\n+\tsay All done.\n+}\n+\n+case \"$action\" in\n+continue)\n+\tread_state\n+\tcontinue_merge\n+\twhile test \"$msgnum\" -le \"$end\"\n+\tdo\n+\t\tcall_merge \"$msgnum\"\n+\t\tcontinue_merge\n+\tdone\n+\tfinish_rb_merge\n+\texit\n+\t;;\n+skip)\n+\tread_state\n+\tgit rerere clear\n+\tmsgnum=$(($msgnum + 1))\n+\twhile test \"$msgnum\" -le \"$end\"\n+\tdo\n+\t\tcall_merge \"$msgnum\"\n+\t\tcontinue_merge\n+\tdone\n+\tfinish_rb_merge\n+\texit\n+\t;;\n+esac\n+\n+mkdir -p \"$state_dir\"\n+echo \"$onto_name\" > \"$state_dir/onto_name\"\n+echo \"$head_name\" > \"$state_dir/head-name\"\n+echo \"$onto\" > \"$state_dir/onto\"\n+echo \"$orig_head\" > \"$state_dir/orig-head\"\n+echo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+\n+msgnum=0\n+for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n+do\n+\tmsgnum=$(($msgnum + 1))\n+\techo \"$cmt\" > \"$state_dir/cmt.$msgnum\"\n+done\n+\n+echo 1 >\"$state_dir/msgnum\"\n+echo $msgnum >\"$state_dir/end\"\n+\n+end=$msgnum\n+msgnum=1\n+\n+while test \"$msgnum\" -le \"$end\"\n+do\n+\tcall_merge \"$msgnum\"\n+\tcontinue_merge\n+done\n+\n+finish_rb_merge\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex eae2f7a..ee586e8 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -48,7 +48,6 @@ strategy_opts=\n do_merge=\n merge_dir=\"$GIT_DIR\"/rebase-merge\n apply_dir=\"$GIT_DIR\"/rebase-apply\n-prec=4\n verbose=\n diffstat=\n test \"$(git config --bool rebase.stat)\" = true && diffstat=t\n@@ -68,94 +67,13 @@ preserve_merges=\n autosquash=\n test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n \n-read_state () {\n-\tif test \"$type\" = merge\n-\tthen\n-\t\tonto_name=$(cat \"$state_dir\"/onto_name) &&\n-\t\tend=$(cat \"$state_dir\"/end) &&\n-\t\tmsgnum=$(cat \"$state_dir\"/msgnum)\n-\tfi &&\n+read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n \torig_head=$(cat \"$state_dir\"/orig-head) &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n-continue_merge () {\n-\ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n-\n-\tunmerged=$(git ls-files -u)\n-\tif test -n \"$unmerged\"\n-\tthen\n-\t\techo \"You still have unmerged paths in your index\"\n-\t\techo \"did you forget to use git add?\"\n-\t\tdie \"$RESOLVEMSG\"\n-\tfi\n-\n-\tcmt=`cat \"$merge_dir/current\"`\n-\tif ! git diff-index --quiet --ignore-submodules HEAD --\n-\tthen\n-\t\tif ! git commit --no-verify -C \"$cmt\"\n-\t\tthen\n-\t\t\techo \"Commit failed, please do not call \\\"git commit\\\"\"\n-\t\t\techo \"directly, but instead do one of the following: \"\n-\t\t\tdie \"$RESOLVEMSG\"\n-\t\tfi\n-\t\tif test -z \"$GIT_QUIET\"\n-\t\tthen\n-\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n-\t\tfi\n-\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$merge_dir/rewritten\"\n-\telse\n-\t\tif test -z \"$GIT_QUIET\"\n-\t\tthen\n-\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n-\t\tfi\n-\tfi\n-\ttest -z \"$GIT_QUIET\" &&\n-\tGIT_PAGER='' git log --format=%s -1 \"$cmt\"\n-\n-\t# onto the next patch:\n-\tmsgnum=$(($msgnum + 1))\n-\techo \"$msgnum\" >\"$merge_dir/msgnum\"\n-}\n-\n-call_merge () {\n-\tcmt=\"$(cat \"$merge_dir/cmt.$1\")\"\n-\techo \"$cmt\" > \"$merge_dir/current\"\n-\thd=$(git rev-parse --verify HEAD)\n-\tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n-\tmsgnum=$(cat \"$merge_dir/msgnum\")\n-\teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n-\teval GITHEAD_$hd='$onto_name'\n-\texport GITHEAD_$cmt GITHEAD_$hd\n-\tif test -n \"$GIT_QUIET\"\n-\tthen\n-\t\tGIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY\n-\tfi\n-\ttest -z \"$strategy\" && strategy=recursive\n-\teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n-\trv=$?\n-\tcase \"$rv\" in\n-\t0)\n-\t\tunset GITHEAD_$cmt GITHEAD_$hd\n-\t\treturn\n-\t\t;;\n-\t1)\n-\t\tgit rerere $allow_rerere_autoupdate\n-\t\tdie \"$RESOLVEMSG\"\n-\t\t;;\n-\t2)\n-\t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n-\t\tdie \"$RESOLVEMSG\"\n-\t\t;;\n-\t*)\n-\t\tdie \"Unknown exit code ($rv) from command:\" \\\n-\t\t\t\"git-merge-$strategy $cmt^ -- HEAD $cmt\"\n-\t\t;;\n-\tesac\n-}\n-\n move_to_original_branch () {\n \tcase \"$head_name\" in\n \trefs/*)\n@@ -168,25 +86,17 @@ move_to_original_branch () {\n \tesac\n }\n \n-finish_rb_merge () {\n-\tmove_to_original_branch\n-\tgit notes copy --for-rewrite=rebase < \"$merge_dir\"/rewritten\n-\tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n-\t\ttest -s \"$merge_dir\"/rewritten; then\n-\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$merge_dir\"/rewritten\n-\tfi\n-\trm -r \"$merge_dir\"\n-\tsay All done.\n-}\n-\n-run_interactive_rebase () {\n+run_specific_rebase () {\n \tif [ \"$interactive_rebase\" = implied ]; then\n \t\tGIT_EDITOR=:\n \t\texport GIT_EDITOR\n \tfi\n \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n-\tforce_rebase action preserve_merges upstream switch_to head_name\n-\texec git-rebase--interactive\n+\tforce_rebase action preserve_merges upstream switch_to head_name \\\n+\tstate_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \\\n+\tallow_rerere_autoupdate\n+\texport -f move_to_original_branch\n+\ttest \"$type\" != am && exec git-rebase--$type\n }\n \n run_pre_rebase_hook () {\n@@ -343,7 +253,7 @@ test $# -gt 2 && usage\n if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\ttest \"$type\" = interactive && run_interactive_rebase\n+\ttest \"$type\" = interactive && run_specific_rebase\n fi\n \n case \"$action\" in\n@@ -354,44 +264,23 @@ continue)\n \t\techo \"mark them as resolved using git add\"\n \t\texit 1\n \t}\n-\tread_state\n-\tif test -d \"$merge_dir\"\n-\tthen\n-\t\tcontinue_merge\n-\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\tdo\n-\t\t\tcall_merge \"$msgnum\"\n-\t\t\tcontinue_merge\n-\t\tdone\n-\t\tfinish_rb_merge\n-\t\texit\n-\tfi\n+\tread_basic_state\n+\trun_specific_rebase\n \tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n skip)\n \tgit reset --hard HEAD || exit $?\n-\tread_state\n-\tif test -d \"$merge_dir\"\n-\tthen\n-\t\tgit rerere clear\n-\t\tmsgnum=$(($msgnum + 1))\n-\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\tdo\n-\t\t\tcall_merge \"$msgnum\"\n-\t\t\tcontinue_merge\n-\t\tdone\n-\t\tfinish_rb_merge\n-\t\texit\n-\tfi\n+\tread_basic_state\n+\trun_specific_rebase\n \tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n abort)\n \tgit rerere clear\n-\tread_state\n+\tread_basic_state\n \tcase \"$head_name\" in\n \trefs/*)\n \t\tgit symbolic-ref HEAD $head_name ||\n@@ -549,7 +438,7 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n-test \"$type\" = interactive && run_interactive_rebase\n+test \"$type\" = interactive && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n@@ -591,30 +480,4 @@ fi\n # start doing a rebase with git-merge\n # this is rename-aware if the recursive (default) strategy is used\n \n-mkdir -p \"$merge_dir\"\n-echo \"$onto_name\" > \"$merge_dir/onto_name\"\n-echo \"$head_name\" > \"$merge_dir/head-name\"\n-echo \"$onto\" > \"$merge_dir/onto\"\n-echo \"$orig_head\" > \"$merge_dir/orig-head\"\n-echo \"$GIT_QUIET\" > \"$merge_dir/quiet\"\n-\n-msgnum=0\n-for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n-do\n-\tmsgnum=$(($msgnum + 1))\n-\techo \"$cmt\" > \"$merge_dir/cmt.$msgnum\"\n-done\n-\n-echo 1 >\"$merge_dir/msgnum\"\n-echo $msgnum >\"$merge_dir/end\"\n-\n-end=$msgnum\n-msgnum=1\n-\n-while test \"$msgnum\" -le \"$end\"\n-do\n-\tcall_merge \"$msgnum\"\n-\tcontinue_merge\n-done\n-\n-finish_rb_merge\n+run_specific_rebase\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158652","messageId":"1293528648-21873-20-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 19/31] rebase: extract am code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:36Z","receivedAt":"2010-12-28T09:30:36Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Extract the code for am-based rebase to git-rebase--am.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n .gitignore        |    1 +\n Makefile          |    1 +\n git-rebase--am.sh |   34 ++++++++++++++++++++++++++++++++++\n git-rebase.sh     |   33 +++------------------------------\n 4 files changed, 39 insertions(+), 30 deletions(-)\n create mode 100644 git-rebase--am.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 40506ff..ef04058 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -102,6 +102,7 @@\n /git-quiltimport\n /git-read-tree\n /git-rebase\n+/git-rebase--am\n /git-rebase--interactive\n /git-rebase--merge\n /git-receive-pack\ndiff --git a/Makefile b/Makefile\nindex ffc3a5d..459df3a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -369,6 +369,7 @@ SCRIPT_SH += git-merge-resolve.sh\n SCRIPT_SH += git-mergetool.sh\n SCRIPT_SH += git-pull.sh\n SCRIPT_SH += git-quiltimport.sh\n+SCRIPT_SH += git-rebase--am.sh\n SCRIPT_SH += git-rebase--interactive.sh\n SCRIPT_SH += git-rebase--merge.sh\n SCRIPT_SH += git-rebase.sh\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nnew file mode 100644\nindex 0000000..9316761\n--- /dev/null\n+++ b/git-rebase--am.sh\n@@ -0,0 +1,34 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Junio C Hamano.\n+#\n+\n+. git-sh-setup\n+\n+case \"$action\" in\n+continue)\n+\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+skip)\n+\tgit am --skip -3 --resolvemsg=\"$RESOLVEMSG\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+esac\n+\n+test -n \"$rebase_root\" && root_flag=--root\n+\n+git format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n+\t--src-prefix=a/ --dst-prefix=b/ \\\n+\t--no-renames $root_flag \"$revisions\" |\n+git am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n+move_to_original_branch\n+ret=$?\n+test 0 != $ret -a -d \"$state_dir\" &&\n+\techo $head_name > \"$state_dir/head-name\" &&\n+\techo $onto > \"$state_dir/onto\" &&\n+\techo $orig_head > \"$state_dir/orig-head\" &&\n+\techo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+exit $ret\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex ee586e8..615d9dd 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -94,9 +94,9 @@ run_specific_rebase () {\n \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n \tforce_rebase action preserve_merges upstream switch_to head_name \\\n \tstate_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \\\n-\tallow_rerere_autoupdate\n+\tallow_rerere_autoupdate git_am_opt\n \texport -f move_to_original_branch\n-\ttest \"$type\" != am && exec git-rebase--$type\n+\texec git-rebase--$type\n }\n \n run_pre_rebase_hook () {\n@@ -266,17 +266,11 @@ continue)\n \t}\n \tread_basic_state\n \trun_specific_rebase\n-\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n-\tmove_to_original_branch\n-\texit\n \t;;\n skip)\n \tgit reset --hard HEAD || exit $?\n \tread_basic_state\n \trun_specific_rebase\n-\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n-\tmove_to_original_branch\n-\texit\n \t;;\n abort)\n \tgit rerere clear\n@@ -329,14 +323,12 @@ then\n \tshift\n \tupstream=`git rev-parse --verify \"${upstream_name}^0\"` ||\n \tdie \"invalid upstream $upstream_name\"\n-\tunset root_flag\n \tupstream_arg=\"$upstream_name\"\n else\n \ttest -z \"$onto\" && die \"You must specify --onto when using --root\"\n \tunset upstream_name\n \tunset upstream\n-\troot_flag=\"--root\"\n-\tupstream_arg=\"$root_flag\"\n+\tupstream_arg=--root\n fi\n \n # Make sure the branch to rebase onto is valid.\n@@ -461,23 +453,4 @@ else\n \trevisions=\"$upstream..$orig_head\"\n fi\n \n-if test -z \"$do_merge\"\n-then\n-\tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n-\t\t--src-prefix=a/ --dst-prefix=b/ \\\n-\t\t--no-renames $root_flag \"$revisions\" |\n-\tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n-\tmove_to_original_branch\n-\tret=$?\n-\ttest 0 != $ret -a -d \"$apply_dir\" &&\n-\t\techo $head_name > \"$apply_dir/head-name\" &&\n-\t\techo $onto > \"$apply_dir/onto\" &&\n-\t\techo $orig_head > \"$apply_dir/orig-head\" &&\n-\t\techo \"$GIT_QUIET\" > \"$apply_dir/quiet\"\n-\texit $ret\n-fi\n-\n-# start doing a rebase with git-merge\n-# this is rename-aware if the recursive (default) strategy is used\n-\n run_specific_rebase\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158656","messageId":"1293528648-21873-21-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 20/31] rebase: show consistent conflict resolution hint","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:37Z","receivedAt":"2010-12-28T09:30:37Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"When rebase stops due to conflict, interactive rebase currently\ndisplays a different hint to the user than non-interactive rebase\ndoes. Use the same message for both types of rebase.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nShould we include the \"mark the corrected paths with 'git add\n<paths>'\" part?\n\n git-rebase--interactive.sh |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0beeb8b..e848ea2 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -81,9 +81,7 @@ AMEND=\"$DOTEST\"/amend\n REWRITTEN_LIST=\"$DOTEST\"/rewritten-list\n REWRITTEN_PENDING=\"$DOTEST\"/rewritten-pending\n \n-GIT_CHERRY_PICK_HELP=\"\\\n-hint: after resolving the conflicts, mark the corrected paths\n-hint: with 'git add <paths>' and run 'git rebase --continue'\"\n+GIT_CHERRY_PICK_HELP=\"$RESOLVEMSG\"\n export GIT_CHERRY_PICK_HELP\n \n warn () {\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158657","messageId":"1293528648-21873-22-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 21/31] rebase -i: align variable names","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:38Z","receivedAt":"2010-12-28T09:30:38Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Rename variables HEAD and OLDHEAD to orig_head and HEADNAME to\nhead_name, which are the names used in git-rebase.sh. This prepares\nfor factoring out of the code that persists these variables during the\nentire rebase process. Using the same variable names to mean the same\nthing in both files also makes the code easier to read.\n\nWhile at it, also remove the DOTEST variable and use the state_dir\nvariable that was inherited from git-rebase.sh instead.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nSquash this commit with earlier commit that also renamed variables in\ngit-rebase--interactive.sh?\n\n git-rebase--interactive.sh |  120 +++++++++++++++++++++----------------------\n 1 files changed, 59 insertions(+), 61 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex e848ea2..eace4e5 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -12,22 +12,20 @@\n \n . git-sh-setup\n \n-DOTEST=\"$GIT_DIR/rebase-merge\"\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=\"$DOTEST\"/git-rebase-todo\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=\"$DOTEST\"/done\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=\"$DOTEST\"/message\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@@ -42,14 +40,14 @@ MSG=\"$DOTEST\"/message\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=\"$DOTEST\"/message-squash\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=\"$DOTEST\"/message-fixup\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@@ -57,14 +55,14 @@ FIXUP_MSG=\"$DOTEST\"/message-fixup\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=\"$DOTEST\"/rewritten\n+REWRITTEN=\"$state_dir\"/rewritten\n \n-DROPPED=\"$DOTEST\"/dropped\n+DROPPED=\"$state_dir\"/dropped\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=\"$DOTEST\"/author-script\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@@ -72,14 +70,14 @@ AUTHOR_SCRIPT=\"$DOTEST\"/author-script\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=\"$DOTEST\"/amend\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=\"$DOTEST\"/rewritten-list\n-REWRITTEN_PENDING=\"$DOTEST\"/rewritten-pending\n+REWRITTEN_LIST=\"$state_dir\"/rewritten-list\n+REWRITTEN_PENDING=\"$state_dir\"/rewritten-pending\n \n GIT_CHERRY_PICK_HELP=\"$RESOLVEMSG\"\n export GIT_CHERRY_PICK_HELP\n@@ -145,7 +143,7 @@ make_patch () {\n \t*)\n \t\techo \"Root commit\"\n \t\t;;\n-\tesac > \"$DOTEST\"/patch\n+\tesac > \"$state_dir\"/patch\n \ttest -f \"$MSG\" ||\n \t\tcommit_message \"$1\" > \"$MSG\"\n \ttest -f \"$AUTHOR_SCRIPT\" ||\n@@ -153,14 +151,14 @@ make_patch () {\n }\n \n die_with_patch () {\n-\techo \"$1\" > \"$DOTEST\"/stopped-sha\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n \tmake_patch \"$1\"\n \tgit rerere\n \tdie \"$2\"\n }\n \n die_abort () {\n-\trm -rf \"$DOTEST\"\n+\trm -rf \"$state_dir\"\n \tdie \"$1\"\n }\n \n@@ -205,20 +203,20 @@ pick_one_preserving_merges () {\n \tesac\n \tsha1=$(git rev-parse $sha1)\n \n-\tif test -f \"$DOTEST\"/current-commit\n+\tif test -f \"$state_dir\"/current-commit\n \tthen\n \t\tif test \"$fast_forward\" = t\n \t\tthen\n \t\t\twhile read current_commit\n \t\t\tdo\n \t\t\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit\n-\t\t\tdone <\"$DOTEST\"/current-commit\n-\t\t\trm \"$DOTEST\"/current-commit ||\n+\t\t\tdone <\"$state_dir\"/current-commit\n+\t\t\trm \"$state_dir\"/current-commit ||\n \t\t\tdie \"Cannot write current commit's replacement sha1\"\n \t\tfi\n \tfi\n \n-\techo $sha1 >> \"$DOTEST\"/current-commit\n+\techo $sha1 >> \"$state_dir\"/current-commit\n \n \t# rewrite parents; if none were rewritten, we can fast-forward.\n \tnew_parents=\n@@ -425,7 +423,7 @@ do_next () {\n \t\tmark_action_done\n \t\tpick_one $sha1 ||\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n-\t\techo \"$sha1\" > \"$DOTEST\"/stopped-sha\n+\t\techo \"$sha1\" > \"$state_dir\"/stopped-sha\n \t\tmake_patch $sha1\n \t\tgit rev-parse --verify HEAD > \"$AMEND\"\n \t\twarn \"Stopped at $sha1... $rest\"\n@@ -490,7 +488,7 @@ do_next () {\n \t\tprintf 'Executing: %s\\n' \"$rest\"\n \t\t# \"exec\" command doesn't take a sha1 in the todo-list.\n \t\t# => can't just use $sha1 here.\n-\t\tgit rev-parse --verify HEAD > \"$DOTEST\"/stopped-sha\n+\t\tgit rev-parse --verify HEAD > \"$state_dir\"/stopped-sha\n \t\t${SHELL:-@SHELL_PATH@} -c \"$rest\" # Actual execution\n \t\tstatus=$?\n \t\tif test \"$status\" -ne 0\n@@ -525,19 +523,19 @@ do_next () {\n \ttest -s \"$TODO\" && return\n \n \tcomment_for_reflog finish &&\n-\tHEADNAME=$(cat \"$DOTEST\"/head-name) &&\n-\tOLDHEAD=$(cat \"$DOTEST\"/head) &&\n-\tSHORTONTO=$(git rev-parse --short $(cat \"$DOTEST\"/onto)) &&\n+\thead_name=$(cat \"$state_dir\"/head-name) &&\n+\torig_head=$(cat \"$state_dir\"/head) &&\n+\tSHORTONTO=$(git rev-parse --short $(cat \"$state_dir\"/onto)) &&\n \tNEWHEAD=$(git rev-parse HEAD) &&\n-\tcase $HEADNAME in\n+\tcase $head_name in\n \trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO\" &&\n-\t\tgit update-ref -m \"$message\" $HEADNAME $NEWHEAD $OLDHEAD &&\n-\t\tgit symbolic-ref HEAD $HEADNAME\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $SHORTONTO\" &&\n+\t\tgit update-ref -m \"$message\" $head_name $NEWHEAD $orig_head &&\n+\t\tgit symbolic-ref HEAD $head_name\n \t\t;;\n \tesac && {\n-\t\ttest ! -f \"$DOTEST\"/verbose ||\n-\t\t\tgit diff-tree --stat $(cat \"$DOTEST\"/head)..HEAD\n+\t\ttest ! -f \"$state_dir\"/verbose ||\n+\t\t\tgit diff-tree --stat $(cat \"$state_dir\"/head)..HEAD\n \t} &&\n \t{\n \t\ttest -s \"$REWRITTEN_LIST\" &&\n@@ -549,9 +547,9 @@ do_next () {\n \t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$REWRITTEN_LIST\"\n \t\ttrue # we don't care if this hook failed\n \tfi &&\n-\trm -rf \"$DOTEST\" &&\n+\trm -rf \"$state_dir\" &&\n \tgit gc --auto &&\n-\twarn \"Successfully rebased and updated $HEADNAME.\"\n+\twarn \"Successfully rebased and updated $head_name.\"\n \n \texit\n }\n@@ -602,9 +600,9 @@ skip_unnecessary_picks () {\n \n get_saved_options () {\n \ttest -d \"$REWRITTEN\" && preserve_merges=t\n-\ttest -f \"$DOTEST\"/strategy && strategy=\"$(cat \"$DOTEST\"/strategy)\"\n-\ttest -f \"$DOTEST\"/verbose && verbose=t\n-\ttest -f \"$DOTEST\"/rebase-root && rebase_root=t\n+\ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n+\ttest -f \"$state_dir\"/verbose && verbose=t\n+\ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n # Rearrange the todo list that has both \"pick sha1 msg\" and\n@@ -704,7 +702,7 @@ first and then run 'git rebase --continue' again.\"\n \t\t}\n \tfi\n \n-\trecord_in_rewritten \"$(cat \"$DOTEST\"/stopped-sha)\"\n+\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n \n \trequire_clean_work_tree \"rebase\"\n \tdo_rest\n@@ -715,15 +713,15 @@ abort)\n \n \tgit rerere clear\n \n-\tHEADNAME=$(cat \"$DOTEST\"/head-name)\n-\tHEAD=$(cat \"$DOTEST\"/head)\n-\tcase $HEADNAME in\n+\thead_name=$(cat \"$state_dir\"/head-name)\n+\torig_head=$(cat \"$state_dir\"/head)\n+\tcase $head_name in\n \trefs/*)\n-\t\tgit symbolic-ref HEAD $HEADNAME\n+\t\tgit symbolic-ref HEAD $head_name\n \t\t;;\n \tesac &&\n-\toutput git reset --hard $HEAD &&\n-\trm -rf \"$DOTEST\"\n+\toutput git reset --hard $orig_head &&\n+\trm -rf \"$state_dir\"\n \texit\n \t;;\n skip)\n@@ -747,28 +745,28 @@ then\n \t\tdie \"Could not checkout $switch_to\"\n fi\n \n-HEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n-mkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n+orig_head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n+mkdir \"$state_dir\" || die \"Could not create temporary $state_dir\"\n \n-: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n-echo \"$head_name\" > \"$DOTEST\"/head-name\n+: > \"$state_dir\"/interactive || die \"Could not mark as interactive\"\n+echo \"$head_name\" > \"$state_dir\"/head-name\n \n-echo $HEAD > \"$DOTEST\"/head\n+echo $orig_head > \"$state_dir\"/head\n case \"$rebase_root\" in\n '')\n-\trm -f \"$DOTEST\"/rebase-root ;;\n+\trm -f \"$state_dir\"/rebase-root ;;\n *)\n-\t: >\"$DOTEST\"/rebase-root ;;\n+\t: >\"$state_dir\"/rebase-root ;;\n esac\n-echo $onto > \"$DOTEST\"/onto\n-test -z \"$strategy\" || echo \"$strategy\" > \"$DOTEST\"/strategy\n-test t = \"$verbose\" && : > \"$DOTEST\"/verbose\n+echo $onto > \"$state_dir\"/onto\n+test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n+test t = \"$verbose\" && : > \"$state_dir\"/verbose\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\n \tthen\n \t\tmkdir \"$REWRITTEN\" &&\n-\t\tfor c in $(git merge-base --all $HEAD $upstream)\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 \"Could not init rewritten commits\"\n@@ -782,21 +780,21 @@ then\n \t# parents to rewrite and skipping dropped commits would\n \t# prematurely end our probe\n \tMERGES_OPTION=\n-\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $upstream..$HEAD | head -n 1)\"\n+\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $upstream..$orig_head | head -n 1)\"\n else\n \tMERGES_OPTION=\"--no-merges --cherry-pick\"\n fi\n \n-SHORTHEAD=$(git rev-parse --short $HEAD)\n+SHORTHEAD=$(git rev-parse --short $orig_head)\n SHORTONTO=$(git rev-parse --short $onto)\n if test -z \"$rebase_root\"\n \t# this is now equivalent to ! -z \"$upstream\"\n then\n \tSHORTUPSTREAM=$(git rev-parse --short $upstream)\n-\tREVISIONS=$upstream...$HEAD\n+\tREVISIONS=$upstream...$orig_head\n \tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n else\n-\tREVISIONS=$onto...$HEAD\n+\tREVISIONS=$onto...$orig_head\n \tSHORTREVISIONS=$SHORTHEAD\n fi\n git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n@@ -837,13 +835,13 @@ then\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\" > \"$DOTEST\"/not-cherry-picks\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 -a \"$(sane_grep \"$rev\" \"$DOTEST\"/not-cherry-picks)\" = \"\"\n+\t\tif test -f \"$REWRITTEN\"/$rev -a \"$(sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks)\" = \"\"\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@@ -889,5 +887,5 @@ has_action \"$TODO\" ||\n test -d \"$REWRITTEN\" || test -n \"$force_rebase\" || skip_unnecessary_picks\n \n output git checkout $onto || die_abort \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $HEAD\n+git update-ref ORIG_HEAD $orig_head\n do_rest\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158659","messageId":"1293528648-21873-23-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 22/31] rebase: make -v a tiny bit more verbose","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:39Z","receivedAt":"2010-12-28T09:30:39Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"To make it possible to later remove the handling of --abort from\ngit-rebase--interactive.sh, align the implementation in git-rebase.sh\nwith the former by making it a bit more verbose.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nWhat do we really want to print when -v is passed? Interactive rebase\nis currently quite a bit more verbose than non-interactive rebase.\n\n git-rebase--interactive.sh |   14 --------------\n git-rebase.sh              |   20 +++++++++++++++++---\n 2 files changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex eace4e5..acd0258 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -86,20 +86,6 @@ warn () {\n \tprintf '%s\\n' \"$*\" >&2\n }\n \n-output () {\n-\tcase \"$verbose\" in\n-\t'')\n-\t\toutput=$(\"$@\" 2>&1 )\n-\t\tstatus=$?\n-\t\ttest $status != 0 && printf \"%s\\n\" \"$output\"\n-\t\treturn $status\n-\t\t;;\n-\t*)\n-\t\t\"$@\"\n-\t\t;;\n-\tesac\n-}\n-\n # Output the commit message for the specified commit.\n commit_message () {\n \tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 615d9dd..0322f27 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -74,6 +74,20 @@ read_basic_state () {\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n+output () {\n+\tcase \"$verbose\" in\n+\t'')\n+\t\toutput=$(\"$@\" 2>&1 )\n+\t\tstatus=$?\n+\t\ttest $status != 0 && printf \"%s\\n\" \"$output\"\n+\t\treturn $status\n+\t\t;;\n+\t*)\n+\t\t\"$@\"\n+\t\t;;\n+\tesac\n+}\n+\n move_to_original_branch () {\n \tcase \"$head_name\" in\n \trefs/*)\n@@ -95,7 +109,7 @@ run_specific_rebase () {\n \tforce_rebase action preserve_merges upstream switch_to head_name \\\n \tstate_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \\\n \tallow_rerere_autoupdate git_am_opt\n-\texport -f move_to_original_branch\n+\texport -f move_to_original_branch output\n \texec git-rebase--$type\n }\n \n@@ -268,7 +282,7 @@ continue)\n \trun_specific_rebase\n \t;;\n skip)\n-\tgit reset --hard HEAD || exit $?\n+\toutput git reset --hard HEAD || exit $?\n \tread_basic_state\n \trun_specific_rebase\n \t;;\n@@ -281,7 +295,7 @@ abort)\n \t\tdie \"Could not move back to $head_name\"\n \t\t;;\n \tesac\n-\tgit reset --hard $orig_head\n+\toutput git reset --hard $orig_head\n \trm -r \"$state_dir\"\n \texit\n \t;;\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158654","messageId":"1293528648-21873-24-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 23/31] rebase: factor out sub command handling","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:40Z","receivedAt":"2010-12-28T09:30:40Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Factor out the common parts of the handling of the sub commands\n'--continue', '--skip' and '--abort'. The '--abort' handling can\nhandled completely in git-rebase.sh.\n\nAfter this refactoring, the calls to git-rebase--am.sh,\ngit-rebase--merge.sh and git-rebase--interactive.sh will be better\naligned. There will only be one call to interactive rebase that will\nshortcut the very last part of git-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   34 +++-------------------------------\n git-rebase.sh              |   17 +++++++++++++++--\n 2 files changed, 18 insertions(+), 33 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex acd0258..1079994 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -509,9 +509,7 @@ do_next () {\n \ttest -s \"$TODO\" && return\n \n \tcomment_for_reflog finish &&\n-\thead_name=$(cat \"$state_dir\"/head-name) &&\n-\torig_head=$(cat \"$state_dir\"/head) &&\n-\tSHORTONTO=$(git rev-parse --short $(cat \"$state_dir\"/onto)) &&\n+\tSHORTONTO=$(git rev-parse --short $onto) &&\n \tNEWHEAD=$(git rev-parse HEAD) &&\n \tcase $head_name in\n \trefs/*)\n@@ -521,7 +519,7 @@ do_next () {\n \t\t;;\n \tesac && {\n \t\ttest ! -f \"$state_dir\"/verbose ||\n-\t\t\tgit diff-tree --stat $(cat \"$state_dir\"/head)..HEAD\n+\t\t\tgit diff-tree --stat $orig_head..HEAD\n \t} &&\n \t{\n \t\ttest -s \"$REWRITTEN_LIST\" &&\n@@ -655,14 +653,6 @@ rearrange_squash () {\n case \"$action\" in\n continue)\n \tget_saved_options\n-\tcomment_for_reflog continue\n-\n-\t# Sanity check\n-\tgit rev-parse --verify HEAD >/dev/null ||\n-\t\tdie \"Cannot read HEAD\"\n-\tgit update-index --ignore-submodules --refresh &&\n-\t\tgit diff-files --quiet --ignore-submodules ||\n-\t\tdie \"Working tree is dirty\"\n \n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet --ignore-submodules HEAD --\n@@ -693,30 +683,12 @@ first and then run 'git rebase --continue' again.\"\n \trequire_clean_work_tree \"rebase\"\n \tdo_rest\n \t;;\n-abort)\n-\tget_saved_options\n-\tcomment_for_reflog abort\n-\n-\tgit rerere clear\n-\n-\thead_name=$(cat \"$state_dir\"/head-name)\n-\torig_head=$(cat \"$state_dir\"/head)\n-\tcase $head_name in\n-\trefs/*)\n-\t\tgit symbolic-ref HEAD $head_name\n-\t\t;;\n-\tesac &&\n-\toutput git reset --hard $orig_head &&\n-\trm -rf \"$state_dir\"\n-\texit\n-\t;;\n skip)\n \tget_saved_options\n-\tcomment_for_reflog skip\n \n \tgit rerere clear\n \n-\toutput git reset --hard && do_rest\n+\tdo_rest\n \t;;\n esac\n \ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 0322f27..7e2e978 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -70,7 +70,12 @@ test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n-\torig_head=$(cat \"$state_dir\"/orig-head) &&\n+\tif test \"$type\" = interactive\n+\tthen\n+\t\torig_head=$(cat \"$state_dir\"/head)\n+\telse\n+\t\torig_head=$(cat \"$state_dir\"/orig-head)\n+\tfi &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n@@ -267,11 +272,19 @@ test $# -gt 2 && usage\n if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\ttest \"$type\" = interactive && run_specific_rebase\n+\t# Only interactive rebase uses detailed reflog messages\n+\tif test \"$type\" = interactive && 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 case \"$action\" in\n continue)\n+\t# Sanity check\n+\tgit rev-parse --verify HEAD >/dev/null ||\n+\t\tdie \"Cannot read HEAD\"\n \tgit update-index --ignore-submodules --refresh &&\n \tgit diff-files --quiet --ignore-submodules || {\n \t\techo \"You must edit all merge conflicts and then\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158662","messageId":"1293528648-21873-25-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 24/31] rebase: extract code for writing basic state","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:41Z","receivedAt":"2010-12-28T09:30:41Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Extrace the code for writing the state to rebase-apply/ or\nrebase-merge/ when a rebase is initiated. This will make it easier to\nlater make both interactive and non-interactive rebase remember the\noptions used.\n\nNote that non-interactive rebase stores the sha1 of the original head\nin a file called orig-head, while interactive rebase stores it in a\nfile called head.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--am.sh          |    6 +-----\n git-rebase--interactive.sh |    5 +----\n git-rebase--merge.sh       |    5 +----\n git-rebase.sh              |   16 ++++++++++++++--\n 4 files changed, 17 insertions(+), 15 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 9316761..5acfa00 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -26,9 +26,5 @@ git format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n git am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n move_to_original_branch\n ret=$?\n-test 0 != $ret -a -d \"$state_dir\" &&\n-\techo $head_name > \"$state_dir/head-name\" &&\n-\techo $onto > \"$state_dir/onto\" &&\n-\techo $orig_head > \"$state_dir/orig-head\" &&\n-\techo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+test 0 != $ret -a -d \"$state_dir\" && write_basic_state\n exit $ret\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 1079994..a33b246 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -707,16 +707,13 @@ orig_head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n mkdir \"$state_dir\" || die \"Could not create temporary $state_dir\"\n \n : > \"$state_dir\"/interactive || die \"Could not mark as interactive\"\n-echo \"$head_name\" > \"$state_dir\"/head-name\n-\n-echo $orig_head > \"$state_dir\"/head\n+write_basic_state\n case \"$rebase_root\" in\n '')\n \trm -f \"$state_dir\"/rebase-root ;;\n *)\n \t: >\"$state_dir\"/rebase-root ;;\n esac\n-echo $onto > \"$state_dir\"/onto\n test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n test t = \"$verbose\" && : > \"$state_dir\"/verbose\n if test t = \"$preserve_merges\"\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex 8cfdcf1..705d2f5 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -127,10 +127,7 @@ esac\n \n mkdir -p \"$state_dir\"\n echo \"$onto_name\" > \"$state_dir/onto_name\"\n-echo \"$head_name\" > \"$state_dir/head-name\"\n-echo \"$onto\" > \"$state_dir/onto\"\n-echo \"$orig_head\" > \"$state_dir/orig-head\"\n-echo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+write_basic_state\n \n msgnum=0\n for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 7e2e978..95c0d05 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -79,6 +79,18 @@ read_basic_state () {\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n+write_basic_state () {\n+\techo \"$head_name\" > \"$state_dir\"/head-name &&\n+\techo \"$onto\" > \"$state_dir\"/onto &&\n+\tif test \"$type\" = interactive\n+\tthen\n+\t\techo \"$orig_head\" > \"$state_dir\"/head\n+\telse\n+\t\techo \"$orig_head\" > \"$state_dir\"/orig-head\n+\tfi &&\n+\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet\n+}\n+\n output () {\n \tcase \"$verbose\" in\n \t'')\n@@ -113,8 +125,8 @@ run_specific_rebase () {\n \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n \tforce_rebase action preserve_merges upstream switch_to head_name \\\n \tstate_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \\\n-\tallow_rerere_autoupdate git_am_opt\n-\texport -f move_to_original_branch output\n+\tallow_rerere_autoupdate git_am_opt type\n+\texport -f move_to_original_branch output write_basic_state\n \texec git-rebase--$type\n }\n \n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158664","messageId":"1293528648-21873-26-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 25/31] rebase: remember verbose option","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:42Z","receivedAt":"2010-12-28T09:30:42Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Currently, only interactive rebase remembers the value of the '-v'\nflag from the initial invocation. Make non-interactive rebase also\nremember it.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    2 --\n git-rebase.sh              |    6 ++++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a33b246..7809932 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -585,7 +585,6 @@ skip_unnecessary_picks () {\n get_saved_options () {\n \ttest -d \"$REWRITTEN\" && preserve_merges=t\n \ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n-\ttest -f \"$state_dir\"/verbose && verbose=t\n \ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n@@ -715,7 +714,6 @@ case \"$rebase_root\" in\n \t: >\"$state_dir\"/rebase-root ;;\n esac\n test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n-test t = \"$verbose\" && : > \"$state_dir\"/verbose\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 95c0d05..e5be7e5 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -76,7 +76,8 @@ read_basic_state () {\n \telse\n \t\torig_head=$(cat \"$state_dir\"/orig-head)\n \tfi &&\n-\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n+\tGIT_QUIET=$(cat \"$state_dir\"/quiet) &&\n+\ttest -f \"$state_dir\"/verbose && verbose=t\n }\n \n write_basic_state () {\n@@ -88,7 +89,8 @@ write_basic_state () {\n \telse\n \t\techo \"$orig_head\" > \"$state_dir\"/orig-head\n \tfi &&\n-\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet\n+\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet &&\n+\ttest t = \"$verbose\" && : > \"$state_dir\"/verbose\n }\n \n output () {\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158668","messageId":"1293528648-21873-27-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 26/31] rebase: remember strategy and strategy options","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:43Z","receivedAt":"2010-12-28T09:30:43Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"When a rebase is resumed, interactive rebase remembers any merge\nstrategy passed when the rebase was initated. Make non-interactive\nrebase remember any merge strategy as well. Also make non-interactive\nrebase remember any merge strategy options.\n\nTo be able to resume a rebase that was initiated with an older version\nof git (older than this commit), make sure not to expect the saved\noption files to exist.\n\nTest case idea taken from Junio's 71fc224 (t3402: test \"rebase\n-s<strategy> -X<opt>\", 2010-11-11).\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nHow to add support for strategy options to interactive rebase?\n\n git-rebase--interactive.sh |    2 --\n git-rebase.sh              |    6 ++++++\n t/t3418-rebase-continue.sh |   29 +++++++++++++++++++++++++++++\n 3 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 7809932..0763ef5 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -584,7 +584,6 @@ skip_unnecessary_picks () {\n \n get_saved_options () {\n \ttest -d \"$REWRITTEN\" && preserve_merges=t\n-\ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n \ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n@@ -713,7 +712,6 @@ case \"$rebase_root\" in\n *)\n \t: >\"$state_dir\"/rebase-root ;;\n esac\n-test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e5be7e5..d192038 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -78,6 +78,9 @@ read_basic_state () {\n \tfi &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet) &&\n \ttest -f \"$state_dir\"/verbose && verbose=t\n+\ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n+\ttest -f \"$state_dir\"/strategy_opts &&\n+\t\tstrategy_opts=\"$(cat \"$state_dir\"/strategy_opts)\"\n }\n \n write_basic_state () {\n@@ -91,6 +94,9 @@ write_basic_state () {\n \tfi &&\n \techo \"$GIT_QUIET\" > \"$state_dir\"/quiet &&\n \ttest t = \"$verbose\" && : > \"$state_dir\"/verbose\n+\ttest -n \"$strategy\" && echo \"$strategy\" > \"$state_dir\"/strategy\n+\ttest -n \"$strategy_opts\" && echo \"$strategy_opts\" > \\\n+\t\t\"$state_dir\"/strategy_opts\n }\n \n output () {\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 1d90191..5469546 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -45,4 +45,33 @@ test_expect_success 'rebase --continue can not be used with other options' '\n \ttest_must_fail git rebase --continue -v\n '\n \n+test_expect_success 'rebase --continue remembers merge strategy and options' '\n+\trm -fr .git/rebase-* &&\n+\tgit reset --hard commit-new-file-F2-on-topic-branch &&\n+\ttest_commit \"commit-new-file-F3-on-topic-branch\" F3 32 &&\n+\ttest_when_finished \"rm -fr test-bin funny.was.run\" &&\n+\tmkdir test-bin &&\n+\tcat >test-bin/git-merge-funny <<-EOF\n+\t#!$SHELL_PATH\n+\tcase \"\\$1\" in --opt) ;; *) exit 2 ;; esac\n+\tshift &&\n+\t>funny.was.run &&\n+\texec git merge-recursive \"\\$@\"\n+\tEOF\n+\tchmod +x test-bin/git-merge-funny &&\n+\t(\n+\t\tPATH=./test-bin:$PATH\n+\t\ttest_must_fail git rebase -s funny -Xopt master topic\n+\t) &&\n+\ttest -f funny.was.run &&\n+\trm funny.was.run &&\n+\techo \"Resolved\" >F2 &&\n+\tgit add F2 &&\n+\t(\n+\t\tPATH=./test-bin:$PATH\n+\t\tgit rebase --continue\n+\t) &&\n+\ttest -f funny.was.run\n+'\n+\n test_done\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158663","messageId":"1293528648-21873-28-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 27/31] rebase -m: remember allow_rerere_autoupdate option","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:44Z","receivedAt":"2010-12-28T09:30:44Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"If '--[no-]allow_rerere_autoupdate' is passed when 'git rebase -m' is\ncalled and a merge conflict occurs, the flag will be forgotten for the\nrest of the rebase process. Make rebase remember it by saving the\nvalue.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nallow_rerere_autoupdate is only used by git-rebase--merge. Still ok to\nwrite and read it here?\n\nShould allow_rerere_autoupdate also be added to git_am_opt?\n\n git-rebase.sh              |    4 ++++\n t/t3418-rebase-continue.sh |   21 +++++++++++++++++++++\n 2 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d192038..05b4fe1 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -81,6 +81,8 @@ read_basic_state () {\n \ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n \ttest -f \"$state_dir\"/strategy_opts &&\n \t\tstrategy_opts=\"$(cat \"$state_dir\"/strategy_opts)\"\n+\ttest -f \"$state_dir\"/allow_rerere_autoupdate &&\n+\t\tallow_rerere_autoupdate=\"$(cat \"$state_dir\"/allow_rerere_autoupdate)\"\n }\n \n write_basic_state () {\n@@ -97,6 +99,8 @@ write_basic_state () {\n \ttest -n \"$strategy\" && echo \"$strategy\" > \"$state_dir\"/strategy\n \ttest -n \"$strategy_opts\" && echo \"$strategy_opts\" > \\\n \t\t\"$state_dir\"/strategy_opts\n+\ttest -n \"$allow_rerere_autoupdate\" && echo \"$allow_rerere_autoupdate\" > \\\n+\t\t\"$state_dir\"/allow_rerere_autoupdate\n }\n \n output () {\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 5469546..1e855cd 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -74,4 +74,25 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '\n \ttest -f funny.was.run\n '\n \n+test_expect_success 'rebase --continue remembers --rerere-autoupdate' '\n+\trm -fr .git/rebase-* &&\n+\tgit reset --hard commit-new-file-F3-on-topic-branch &&\n+\tgit checkout master\n+\ttest_commit \"commit-new-file-F3\" F3 3 &&\n+\tgit config rerere.enabled true &&\n+\ttest_must_fail git rebase -m master topic &&\n+\techo \"Resolved\" >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail git rebase --continue &&\n+\techo \"Resolved\" >F3 &&\n+\tgit add F3 &&\n+\tgit rebase --continue &&\n+\tgit reset --hard topic@{1} &&\n+\ttest_must_fail git rebase -m --rerere-autoupdate master &&\n+\ttest \"$(cat F2)\" = \"Resolved\" &&\n+\ttest_must_fail git rebase --continue &&\n+\ttest \"$(cat F3)\" = \"Resolved\" &&\n+\tgit rebase --continue\n+'\n+\n test_done\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158658","messageId":"1293528648-21873-29-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 28/31] rebase -m: don't print exit code 2 when merge fails","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:45Z","receivedAt":"2010-12-28T09:30:45Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"When the merge strategy fails, a message suggesting the user to try\nanother strategy is displayed. Remove the \"$rv\" (which is always equal\nto \"2\" in this case) from that message.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--merge.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex 705d2f5..4ea3ca7 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -78,7 +78,7 @@ call_merge () {\n \t\tdie \"$RESOLVEMSG\"\n \t\t;;\n \t2)\n-\t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n+\t\techo \"Strategy: $strategy failed, try another\" 1>&2\n \t\tdie \"$RESOLVEMSG\"\n \t\t;;\n \t*)\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158670","messageId":"1293528648-21873-30-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 29/31] git-rebase--am: remove unnecessary --3way option","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:46Z","receivedAt":"2010-12-28T09:30:46Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Since 22db240 (git-am: propagate --3way options as well, 2008-12-04),\nthe --3way has been propageted across failure, so it is since\npointless to pass it to git-am when resuming.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--am.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 5acfa00..95608c6 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -7,12 +7,12 @@\n \n case \"$action\" in\n continue)\n-\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n+\tgit am --resolved --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n skip)\n-\tgit am --skip -3 --resolvemsg=\"$RESOLVEMSG\" &&\n+\tgit am --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158665","messageId":"1293528648-21873-31-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 30/31] rebase -i: don't read unused variable preserve_merges","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:47Z","receivedAt":"2010-12-28T09:30:47Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Since 8e4a91b (rebase -i: remember the settings of -v, -s and -p when\ninterrupted, 2007-07-08), the variable preserve_merges (then called\nPRESERVE_MERGES) was detected from the state saved in\n$GIT_DIR/rebase-merge in order to be used when the rebase resumed, but\nits value was never actually used. The variable's value was only used\nwhen the rebase was initated.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    5 -----\n 1 files changed, 0 insertions(+), 5 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0763ef5..d20a9b2 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -583,7 +583,6 @@ skip_unnecessary_picks () {\n }\n \n get_saved_options () {\n-\ttest -d \"$REWRITTEN\" && preserve_merges=t\n \ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n@@ -650,8 +649,6 @@ rearrange_squash () {\n \n case \"$action\" in\n continue)\n-\tget_saved_options\n-\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet --ignore-submodules HEAD --\n \tthen\n@@ -682,8 +679,6 @@ first and then run 'git rebase --continue' again.\"\n \tdo_rest\n \t;;\n skip)\n-\tget_saved_options\n-\n \tgit rerere clear\n \n \tdo_rest\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158669","messageId":"1293528648-21873-32-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH 31/31] rebase -i: remove unnecessary state rebase-root","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T09:30:48Z","receivedAt":"2010-12-28T09:30:48Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Before calling 'git cherry-pick', interactive rebase currently checks\nif we are rebasing from root (if --root was passed). If we are, the\n'--ff' flag to 'git cherry-pick' is omitted. However, according to the\ndocumentation for 'git cherry-pick --ff', \"If the current HEAD is the\nsame as the parent of the cherry-picked commit, then a fast forward to\nthis commit will be performed.\". This should never be the case when\nrebasing from root, so it should not matter whether --ff is passed, so\nsimplify the code by removing the condition.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n\nWhile factoring out the state writing code a few patches back, I went\nthrough each of the pieces of state that was written. I was a bit\nhesitant to include this patch since I'm not quite sure why the code\nwas introduced, but I thought I would include it anyway to hear what\nyou have to say.\n\nThere used to be bug when using --ff when rebasing a root commit. This\nwas fixed in 6355e50 (builtin/revert.c: don't dereference a NULL\npointer, 2010-09-27). Could this have been the reason for the check?\nThomas, do you remember?\n\n git-rebase--interactive.sh |   15 ---------------\n 1 files changed, 0 insertions(+), 15 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex d20a9b2..a9f44d8 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -168,11 +168,6 @@ pick_one () {\n \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n \ttest -d \"$REWRITTEN\" &&\n \t\tpick_one_preserving_merges \"$@\" && return\n-\tif test -n \"$rebase_root\"\n-\tthen\n-\t\toutput git cherry-pick \"$@\"\n-\t\treturn\n-\tfi\n \toutput git cherry-pick $ff \"$@\"\n }\n \n@@ -582,10 +577,6 @@ skip_unnecessary_picks () {\n \tdie \"Could not skip unnecessary pick commands\"\n }\n \n-get_saved_options () {\n-\ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n-}\n-\n # Rearrange the todo list that has both \"pick sha1 msg\" and\n # \"pick sha1 fixup!/squash! msg\" appears in it so that the latter\n # comes immediately after the former, and change \"pick\" to\n@@ -701,12 +692,6 @@ mkdir \"$state_dir\" || die \"Could not create temporary $state_dir\"\n \n : > \"$state_dir\"/interactive || die \"Could not mark as interactive\"\n write_basic_state\n-case \"$rebase_root\" in\n-'')\n-\trm -f \"$state_dir\"/rebase-root ;;\n-*)\n-\t: >\"$state_dir\"/rebase-root ;;\n-esac\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\n-- \n1.7.3.2.864.gbbb96\n"},{"id":"158684","messageId":"alpine.DEB.1.10.1012281407360.788@debian","threadId":"26148","inReplyTo":"alpine.DEB.1.00.1012281858300.1794@bonsai2","subject":"Re: [PATCH 16/31] rebase -i: support --stat","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T13:24:52Z","receivedAt":"2010-12-28T13:24:52Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 28 Dec 2010, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Tue, 28 Dec 2010, Martin von Zweigbergk wrote:\n> \n> > diff --git a/git-rebase.sh b/git-rebase.sh\n> > index 229e8d2..0fc580a 100755\n> \n> Hmpf... After a rebasing merge to junio/next:\n> \n> -- snip --\n> [...]\n> Applying: rebase -i: support --stat\n> fatal: sha1 information is lacking or useless (git-rebase.sh).\n> Repository lacks necessary blobs to fall back on 3-way merge.\n> Cannot fall back to three-way merge.\n> [...]\n> -- snap --\n> \n> Is this supposed to apply on top of junio/master, junio/next, junio/maint?\n\nIt is supposed to apply on top of junio/master. I tried exporting the\nrecevied emails using Alpine. This is the first time I do this, but I\nmanaged to export them to one big file. I then applied it using 'git\nam' onto a new branch created from junio/master and it was\nsuccessful. I'm very surprised that patch 16 failed for you if the\nfirst 15 patches applied correctly.\n\nI'm not sure what to use the hashes in the beginning of your mail for,\nbut I have verified that they match the hashes of git-rebase.sh before\nand after patch 16 (in both my original branch and in the temporary\nbranch where I ran 'git am' on my own emails).\n\n\nRegards,\nMartin\n"},{"id":"158673","messageId":"201012281740.52374.trast@student.ethz.ch","threadId":"26148","inReplyTo":"1293528648-21873-32-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 31/31] rebase -i: remove unnecessary state rebase-root","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-12-28T16:40:52Z","receivedAt":"2010-12-28T16:40:52Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Martin von Zweigbergk wrote:\n> @@ -168,11 +168,6 @@ pick_one () {\n>  \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n>  \ttest -d \"$REWRITTEN\" &&\n>  \t\tpick_one_preserving_merges \"$@\" && return\n> -\tif test -n \"$rebase_root\"\n> -\tthen\n> -\t\toutput git cherry-pick \"$@\"\n> -\t\treturn\n> -\tfi\n>  \toutput git cherry-pick $ff \"$@\"\n>  }\n[...]\n> While factoring out the state writing code a few patches back, I went\n> through each of the pieces of state that was written. I was a bit\n> hesitant to include this patch since I'm not quite sure why the code\n> was introduced, but I thought I would include it anyway to hear what\n> you have to say.\n> \n> There used to be bug when using --ff when rebasing a root commit. This\n> was fixed in 6355e50 (builtin/revert.c: don't dereference a NULL\n> pointer, 2010-09-27). Could this have been the reason for the check?\n> Thomas, do you remember?\n\nI think this just ended up being such a strange test because of the\nfollowing hunk in 8e75abf (rebase -i: use new --ff cherry-pick option,\n2010-03-06):\n\n@@ -232,16 +232,7 @@ pick_one () {\n                output git cherry-pick \"$@\"\n                return\n        fi\n-       parent_sha1=$(git rev-parse --verify $sha1^) ||\n-               die \"Could not get the parent of $sha1\"\n-       current_sha1=$(git rev-parse --verify HEAD)\n-       if test -z \"$no_ff\" && test \"$current_sha1\" = \"$parent_sha1\"\n-       then\n-               output git reset --hard $sha1\n-               output warn Fast-forward to $(git rev-parse --short $sha1)\n-       else\n-               output git cherry-pick \"$@\"\n-       fi\n+       output git cherry-pick $ff \"$@\"\n }\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158680","messageId":"alpine.DEB.1.00.1012281858300.1794@bonsai2","threadId":"26148","inReplyTo":"1293528648-21873-17-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 16/31] rebase -i: support --stat","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-12-28T17:59:46Z","receivedAt":"2010-12-28T17:59:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 28 Dec 2010, Martin von Zweigbergk wrote:\n\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index 229e8d2..0fc580a 100755\n\nHmpf... After a rebasing merge to junio/next:\n\n-- snip --\n[...]\nApplying: rebase -i: support --stat\nfatal: sha1 information is lacking or useless (git-rebase.sh).\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\n[...]\n-- snap --\n\nIs this supposed to apply on top of junio/master, junio/next, junio/maint?\n\nCiao,\nDscho\n"},{"id":"158700","messageId":"alpine.DEB.1.10.1012282104320.29381@debian","threadId":"26148","inReplyTo":"7vaajpv6lh.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 05/31] rebase: improve detection of rebase in progress","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T20:35:34Z","receivedAt":"2010-12-28T20:35:34Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"\nOn Tue, 28 Dec 2010, Junio C Hamano wrote:\n\n> Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n> \n> > Currently, the existence of rebase-merge/ is tested with 'test -d',\n> > while the existence of rebase-apply/ is tested by creating the\n> > directory and then deleting it again. Any good reason for this?\n> \n> I don't recall how the merge side reached the current shape of the code,\n> but I think the rebase-apply one was that we wanted to make sure not only\n> we don't have a directory but also we actually _can_ create one.  If\n> somebody had a bad permission set, \"test -d\" wouldn't help us much.  We\n> would fail later and error diagnosis codepath should do the right thing\n> anyway, so it is not a correctness issue, but is more about attempting to\n> notice an error early rather than late.\n\nYeah, I was wondering if that might have been the reason. Why would\nanyone set such permissions on .git (keep in mind that I am no\nLinux/Unix expert)?\n\nI saw that the code was introduced [1] when the directory was called\n.dotest and I believe this directory was created at the top level\n(i.e. a sibling to .git). Could it be that it was reasonable for the\nuser to set such permissions back then (on the top level dir), but not\nany longer (on the .git dir)?\n\n\nEither way, if it is good to have the that check for rebase-apply/,\nwouldn't it be good to have for rebase-merge/ as well?\n\n/Martin\n\n\n[1] 7f4bd5d (rebase: one safety net, one bugfix and one optimization.,\n2005-11-28)\n"},{"id":"158701","messageId":"alpine.DEB.1.10.1012282137580.29381@debian","threadId":"26148","inReplyTo":"7vtyhxts0a.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 01/31] rebase: clearer names for directory variables","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-28T20:53:46Z","receivedAt":"2010-12-28T20:53:46Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"\nOn Tue, 28 Dec 2010, Junio C Hamano wrote:\n\n> If this were just \"s/dotest/merge_dir/g\" and the same for rebase-apply, I\n> would have to say it is long overdue ;-)\n\n\nYes, that should be all!\n\nWell, to be precise, in the \"@@ -560,35 +561,35 @@ then\" hunk, I also\nmoved the quotes to contain the file name as was done for\nrebase-merge. I redid the search/replace just to double check.\n"},{"id":"158692","messageId":"7vaajpv6lh.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"1293528648-21873-6-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 05/31] rebase: improve detection of rebase in progress","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-28T23:08:10Z","receivedAt":"2010-12-28T23:08:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n\n> Currently, the existence of rebase-merge/ is tested with 'test -d',\n> while the existence of rebase-apply/ is tested by creating the\n> directory and then deleting it again. Any good reason for this?\n\nI don't recall how the merge side reached the current shape of the code,\nbut I think the rebase-apply one was that we wanted to make sure not only\nwe don't have a directory but also we actually _can_ create one.  If\nsomebody had a bad permission set, \"test -d\" wouldn't help us much.  We\nwould fail later and error diagnosis codepath should do the right thing\nanyway, so it is not a correctness issue, but is more about attempting to\nnotice an error early rather than late.\n"},{"id":"158693","messageId":"7v1v51v6l2.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"1293528648-21873-3-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 02/31] rebase: refactor reading of state","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-28T23:08:25Z","receivedAt":"2010-12-28T23:08:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n\n> +read_state () {\n> +\tif test -d \"$merge_dir\"\n> +\tthen\n> +\t\tstate_dir=\"$merge_dir\"\n> +\t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n> +\t\tend=$(cat \"$merge_dir\"/end) &&\n> +\t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n> +\telse\n> +\t\tstate_dir=\"$apply_dir\"\n> +\tfi &&\n> +\thead_name=$(cat \"$state_dir\"/head-name) &&\n> +\tonto=$(cat \"$state_dir\"/onto) &&\n> +\torig_head=$(cat \"$state_dir\"/orig-head) &&\n> +\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n> +}\n> +\n>  continue_merge () {\n>  \ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n>  \ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n> @@ -138,10 +154,6 @@ call_merge () {\n>  }\n>  \n>  move_to_original_branch () {\n> -\ttest -z \"$head_name\" &&\n> -\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n> -\t\tonto=\"$(cat \"$merge_dir\"/onto)\" &&\n> -\t\torig_head=\"$(cat \"$merge_dir\"/orig-head)\"\n\nIt used to be safe to call this without head_name and friends set, because\nthe function took care of reading these itself.  Nobody calls this without\nhead_name set anymore?\n\nI am not complaining nor suggesting to add an unnecessary \"read_state\"\nhere only to slow things down---I am making sure that you removed this\nbecause you know it is unnecessary.\n\n> @@ -220,13 +232,9 @@ do\n>  \t\t\techo \"mark them as resolved using git add\"\n>  \t\t\texit 1\n>  \t\t}\n> +\t\tread_state\n>  \t\tif test -d \"$merge_dir\"\n>  \t\tthen\n> -\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n> -\t\t\tend=$(cat \"$merge_dir/end\")\n> -\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n> -\t\t\tonto=$(cat \"$merge_dir/onto\")\n> -\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n\nEven though this patch may make the code shorter, it starts to read\nhead_name and orig_head that we previously did not open and change the\nvalues of variables with what are read from them.  Does this change affect\nthe behaviour in any way (either in performance or in correctness)?\n\n> @@ -236,10 +244,6 @@ do\n>  \t\t\tfinish_rb_merge\n>  \t\t\texit\n>  \t\tfi\n> -\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n> -\t\tonto=$(cat \"$apply_dir\"/onto) &&\n> -\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n> -\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n>  \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n>  \t\tmove_to_original_branch\n\nEarlier move-to-original-branch was Ok to be called without head_name, and\nthe old code here read from the file anyway, so it didn't matter, but now\nit seems that the first check and assignment you removed from the function\nmay matter because this caller does not even read from head_name.  Are you\nsure about this change?\n\n> @@ -279,18 +275,15 @@ do\n>  \t\t\tdie \"No rebase in progress?\"\n>  \n>  \t\tgit rerere clear\n> -\n> -\t\ttest -d \"$merge_dir\" || merge_dir=\"$apply_dir\"\n\nMy heartbeat skipped when I first saw this.  Thanks to the previous\ncommit, it was exposed that somebody reused $dotest that was only to be\nused when using merge machinery because the things left to be done in this\ncodepath are common between the merge and apply, which is kind of sloppy,\nbut that sloppiness is now gone ;-).\n\nAre there places that read from individual files for states left after\nthis patch, or read_state is the only interface to get to the states?  If\nthe latter that would be a great news, and also would suggest that we may\nwant to have a corresponding write_state function (and we may even want to\nmake the state into a single file to reduce I/O---but that is a separate\nissue that can be done at the very end of the series if it turns out to be\nbeneficial).\n\nOf course it is fine if introduction of read_state is an attempt to catch\nmost common cases, but it would reduce chances of mistake if the coverage\nwere 100% (as opposed to 99.9%) hence this question.\n"},{"id":"158694","messageId":"7vtyhxts0a.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"1293528648-21873-2-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 01/31] rebase: clearer names for directory variables","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-28T23:08:37Z","receivedAt":"2010-12-28T23:08:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"If this were just \"s/dotest/merge_dir/g\" and the same for rebase-apply, I\nwould have to say it is long overdue ;-)\n\nI read the patch and didn't spot any glaring mistake, but I wasn't being\nas careful as I usually am.\n\nThanks.\n"},{"id":"158695","messageId":"7vpqsltqpd.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"alpine.DEB.1.00.1012281858300.1794@bonsai2","subject":"Re: [PATCH 16/31] rebase -i: support --stat","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-12-28T23:36:46Z","receivedAt":"2010-12-28T23:36:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Tue, 28 Dec 2010, Martin von Zweigbergk wrote:\n>\n>> diff --git a/git-rebase.sh b/git-rebase.sh\n>> index 229e8d2..0fc580a 100755\n>\n> Hmpf... After a rebasing merge to junio/next:\n\nThe series applied cleanly near the tip of my 'master'.  I've been\npreparing to push out 1.7.4-rc0 so the commit I applied the series was\nprobably a few commits ahead of the public 'master', but I don't think\nthere is anything that may conflict with or may be required for this\nseries to make any difference.\n\nPlease check tonight's 'pu' where the series is parked.\n\nThanks.\n"},{"id":"158696","messageId":"alpine.DEB.1.00.1012290040200.1794@bonsai2","threadId":"26148","inReplyTo":"7vpqsltqpd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 16/31] rebase -i: support --stat","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-12-28T23:44:03Z","receivedAt":"2010-12-28T23:44:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 28 Dec 2010, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Tue, 28 Dec 2010, Martin von Zweigbergk wrote:\n> >\n> >> diff --git a/git-rebase.sh b/git-rebase.sh\n> >> index 229e8d2..0fc580a 100755\n> >\n> > Hmpf... After a rebasing merge to junio/next:\n> \n> The series applied cleanly near the tip of my 'master'.\n\nSorry, I should have been more specific. I updated to current 'next' \n(a2bc419) of git://repo.or.cz/git.git/.\n\n> Please check tonight's 'pu' where the series is parked.\n\nThanks, but unfortunately I have to tend to other things now.\n\nCiao,\nJohannes\n"},{"id":"158710","messageId":"alpine.DEB.1.10.1012290550080.29381@debian","threadId":"26148","inReplyTo":"7v1v51v6l2.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 02/31] rebase: refactor reading of state","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-29T08:09:37Z","receivedAt":"2010-12-29T08:09:37Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 28 Dec 2010, Junio C Hamano wrote:\n\n> Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n> \n> > +read_state () {\n> > +\tif test -d \"$merge_dir\"\n> > +\tthen\n> > +\t\tstate_dir=\"$merge_dir\"\n> > +\t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n> > +\t\tend=$(cat \"$merge_dir\"/end) &&\n> > +\t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n> > +\telse\n> > +\t\tstate_dir=\"$apply_dir\"\n> > +\tfi &&\n> > +\thead_name=$(cat \"$state_dir\"/head-name) &&\n> > +\tonto=$(cat \"$state_dir\"/onto) &&\n> > +\torig_head=$(cat \"$state_dir\"/orig-head) &&\n> > +\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n> > +}\n> > +\n> >  continue_merge () {\n> >  \ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n> >  \ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n> > @@ -138,10 +154,6 @@ call_merge () {\n> >  }\n> >  \n> >  move_to_original_branch () {\n> > -\ttest -z \"$head_name\" &&\n> > -\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n> > -\t\tonto=\"$(cat \"$merge_dir\"/onto)\" &&\n> > -\t\torig_head=\"$(cat \"$merge_dir\"/orig-head)\"\n> \n> It used to be safe to call this without head_name and friends set, because\n> the function took care of reading these itself.  Nobody calls this without\n> head_name set anymore?\n> \n> I am not complaining nor suggesting to add an unnecessary \"read_state\"\n> here only to slow things down---I am making sure that you removed this\n> because you know it is unnecessary.\n\nCorrect. It used to be called without head_name set from\nfinish_rb_merge, which would in turn be called from the --continue and\n--skip arms. onto would already have been set in these cases, but\nwould then be re-read.\n\n> > @@ -220,13 +232,9 @@ do\n> >  \t\t\techo \"mark them as resolved using git add\"\n> >  \t\t\texit 1\n> >  \t\t}\n> > +\t\tread_state\n> >  \t\tif test -d \"$merge_dir\"\n> >  \t\tthen\n> > -\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n> > -\t\t\tend=$(cat \"$merge_dir/end\")\n> > -\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n> > -\t\t\tonto=$(cat \"$merge_dir/onto\")\n> > -\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n> \n> Even though this patch may make the code shorter, it starts to read\n> head_name and orig_head that we previously did not open and change the\n> values of variables with what are read from them.  Does this change affect\n> the behaviour in any way (either in performance or in correctness)?\n\nTrue. Previously, head_name and orig_head were lazily read only when\nthe rebase had been finished (in the finish_rb_merge, as I mentioned\nabove). Now these values are read unnecessarily when the rebase is\nresumed, but a later patch fails. The am-based rebase is not affacted\nby this patch as it already read head_name and orig_head eagerly.\n\nGood point about the correctness. I looked into the correctness issue\narising if a file could not be found and I think I concluded that all\nof the files would always be written (do we need to care about the\ncase where a user deletes e.g. .git/rebase-apply/onto?). However, I\ndid not think about the possibility of overwriting variables. It seems\nfine, though, as neither continue_merge nor call_merge uses either of\nthese variables.\n\nRegarding performance, I would say there is definitely a cost\nassociated with this patch. How big this cost is, though, I don't dare\nto speculate. I will leave that up to the rest of you.\n\nIt should be noted that read_state is only called when a rebase is\nresumed with --continue or --skip, or when it is aborted. There are no\nchanges to the code in the call_merge-continue_merge loop.\n\nThe performance hit is probably biggest in the --abort case, which\npreviously only read head_name and orig_head. It now ends up reading\n_at least_ two more values.\n\n> \n> > @@ -236,10 +244,6 @@ do\n> >  \t\t\tfinish_rb_merge\n> >  \t\t\texit\n> >  \t\tfi\n> > -\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n> > -\t\tonto=$(cat \"$apply_dir\"/onto) &&\n> > -\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n> > -\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n> >  \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n> >  \t\tmove_to_original_branch\n> \n> Earlier move-to-original-branch was Ok to be called without head_name, and\n> the old code here read from the file anyway, so it didn't matter, but now\n> it seems that the first check and assignment you removed from the function\n> may matter because this caller does not even read from head_name.  Are you\n> sure about this change?\n\nIf I understand your question correctly, then yes, it is ok, because\nof the previous hunk that calls read_state. That call is made\nbefore/outside the if block for merge-based rebase, so the variables\nare already set when this code is reached.\n \n> > @@ -279,18 +275,15 @@ do\n> >  \t\t\tdie \"No rebase in progress?\"\n> >  \n> >  \t\tgit rerere clear\n> > -\n> > -\t\ttest -d \"$merge_dir\" || merge_dir=\"$apply_dir\"\n> \n> My heartbeat skipped when I first saw this.  Thanks to the previous\n> commit, it was exposed that somebody reused $dotest that was only to be\n> used when using merge machinery because the things left to be done in this\n> codepath are common between the merge and apply, which is kind of sloppy,\n> but that sloppiness is now gone ;-).\n> \n> Are there places that read from individual files for states left after\n> this patch, or read_state is the only interface to get to the states?  If\n> the latter that would be a great news, and also would suggest that we may\n> want to have a corresponding write_state function (and we may even want to\n> make the state into a single file to reduce I/O---but that is a separate\n> issue that can be done at the very end of the series if it turns out to be\n> beneficial).\n\nThere are still a few other places where state is read, mainly in\ncall_merge. It reads things that vary from iteration to iteration,\nsuch as a counter. I forgot to say in the commit message, but I tried\nto extract only the code that reads the initial state.\n\nThe write_state function actually is there, but it comes pretty late,\nin patch 24. I don't remember why I added it so much later. I could\npossibly move it closer to the beginning of this series.\n \n> Of course it is fine if introduction of read_state is an attempt to catch\n> most common cases, but it would reduce chances of mistake if the coverage\n> were 100% (as opposed to 99.9%) hence this question.\n\nDo you mean if all the state was read in the read_state function? I\nshould say that the pieces of state that are read in read_state are\nnot read anywhere else. But overall, the coverage is more like 60% or\nso.\n\n\nThanks for a thorough review. Many of these things should have been in\nthe commit message. I need to get better at writing those...\n\n\nThanks,\nMartin\n"},{"id":"158729","messageId":"201012292231.33333.j6t@kdbg.org","threadId":"26148","inReplyTo":"1293528648-21873-19-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 18/31] rebase: extract merge code to new source file","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2010-12-29T21:31:32Z","receivedAt":"2010-12-29T21:31:32Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Dienstag, 28. Dezember 2010, Martin von Zweigbergk wrote:\n> -run_interactive_rebase () {\n> +run_specific_rebase () {\n>  \tif [ \"$interactive_rebase\" = implied ]; then\n>  \t\tGIT_EDITOR=:\n>  \t\texport GIT_EDITOR\n>  \tfi\n>  \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n> -\tforce_rebase action preserve_merges upstream switch_to head_name\n> -\texec git-rebase--interactive\n> +\tforce_rebase action preserve_merges upstream switch_to head_name \\\n> +\tstate_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \\\n> +\tallow_rerere_autoupdate\n> +\texport -f move_to_original_branch\n\nIs export -f portable?\n\n> +\ttest \"$type\" != am && exec git-rebase--$type\n\nI'd prefer to dispatch to the final rebase type using\n\n\t. git-rebase--$type\n\nThis way, you can avoid to export the huge list of helper variables and the \nfunction. (And it might be faster by a millisecond - or a few dozens on \nWindows.)\n\n-- Hannes\n"},{"id":"158745","messageId":"alpine.DEB.1.10.1012292315070.7175@debian","threadId":"26148","inReplyTo":"201012292231.33333.j6t@kdbg.org","subject":"Re: [PATCH 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-29T22:24:53Z","receivedAt":"2010-12-29T22:24:53Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Wed, 29 Dec 2010, Johannes Sixt wrote:\n\n> On Dienstag, 28. Dezember 2010, Martin von Zweigbergk wrote:\n> > -run_interactive_rebase () {\n> > +run_specific_rebase () {\n> >  \tif [ \"$interactive_rebase\" = implied ]; then\n> >  \t\tGIT_EDITOR=:\n> >  \t\texport GIT_EDITOR\n> >  \tfi\n> >  \texport onto autosquash strategy strategy_opts verbose rebase_root \\\n> > -\tforce_rebase action preserve_merges upstream switch_to head_name\n> > -\texec git-rebase--interactive\n> > +\tforce_rebase action preserve_merges upstream switch_to head_name \\\n> > +\tstate_dir orig_head onto_name GIT_QUIET revisions RESOLVEMSG \\\n> > +\tallow_rerere_autoupdate\n> > +\texport -f move_to_original_branch\n> \n> Is export -f portable?\n\nIt seems like it isn't. What is a good way to check?\n \n> > +\ttest \"$type\" != am && exec git-rebase--$type\n> \n> I'd prefer to dispatch to the final rebase type using\n> \n> \t. git-rebase--$type\n> \n> This way, you can avoid to export the huge list of helper variables and the \n> function. (And it might be faster by a millisecond - or a few dozens on \n> Windows.)\n\nMakes a lot of sense. Will change. Why didn't I do that from the\nbeginning?\n\n\nThanks,\nMartin\n"},{"id":"158746","messageId":"alpine.DEB.1.10.1012292325220.7175@debian","threadId":"26148","inReplyTo":"201012281740.52374.trast@student.ethz.ch","subject":"Re: [PATCH 31/31] rebase -i: remove unnecessary state rebase-root","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-29T22:31:37Z","receivedAt":"2010-12-29T22:31:37Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 28 Dec 2010, Thomas Rast wrote:\n\n> Martin von Zweigbergk wrote:\n> > @@ -168,11 +168,6 @@ pick_one () {\n> >  \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n> >  \ttest -d \"$REWRITTEN\" &&\n> >  \t\tpick_one_preserving_merges \"$@\" && return\n> > -\tif test -n \"$rebase_root\"\n> > -\tthen\n> > -\t\toutput git cherry-pick \"$@\"\n> > -\t\treturn\n> > -\tfi\n> >  \toutput git cherry-pick $ff \"$@\"\n> >  }\n> [...]\n> > While factoring out the state writing code a few patches back, I went\n> > through each of the pieces of state that was written. I was a bit\n> > hesitant to include this patch since I'm not quite sure why the code\n> > was introduced, but I thought I would include it anyway to hear what\n> > you have to say.\n> > \n> > There used to be bug when using --ff when rebasing a root commit. This\n> > was fixed in 6355e50 (builtin/revert.c: don't dereference a NULL\n> > pointer, 2010-09-27). Could this have been the reason for the check?\n> > Thomas, do you remember?\n> \n> I think this just ended up being such a strange test because of the\n> following hunk in 8e75abf (rebase -i: use new --ff cherry-pick option,\n> 2010-03-06):\n> \n> @@ -232,16 +232,7 @@ pick_one () {\n>                 output git cherry-pick \"$@\"\n>                 return\n>         fi\n> -       parent_sha1=$(git rev-parse --verify $sha1^) ||\n> -               die \"Could not get the parent of $sha1\"\n> -       current_sha1=$(git rev-parse --verify HEAD)\n> -       if test -z \"$no_ff\" && test \"$current_sha1\" = \"$parent_sha1\"\n> -       then\n> -               output git reset --hard $sha1\n> -               output warn Fast-forward to $(git rev-parse --short $sha1)\n> -       else\n> -               output git cherry-pick \"$@\"\n> -       fi\n> +       output git cherry-pick $ff \"$@\"\n>  }\n> -- \n\nYes, I saw that one as well, so it would probably have made more sense\nto ask Christian instead (the author of 8e75abf). So do you remember,\nChristian?\n\nAnyway, thanks for your input, Thomas. That makes me feel a little\nless worried about this patch.\n\n\n/Martin\n"},{"id":"158777","messageId":"AANLkTikeUg-9Qik=Xuxo-dM08dg9=aa-mP7aJn8Yknht@mail.gmail.com","threadId":"26148","inReplyTo":"alpine.DEB.1.10.1012292325220.7175@debian","subject":"Re: [PATCH 31/31] rebase -i: remove unnecessary state rebase-root","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2010-12-31T05:41:46Z","receivedAt":"2010-12-31T05:41:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Wed, Dec 29, 2010 at 11:31 PM, Martin von Zweigbergk\n<martin.von.zweigbergk@gmail.com> wrote:\n> On Tue, 28 Dec 2010, Thomas Rast wrote:\n>\n>> Martin von Zweigbergk wrote:\n>> > @@ -168,11 +168,6 @@ pick_one () {\n>> >     output git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n>> >     test -d \"$REWRITTEN\" &&\n>> >             pick_one_preserving_merges \"$@\" && return\n>> > -   if test -n \"$rebase_root\"\n>> > -   then\n>> > -           output git cherry-pick \"$@\"\n>> > -           return\n>> > -   fi\n>> >     output git cherry-pick $ff \"$@\"\n>> >  }\n>> [...]\n>> > While factoring out the state writing code a few patches back, I went\n>> > through each of the pieces of state that was written. I was a bit\n>> > hesitant to include this patch since I'm not quite sure why the code\n>> > was introduced, but I thought I would include it anyway to hear what\n>> > you have to say.\n>> >\n>> > There used to be bug when using --ff when rebasing a root commit. This\n>> > was fixed in 6355e50 (builtin/revert.c: don't dereference a NULL\n>> > pointer, 2010-09-27). Could this have been the reason for the check?\n>> > Thomas, do you remember?\n>>\n>> I think this just ended up being such a strange test because of the\n>> following hunk in 8e75abf (rebase -i: use new --ff cherry-pick option,\n>> 2010-03-06):\n>>\n>> @@ -232,16 +232,7 @@ pick_one () {\n>>                 output git cherry-pick \"$@\"\n>>                 return\n>>         fi\n>> -       parent_sha1=$(git rev-parse --verify $sha1^) ||\n>> -               die \"Could not get the parent of $sha1\"\n>> -       current_sha1=$(git rev-parse --verify HEAD)\n>> -       if test -z \"$no_ff\" && test \"$current_sha1\" = \"$parent_sha1\"\n>> -       then\n>> -               output git reset --hard $sha1\n>> -               output warn Fast-forward to $(git rev-parse --short $sha1)\n>> -       else\n>> -               output git cherry-pick \"$@\"\n>> -       fi\n>> +       output git cherry-pick $ff \"$@\"\n>>  }\n>> --\n>\n> Yes, I saw that one as well, so it would probably have made more sense\n> to ask Christian instead (the author of 8e75abf). So do you remember,\n> Christian?\n\nYeah, I must say that I did not try to understand why there was a\nspecial case for $rebase_root above the code I was changing.\nPerhaps I should have, and I would probably have sent a patch like yours...\n\n> Anyway, thanks for your input, Thomas. That makes me feel a little\n> less worried about this patch.\n\nYeah I think it's a good one.\n\nThanks,\nChristian.\n"},{"id":"158778","messageId":"201012311323.47102.trast@student.ethz.ch","threadId":"26148","inReplyTo":"alpine.DEB.1.10.1012292315070.7175@debian","subject":"Re: [PATCH 18/31] rebase: extract merge code to new source file","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-12-31T12:23:46Z","receivedAt":"2010-12-31T12:23:46Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Martin von Zweigbergk wrote:\n> On Wed, 29 Dec 2010, Johannes Sixt wrote:\n> > \n> > Is export -f portable?\n> \n> It seems like it isn't. What is a good way to check?\n\nOn my system I have POSIX docs for various commands, coming from the\n'man-pages-posix' package.  Maybe your distribution has those too?\nThen you can simply run 'man 1p export' for the documentation.\nAnything that is documented there should be safe (except on Windows\nmaybe).\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158780","messageId":"alpine.DEB.1.10.1012310841340.16976@debian","threadId":"26148","inReplyTo":"201012311323.47102.trast@student.ethz.ch","subject":"Re: [PATCH 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2010-12-31T14:05:01Z","receivedAt":"2010-12-31T14:05:01Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Fri, 31 Dec 2010, Thomas Rast wrote:\n\n> Martin von Zweigbergk wrote:\n> > On Wed, 29 Dec 2010, Johannes Sixt wrote:\n> > > \n> > > Is export -f portable?\n> > \n> > It seems like it isn't. What is a good way to check?\n> \n> On my system I have POSIX docs for various commands, coming from the\n> 'man-pages-posix' package.  Maybe your distribution has those too?\n> Then you can simply run 'man 1p export' for the documentation.\n> Anything that is documented there should be safe (except on Windows\n> maybe).\n\nThanks. I'm running Debian and I just installed the package from\nnon-free. Thanks for the hint on the '1p' syntax as well.\n\n\n/Martin\n"},{"id":"158902","messageId":"201101042012.25580.trast@student.ethz.ch","threadId":"26148","inReplyTo":"1293528648-21873-9-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 08/31] rebase: align variable names","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-01-04T19:12:25Z","receivedAt":"2011-01-04T19:12:25Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Martin von Zweigbergk wrote:\n> Use the same names for variables that git-rebase--interactive.sh will\n> soon inherit from git-rebase.sh.\n\nAFAICS this is partly about spelling the variables in lowercase\ninstead of all-caps.\n\nWouldn't it be nicer to simply downcase *all* variables, so that the\nend result has a consistent coding style?\n\n> -# $UPSTREAM. They are not necessarily rewritten, but their children\n> +# $upstream. They are not necessarily rewritten, but their children\n[...]\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158907","messageId":"201101042019.24223.trast@student.ethz.ch","threadId":"26148","inReplyTo":"1293528648-21873-25-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 24/31] rebase: extract code for writing basic state","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-01-04T19:19:24Z","receivedAt":"2011-01-04T19:19:24Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Martin von Zweigbergk wrote:\n> Note that non-interactive rebase stores the sha1 of the original head\n> in a file called orig-head, while interactive rebase stores it in a\n> file called head.\n[...]\n> +\tif test \"$type\" = interactive\n> +\tthen\n> +\t\techo \"$orig_head\" > \"$state_dir\"/head\n> +\telse\n> +\t\techo \"$orig_head\" > \"$state_dir\"/orig-head\n> +\tfi &&\n\nDo we have to cater to the use-case where the user starts a rebase,\ndowngrades at a conflict, and then continues?\n\nIf not, you could read 'orig-head' first and fall back to 'head', only\nwriting 'orig-head' in the state saving independent of the mode.  That\nwould give us the chance of removing the redundancy at some point.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158910","messageId":"201101042027.26737.trast@student.ethz.ch","threadId":"26148","inReplyTo":"1293528648-21873-27-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 26/31] rebase: remember strategy and strategy options","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-01-04T19:27:26Z","receivedAt":"2011-01-04T19:27:26Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Martin von Zweigbergk wrote:\n> How to add support for strategy options to interactive rebase?\n\nAFAICS rebase -i currently only uses the strategy when dealing with\nmultiple parents, i.e., in --preserve-merges mode.  I think\ngit-cherry-pick needs to learn about the -s and -X options, and then\nit'll be a simple matter of passing them along.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158912","messageId":"201101042057.29809.trast@student.ethz.ch","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH 00/31] Refactor rebase","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-01-04T19:57:29Z","receivedAt":"2011-01-04T19:57:29Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Martin von Zweigbergk wrote:\n> For the past two months, I have been working on refactoring the rebase\n> code. See [1] for background information. I have been trying to polish\n> the patch set for some time, but now I don't think I will get much\n> further without your help.\n\nThanks a lot for undertaking this effort!  I just finished looking\nthrough the entire series, and it all seems sane to me.  Apart from\nj6t's reply I think we're mostly nit-picking or agreeing with you, and\nthis is the first iteration!\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"158937","messageId":"alpine.DEB.1.10.1101042112190.6201@debian","threadId":"26148","inReplyTo":"201101042012.25580.trast@student.ethz.ch","subject":"Re: [PATCH 08/31] rebase: align variable names","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-01-05T02:25:46Z","receivedAt":"2011-01-05T02:25:46Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 4 Jan 2011, Thomas Rast wrote:\n\n> Martin von Zweigbergk wrote:\n> > Use the same names for variables that git-rebase--interactive.sh will\n> > soon inherit from git-rebase.sh.\n> \n> AFAICS this is partly about spelling the variables in lowercase\n> instead of all-caps.\n> \n> Wouldn't it be nicer to simply downcase *all* variables, so that the\n> end result has a consistent coding style?\n\nYes, it would :-). I was just being conservative by trying not to\ntouch code that I didn't have to touch. I'll rename the remaining\nvariables in the next iteration.\n\nThanks,\nMartin\n"},{"id":"158938","messageId":"alpine.DEB.1.10.1101042134180.11516@debian","threadId":"26148","inReplyTo":"201101042019.24223.trast@student.ethz.ch","subject":"Re: [PATCH 24/31] rebase: extract code for writing basic state","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-01-05T02:40:22Z","receivedAt":"2011-01-05T02:40:22Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 4 Jan 2011, Thomas Rast wrote:\n\n> Martin von Zweigbergk wrote:\n> > Note that non-interactive rebase stores the sha1 of the original head\n> > in a file called orig-head, while interactive rebase stores it in a\n> > file called head.\n> [...]\n> > +\tif test \"$type\" = interactive\n> > +\tthen\n> > +\t\techo \"$orig_head\" > \"$state_dir\"/head\n> > +\telse\n> > +\t\techo \"$orig_head\" > \"$state_dir\"/orig-head\n> > +\tfi &&\n> \n> Do we have to cater to the use-case where the user starts a rebase,\n> downgrades at a conflict, and then continues?\n\nI'll let Junio answer that.\n \n> If not, you could read 'orig-head' first and fall back to 'head', only\n> writing 'orig-head' in the state saving independent of the mode.  That\n> would give us the chance of removing the redundancy at some point.\n\nMakes sense. Given that the answer to the previous question is a \"no\",\nI'll change this as well in the next iteration.\n\n\n/Martin\n"},{"id":"158939","messageId":"alpine.DEB.1.10.1101042140500.11516@debian","threadId":"26148","inReplyTo":"201101042027.26737.trast@student.ethz.ch","subject":"Re: [PATCH 26/31] rebase: remember strategy and strategy options","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-01-05T03:33:47Z","receivedAt":"2011-01-05T03:33:47Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 4 Jan 2011, Thomas Rast wrote:\n\n> Martin von Zweigbergk wrote:\n> > How to add support for strategy options to interactive rebase?\n> \n> AFAICS rebase -i currently only uses the strategy when dealing with\n> multiple parents, i.e., in --preserve-merges mode.  I think\n> git-cherry-pick needs to learn about the -s and -X options, and then\n> it'll be a simple matter of passing them along.\n\nI just saw that Jonathan has actually implemented that support in\ngit-cherry-pick. It is currently in pu.\n\nI asked just because the merge strategy is currently passed to the\ncall to 'git merge' in git-rebase--interactive.sh (when dealing with\nmultiple parents, as you said), so it seems like it would make sense\nto pass any merge options there as well.\n\nCome to think of it, doesn't the merge option when passed to 'git\nrebase -i' mean something quite different compared to when it is\npassed to 'git rebase -m'? For interactive rebase, the 'ours' side\nrefers to the upstream, but in the case of merge-based rebase, it\nrefers to one branch in the branch-to-be-rebased, no? In that case,\nshould the merge strategy even be passed to 'git merge' when dealing\nwith multiple parents? Is it likely that one would want to use the\nsame strategy for both things? Am I just not thinking straight?\n\nSome history:\n\nThe command line option '-s' was there from the inception of\ninteractive rebase in 1b1dce4 (Teach rebase an interactive mode,\n2007-06-25) and back then it was passed to git-cherry-pick, which just\nignored it.\n\nSince f09c9b8 (Teach rebase -i about --preserve-merges, 2007-06-25),\nthe strategy has been passed to git-merge as well.\n\nSince 2a9c53e (git-rebase--interactive.sh: Don't pass a strategy to\ngit-cherry-pick., 2007-10-31), the strategy has only been passed to\ngit-merge, because it was ignored by git-cherry-pick.\n\n\nAnyway, I'll leave any changes related to this outside of the current\nseries.\n\n\n/Martin\n"},{"id":"158940","messageId":"alpine.DEB.1.10.1101042234450.11516@debian","threadId":"26148","inReplyTo":"201101042057.29809.trast@student.ethz.ch","subject":"Re: [PATCH 00/31] Refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-01-05T03:39:17Z","receivedAt":"2011-01-05T03:39:17Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 4 Jan 2011, Thomas Rast wrote:\n\n> Martin von Zweigbergk wrote:\n> > For the past two months, I have been working on refactoring the rebase\n> > code. See [1] for background information. I have been trying to polish\n> > the patch set for some time, but now I don't think I will get much\n> > further without your help.\n> \n> Thanks a lot for undertaking this effort!  I just finished looking\n> through the entire series, and it all seems sane to me.  Apart from\n> j6t's reply I think we're mostly nit-picking or agreeing with you, and\n> this is the first iteration!\n\nThanks. And thanks a lot for taking the time to review it!\n\n\n/Martin\n"},{"id":"159402","messageId":"alpine.DEB.1.10.1101120511330.856@debian","threadId":"26148","inReplyTo":"alpine.DEB.1.10.1012282104320.29381@debian","subject":"Re: [PATCH 05/31] rebase: improve detection of rebase in progress","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-01-12T10:20:54Z","receivedAt":"2011-01-12T10:20:54Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 28 Dec 2010, Martin von Zweigbergk wrote:\n\n> \n> On Tue, 28 Dec 2010, Junio C Hamano wrote:\n> \n> > Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n> > \n> > > Currently, the existence of rebase-merge/ is tested with 'test -d',\n> > > while the existence of rebase-apply/ is tested by creating the\n> > > directory and then deleting it again. Any good reason for this?\n> > \n> > I don't recall how the merge side reached the current shape of the code,\n> > but I think the rebase-apply one was that we wanted to make sure not only\n> > we don't have a directory but also we actually _can_ create one.  If\n> > somebody had a bad permission set, \"test -d\" wouldn't help us much.  We\n> > would fail later and error diagnosis codepath should do the right thing\n> > anyway, so it is not a correctness issue, but is more about attempting to\n> > notice an error early rather than late.\n> \n> Yeah, I was wondering if that might have been the reason. Why would\n> anyone set such permissions on .git (keep in mind that I am no\n> Linux/Unix expert)?\n> \n> I saw that the code was introduced [1] when the directory was called\n> .dotest and I believe this directory was created at the top level\n> (i.e. a sibling to .git). Could it be that it was reasonable for the\n> user to set such permissions back then (on the top level dir), but not\n> any longer (on the .git dir)?\n> \n> \n> Either way, if it is good to have the that check for rebase-apply/,\n> wouldn't it be good to have for rebase-merge/ as well?\n> \n> /Martin\n> \n> \n> [1] 7f4bd5d (rebase: one safety net, one bugfix and one optimization.,\n> 2005-11-28)\n> \n\nI'm working on a re-roll. Any input on this?\n"},{"id":"160508","messageId":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1293528648-21873-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:29Z","receivedAt":"2011-02-06T18:43:29Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Changes since the first round:\n\nAs suggested by Johannes Sixt, source git-rebase--interactive.sh and\nfriends instead of executing them.\n\nAs suggested by Thomas Rast, downcase all variables for consitency.\n\nBased on current master, including Jeff's two patches to rebase.\n\nThere are also a few other minor changes, but see the notes in each\npatch for more information.\n\n\nMartin von Zweigbergk (31):\n  rebase: clearer names for directory variables\n  rebase: refactor reading of state\n  rebase: read state outside loop\n  rebase: remove unused rebase state 'prev_head'\n  rebase: improve detection of rebase in progress\n  rebase: act on command line outside parsing loop\n  rebase: stricter check of standalone sub command\n  rebase: align variable names\n  rebase: align variable content\n  rebase: factor out command line option processing\n  rebase -i: remove now unnecessary directory checks\n  rebase: reorder validation steps\n  rebase: factor out reference parsing\n  rebase: factor out clean work tree check\n  rebase: factor out call to pre-rebase hook\n  rebase -i: support --stat\n  rebase: remove $branch as synonym for $orig_head\n  rebase: extract merge code to new source file\n  rebase: extract am code to new source file\n  rebase: show consistent conflict resolution hint\n  rebase -i: align variable names\n  rebase: make -v a tiny bit more verbose\n  rebase: factor out sub command handling\n  rebase: extract code for writing basic state\n  rebase: remember verbose option\n  rebase: remember strategy and strategy options\n  rebase -m: remember allow_rerere_autoupdate option\n  rebase -m: don't print exit code 2 when merge fails\n  git-rebase--am: remove unnecessary --3way option\n  rebase -i: don't read unused variable preserve_merges\n  rebase -i: remove unnecessary state rebase-root\n\n .gitignore                 |    2 +\n Makefile                   |    2 +\n git-rebase--am.sh          |   30 ++\n git-rebase--interactive.sh |  751 +++++++++++++++----------------------------\n git-rebase--merge.sh       |  151 +++++++++\n git-rebase.sh              |  482 +++++++++++-----------------\n t/t3403-rebase-skip.sh     |    5 +\n t/t3407-rebase-abort.sh    |   10 +\n t/t3418-rebase-continue.sh |   55 ++++\n 9 files changed, 707 insertions(+), 781 deletions(-)\n create mode 100644 git-rebase--am.sh\n create mode 100644 git-rebase--merge.sh\n\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160509","messageId":"1297017841-20678-2-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 01/31] rebase: clearer names for directory variables","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:30Z","receivedAt":"2011-02-06T18:43:30Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Instead of using the old variable name 'dotest' for\n\"$GIT_DIR\"/rebase-merge and no variable for \"$GIT_DIR\"/rebase-apply,\nintroduce two variables 'merge_dir' and 'apply_dir' for these paths.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |  141 +++++++++++++++++++++++++++++----------------------------\n 1 files changed, 71 insertions(+), 70 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex cbb0ea9..72696bf 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -46,7 +46,8 @@ unset newbase\n strategy=recursive\n strategy_opts=\n do_merge=\n-dotest=\"$GIT_DIR\"/rebase-merge\n+merge_dir=\"$GIT_DIR\"/rebase-merge\n+apply_dir=\"$GIT_DIR\"/rebase-apply\n prec=4\n verbose=\n diffstat=\n@@ -58,7 +59,7 @@ allow_rerere_autoupdate=\n \n continue_merge () {\n \ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n-\ttest -d \"$dotest\" || die \"$dotest directory does not exist\"\n+\ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n \n \tunmerged=$(git ls-files -u)\n \tif test -n \"$unmerged\"\n@@ -68,7 +69,7 @@ continue_merge () {\n \t\tdie \"$RESOLVEMSG\"\n \tfi\n \n-\tcmt=`cat \"$dotest/current\"`\n+\tcmt=`cat \"$merge_dir/current\"`\n \tif ! git diff-index --quiet --ignore-submodules HEAD --\n \tthen\n \t\tif ! git commit --no-verify -C \"$cmt\"\n@@ -81,7 +82,7 @@ continue_merge () {\n \t\tthen\n \t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n \t\tfi\n-\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$dotest/rewritten\"\n+\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$merge_dir/rewritten\"\n \telse\n \t\tif test -z \"$GIT_QUIET\"\n \t\tthen\n@@ -93,22 +94,22 @@ continue_merge () {\n \n \tprev_head=`git rev-parse HEAD^0`\n \t# save the resulting commit so we can read-tree on it later\n-\techo \"$prev_head\" > \"$dotest/prev_head\"\n+\techo \"$prev_head\" > \"$merge_dir/prev_head\"\n \n \t# onto the next patch:\n \tmsgnum=$(($msgnum + 1))\n-\techo \"$msgnum\" >\"$dotest/msgnum\"\n+\techo \"$msgnum\" >\"$merge_dir/msgnum\"\n }\n \n call_merge () {\n-\tcmt=\"$(cat \"$dotest/cmt.$1\")\"\n-\techo \"$cmt\" > \"$dotest/current\"\n+\tcmt=\"$(cat \"$merge_dir/cmt.$1\")\"\n+\techo \"$cmt\" > \"$merge_dir/current\"\n \thd=$(git rev-parse --verify HEAD)\n \tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n-\tmsgnum=$(cat \"$dotest/msgnum\")\n-\tend=$(cat \"$dotest/end\")\n+\tmsgnum=$(cat \"$merge_dir/msgnum\")\n+\tend=$(cat \"$merge_dir/end\")\n \teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n-\teval GITHEAD_$hd='$(cat \"$dotest/onto_name\")'\n+\teval GITHEAD_$hd='$(cat \"$merge_dir/onto_name\")'\n \texport GITHEAD_$cmt GITHEAD_$hd\n \tif test -n \"$GIT_QUIET\"\n \tthen\n@@ -138,9 +139,9 @@ call_merge () {\n \n move_to_original_branch () {\n \ttest -z \"$head_name\" &&\n-\t\thead_name=\"$(cat \"$dotest\"/head-name)\" &&\n-\t\tonto=\"$(cat \"$dotest\"/onto)\" &&\n-\t\torig_head=\"$(cat \"$dotest\"/orig-head)\"\n+\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n+\t\tonto=\"$(cat \"$merge_dir\"/onto)\" &&\n+\t\torig_head=\"$(cat \"$merge_dir\"/orig-head)\"\n \tcase \"$head_name\" in\n \trefs/*)\n \t\tmessage=\"rebase finished: $head_name onto $onto\"\n@@ -154,12 +155,12 @@ move_to_original_branch () {\n \n finish_rb_merge () {\n \tmove_to_original_branch\n-\tgit notes copy --for-rewrite=rebase < \"$dotest\"/rewritten\n+\tgit notes copy --for-rewrite=rebase < \"$merge_dir\"/rewritten\n \tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n-\t\ttest -s \"$dotest\"/rewritten; then\n-\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$dotest\"/rewritten\n+\t\ttest -s \"$merge_dir\"/rewritten; then\n+\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$merge_dir\"/rewritten\n \tfi\n-\trm -r \"$dotest\"\n+\trm -r \"$merge_dir\"\n \tsay All done.\n }\n \n@@ -183,7 +184,7 @@ is_interactive () {\n \t\texport GIT_EDITOR\n \tfi\n \n-\ttest -n \"$interactive_rebase\" || test -f \"$dotest\"/interactive\n+\ttest -n \"$interactive_rebase\" || test -f \"$merge_dir\"/interactive\n }\n \n run_pre_rebase_hook () {\n@@ -195,7 +196,7 @@ run_pre_rebase_hook () {\n \tfi\n }\n \n-test -f \"$GIT_DIR\"/rebase-apply/applying &&\n+test -f \"$apply_dir\"/applying &&\n \tdie 'It looks like git-am is in progress. Cannot rebase.'\n \n is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n@@ -210,7 +211,7 @@ do\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n \t--continue)\n-\t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n+\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit update-index --ignore-submodules --refresh &&\n@@ -219,13 +220,13 @@ do\n \t\t\techo \"mark them as resolved using git add\"\n \t\t\texit 1\n \t\t}\n-\t\tif test -d \"$dotest\"\n+\t\tif test -d \"$merge_dir\"\n \t\tthen\n-\t\t\tprev_head=$(cat \"$dotest/prev_head\")\n-\t\t\tend=$(cat \"$dotest/end\")\n-\t\t\tmsgnum=$(cat \"$dotest/msgnum\")\n-\t\t\tonto=$(cat \"$dotest/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n+\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n+\t\t\tend=$(cat \"$merge_dir/end\")\n+\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n+\t\t\tonto=$(cat \"$merge_dir/onto\")\n+\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\tcontinue_merge\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n@@ -235,28 +236,28 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n-\t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n-\t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$GIT_DIR\"/rebase-apply/quiet)\n+\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n+\t\tonto=$(cat \"$apply_dir\"/onto) &&\n+\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n+\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n \t\t;;\n \t--skip)\n-\t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n+\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit reset --hard HEAD || exit $?\n-\t\tif test -d \"$dotest\"\n+\t\tif test -d \"$merge_dir\"\n \t\tthen\n \t\t\tgit rerere clear\n-\t\t\tprev_head=$(cat \"$dotest/prev_head\")\n-\t\t\tend=$(cat \"$dotest/end\")\n-\t\t\tmsgnum=$(cat \"$dotest/msgnum\")\n+\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n+\t\t\tend=$(cat \"$merge_dir/end\")\n+\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n \t\t\tmsgnum=$(($msgnum + 1))\n-\t\t\tonto=$(cat \"$dotest/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$dotest/quiet\")\n+\t\t\tonto=$(cat \"$merge_dir/onto\")\n+\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n \t\t\t\tcall_merge \"$msgnum\"\n@@ -265,31 +266,31 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$GIT_DIR\"/rebase-apply/head-name) &&\n-\t\tonto=$(cat \"$GIT_DIR\"/rebase-apply/onto) &&\n-\t\torig_head=$(cat \"$GIT_DIR\"/rebase-apply/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$GIT_DIR\"/rebase-apply/quiet)\n+\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n+\t\tonto=$(cat \"$apply_dir\"/onto) &&\n+\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n+\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n \t\t;;\n \t--abort)\n-\t\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply ||\n+\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit rerere clear\n \n-\t\ttest -d \"$dotest\" || dotest=\"$GIT_DIR\"/rebase-apply\n+\t\ttest -d \"$merge_dir\" || merge_dir=\"$apply_dir\"\n \n-\t\thead_name=\"$(cat \"$dotest\"/head-name)\" &&\n+\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n \t\tcase \"$head_name\" in\n \t\trefs/*)\n \t\t\tgit symbolic-ref HEAD $head_name ||\n \t\t\tdie \"Could not move back to $head_name\"\n \t\t\t;;\n \t\tesac\n-\t\tgit reset --hard $(cat \"$dotest/orig-head\")\n-\t\trm -r \"$dotest\"\n+\t\tgit reset --hard $(cat \"$merge_dir/orig-head\")\n+\t\trm -r \"$merge_dir\"\n \t\texit\n \t\t;;\n \t--onto)\n@@ -388,31 +389,31 @@ test $# -gt 2 && usage\n \n if test $# -eq 0 && test -z \"$rebase_root\"\n then\n-\ttest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply || usage\n-\ttest -d \"$dotest\" -o -f \"$GIT_DIR\"/rebase-apply/rebasing &&\n+\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" || usage\n+\ttest -d \"$merge_dir\" -o -f \"$apply_dir\"/rebasing &&\n \t\tdie 'A rebase is in progress, try --continue, --skip or --abort.'\n fi\n \n-# Make sure we do not have $GIT_DIR/rebase-apply\n+# Make sure we do not have $apply_dir or $merge_dir\n if test -z \"$do_merge\"\n then\n-\tif mkdir \"$GIT_DIR\"/rebase-apply 2>/dev/null\n+\tif mkdir \"$apply_dir\" 2>/dev/null\n \tthen\n-\t\trmdir \"$GIT_DIR\"/rebase-apply\n+\t\trmdir \"$apply_dir\"\n \telse\n \t\techo >&2 '\n It seems that I cannot create a rebase-apply directory, and\n I wonder if you are in the middle of patch application or another\n rebase.  If that is not the case, please\n-\trm -fr '\"$GIT_DIR\"'/rebase-apply\n+\trm -fr '\"$apply_dir\"'\n and run me again.  I am stopping in case you still have something\n valuable there.'\n \t\texit 1\n \tfi\n else\n-\tif test -d \"$dotest\"\n+\tif test -d \"$merge_dir\"\n \tthen\n-\t\tdie \"previous rebase directory $dotest still exists.\" \\\n+\t\tdie \"previous rebase directory $merge_dir still exists.\" \\\n \t\t\t'Try git rebase (--continue | --abort | --skip)'\n \tfi\n fi\n@@ -561,35 +562,35 @@ then\n \tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n \tmove_to_original_branch\n \tret=$?\n-\ttest 0 != $ret -a -d \"$GIT_DIR\"/rebase-apply &&\n-\t\techo $head_name > \"$GIT_DIR\"/rebase-apply/head-name &&\n-\t\techo $onto > \"$GIT_DIR\"/rebase-apply/onto &&\n-\t\techo $orig_head > \"$GIT_DIR\"/rebase-apply/orig-head &&\n-\t\techo \"$GIT_QUIET\" > \"$GIT_DIR\"/rebase-apply/quiet\n+\ttest 0 != $ret -a -d \"$apply_dir\" &&\n+\t\techo $head_name > \"$apply_dir/head-name\" &&\n+\t\techo $onto > \"$apply_dir/onto\" &&\n+\t\techo $orig_head > \"$apply_dir/orig-head\" &&\n+\t\techo \"$GIT_QUIET\" > \"$apply_dir/quiet\"\n \texit $ret\n fi\n \n # start doing a rebase with git-merge\n # this is rename-aware if the recursive (default) strategy is used\n \n-mkdir -p \"$dotest\"\n-echo \"$onto\" > \"$dotest/onto\"\n-echo \"$onto_name\" > \"$dotest/onto_name\"\n+mkdir -p \"$merge_dir\"\n+echo \"$onto\" > \"$merge_dir/onto\"\n+echo \"$onto_name\" > \"$merge_dir/onto_name\"\n prev_head=$orig_head\n-echo \"$prev_head\" > \"$dotest/prev_head\"\n-echo \"$orig_head\" > \"$dotest/orig-head\"\n-echo \"$head_name\" > \"$dotest/head-name\"\n-echo \"$GIT_QUIET\" > \"$dotest/quiet\"\n+echo \"$prev_head\" > \"$merge_dir/prev_head\"\n+echo \"$orig_head\" > \"$merge_dir/orig-head\"\n+echo \"$head_name\" > \"$merge_dir/head-name\"\n+echo \"$GIT_QUIET\" > \"$merge_dir/quiet\"\n \n msgnum=0\n for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n do\n \tmsgnum=$(($msgnum + 1))\n-\techo \"$cmt\" > \"$dotest/cmt.$msgnum\"\n+\techo \"$cmt\" > \"$merge_dir/cmt.$msgnum\"\n done\n \n-echo 1 >\"$dotest/msgnum\"\n-echo $msgnum >\"$dotest/end\"\n+echo 1 >\"$merge_dir/msgnum\"\n+echo $msgnum >\"$merge_dir/end\"\n \n end=$msgnum\n msgnum=1\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160517","messageId":"1297017841-20678-3-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 02/31] rebase: refactor reading of state","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:31Z","receivedAt":"2011-02-06T18:43:31Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The code reading the state saved in $merge_dir or $rebase_dir is\ncurrently spread out in many places, making it harder to read and to\nintroduce additional state. Extract this code into one method that\nreads the state. Only extract the code associated with the state that\nis written when the rebase is initiated. Leave the state that changes\nfor each commmit, at least for now.\n\nCurrently, when resuming a merge-based rebase using --continue or\n--skip, move_to_original_branch (via finish_rb_merge) will be called\nwithout head_name and orig_head set. These variables are then lazily\nread in move_to_original_branch if head_name is not set (together with\nonto, which is unnecessarily read again). Change this by always\neagerly reading the state, for both am-based and merge-based rebase,\nin the --continue and --skip cases. Note that this does not change the\nbehavior for am-based rebase, which read the state eagerly even before\nthis commit.\n\nReading the state eagerly means that part of the state will sometimes\nbe read unnecessarily. One example is when the rebase is continued,\nbut stops again at another merge conflict. Another example is when the\nrebase is aborted. However, since both of these cases involve user\ninteraction, the delay is hopefully not noticeable. The\ncall_merge/continue_merge loop is not affected.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |   53 +++++++++++++++++++++++------------------------------\n 1 files changed, 23 insertions(+), 30 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 72696bf..63b5683 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -57,6 +57,22 @@ rebase_root=\n force_rebase=\n allow_rerere_autoupdate=\n \n+read_state () {\n+\tif test -d \"$merge_dir\"\n+\tthen\n+\t\tstate_dir=\"$merge_dir\"\n+\t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n+\t\tend=$(cat \"$merge_dir\"/end) &&\n+\t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n+\telse\n+\t\tstate_dir=\"$apply_dir\"\n+\tfi &&\n+\thead_name=$(cat \"$state_dir\"/head-name) &&\n+\tonto=$(cat \"$state_dir\"/onto) &&\n+\torig_head=$(cat \"$state_dir\"/orig-head) &&\n+\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n+}\n+\n continue_merge () {\n \ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n \ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n@@ -138,10 +154,6 @@ call_merge () {\n }\n \n move_to_original_branch () {\n-\ttest -z \"$head_name\" &&\n-\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n-\t\tonto=\"$(cat \"$merge_dir\"/onto)\" &&\n-\t\torig_head=\"$(cat \"$merge_dir\"/orig-head)\"\n \tcase \"$head_name\" in\n \trefs/*)\n \t\tmessage=\"rebase finished: $head_name onto $onto\"\n@@ -220,13 +232,9 @@ do\n \t\t\techo \"mark them as resolved using git add\"\n \t\t\texit 1\n \t\t}\n+\t\tread_state\n \t\tif test -d \"$merge_dir\"\n \t\tthen\n-\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n-\t\t\tend=$(cat \"$merge_dir/end\")\n-\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n-\t\t\tonto=$(cat \"$merge_dir/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\tcontinue_merge\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n@@ -236,10 +244,6 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n-\t\tonto=$(cat \"$apply_dir\"/onto) &&\n-\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n@@ -249,15 +253,11 @@ do\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit reset --hard HEAD || exit $?\n+\t\tread_state\n \t\tif test -d \"$merge_dir\"\n \t\tthen\n \t\t\tgit rerere clear\n-\t\t\tprev_head=$(cat \"$merge_dir/prev_head\")\n-\t\t\tend=$(cat \"$merge_dir/end\")\n-\t\t\tmsgnum=$(cat \"$merge_dir/msgnum\")\n \t\t\tmsgnum=$(($msgnum + 1))\n-\t\t\tonto=$(cat \"$merge_dir/onto\")\n-\t\t\tGIT_QUIET=$(cat \"$merge_dir/quiet\")\n \t\t\twhile test \"$msgnum\" -le \"$end\"\n \t\t\tdo\n \t\t\t\tcall_merge \"$msgnum\"\n@@ -266,10 +266,6 @@ do\n \t\t\tfinish_rb_merge\n \t\t\texit\n \t\tfi\n-\t\thead_name=$(cat \"$apply_dir\"/head-name) &&\n-\t\tonto=$(cat \"$apply_dir\"/onto) &&\n-\t\torig_head=$(cat \"$apply_dir\"/orig-head) &&\n-\t\tGIT_QUIET=$(cat \"$apply_dir\"/quiet)\n \t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n \t\tmove_to_original_branch\n \t\texit\n@@ -279,18 +275,15 @@ do\n \t\t\tdie \"No rebase in progress?\"\n \n \t\tgit rerere clear\n-\n-\t\ttest -d \"$merge_dir\" || merge_dir=\"$apply_dir\"\n-\n-\t\thead_name=\"$(cat \"$merge_dir\"/head-name)\" &&\n+\t\tread_state\n \t\tcase \"$head_name\" in\n \t\trefs/*)\n \t\t\tgit symbolic-ref HEAD $head_name ||\n \t\t\tdie \"Could not move back to $head_name\"\n \t\t\t;;\n \t\tesac\n-\t\tgit reset --hard $(cat \"$merge_dir/orig-head\")\n-\t\trm -r \"$merge_dir\"\n+\t\tgit reset --hard $orig_head\n+\t\trm -r \"$state_dir\"\n \t\texit\n \t\t;;\n \t--onto)\n@@ -574,12 +567,12 @@ fi\n # this is rename-aware if the recursive (default) strategy is used\n \n mkdir -p \"$merge_dir\"\n-echo \"$onto\" > \"$merge_dir/onto\"\n echo \"$onto_name\" > \"$merge_dir/onto_name\"\n prev_head=$orig_head\n echo \"$prev_head\" > \"$merge_dir/prev_head\"\n-echo \"$orig_head\" > \"$merge_dir/orig-head\"\n echo \"$head_name\" > \"$merge_dir/head-name\"\n+echo \"$onto\" > \"$merge_dir/onto\"\n+echo \"$orig_head\" > \"$merge_dir/orig-head\"\n echo \"$GIT_QUIET\" > \"$merge_dir/quiet\"\n \n msgnum=0\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160510","messageId":"1297017841-20678-4-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 03/31] rebase: read state outside loop","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:32Z","receivedAt":"2011-02-06T18:43:32Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The 'onto_name' state used in 'git rebase --merge' is currently read\nonce for each commit that need to be applied. It doesn't change\nbetween each iteration, however, so it should be moved out of the\nloop. This also makes the code more readable. Also remove the unused\nvariable 'end'.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 63b5683..70948bc 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -62,6 +62,7 @@ read_state () {\n \tthen\n \t\tstate_dir=\"$merge_dir\"\n \t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n+\t\tonto_name=$(cat \"$merge_dir\"/onto_name) &&\n \t\tend=$(cat \"$merge_dir\"/end) &&\n \t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n \telse\n@@ -123,9 +124,8 @@ call_merge () {\n \thd=$(git rev-parse --verify HEAD)\n \tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n \tmsgnum=$(cat \"$merge_dir/msgnum\")\n-\tend=$(cat \"$merge_dir/end\")\n \teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n-\teval GITHEAD_$hd='$(cat \"$merge_dir/onto_name\")'\n+\teval GITHEAD_$hd='$onto_name'\n \texport GITHEAD_$cmt GITHEAD_$hd\n \tif test -n \"$GIT_QUIET\"\n \tthen\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160511","messageId":"1297017841-20678-5-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 04/31] rebase: remove unused rebase state 'prev_head'","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:33Z","receivedAt":"2011-02-06T18:43:33Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The state stored in $GIT_DIR/rebase-merge/prev_head was introduced in\n58634db (rebase: Allow merge strategies to be used when rebasing,\n2006-06-21), but it was never used and should therefore be removed.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |    8 --------\n 1 files changed, 0 insertions(+), 8 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 70948bc..8c1c4ed 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -61,7 +61,6 @@ read_state () {\n \tif test -d \"$merge_dir\"\n \tthen\n \t\tstate_dir=\"$merge_dir\"\n-\t\tprev_head=$(cat \"$merge_dir\"/prev_head) &&\n \t\tonto_name=$(cat \"$merge_dir\"/onto_name) &&\n \t\tend=$(cat \"$merge_dir\"/end) &&\n \t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n@@ -75,7 +74,6 @@ read_state () {\n }\n \n continue_merge () {\n-\ttest -n \"$prev_head\" || die \"prev_head must be defined\"\n \ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n \n \tunmerged=$(git ls-files -u)\n@@ -109,10 +107,6 @@ continue_merge () {\n \ttest -z \"$GIT_QUIET\" &&\n \tGIT_PAGER='' git log --format=%s -1 \"$cmt\"\n \n-\tprev_head=`git rev-parse HEAD^0`\n-\t# save the resulting commit so we can read-tree on it later\n-\techo \"$prev_head\" > \"$merge_dir/prev_head\"\n-\n \t# onto the next patch:\n \tmsgnum=$(($msgnum + 1))\n \techo \"$msgnum\" >\"$merge_dir/msgnum\"\n@@ -568,8 +562,6 @@ fi\n \n mkdir -p \"$merge_dir\"\n echo \"$onto_name\" > \"$merge_dir/onto_name\"\n-prev_head=$orig_head\n-echo \"$prev_head\" > \"$merge_dir/prev_head\"\n echo \"$head_name\" > \"$merge_dir/head-name\"\n echo \"$onto\" > \"$merge_dir/onto\"\n echo \"$orig_head\" > \"$merge_dir/orig-head\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160512","messageId":"1297017841-20678-6-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 05/31] rebase: improve detection of rebase in progress","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:34Z","receivedAt":"2011-02-06T18:43:34Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Detect early on if a rebase is in progress and what type of rebase it\nis (interactive, merge-based or am-based). This prepares for further\nrefactoring where am-based rebase will be dispatched to\ngit-rebase--am.sh and merge-based rebase will be dispatched to\ngit-rebase--merge.sh.\n\nThe idea is to use the same variables whether the type of rebase was\ndetected from rebase-apply/ or rebase-merge/ directories or from the\ncommand line options. This will make the code more readable and will\nlater also make it easier to dispatch to the type-specific scripts.\n\nAlso show a consistent error message independent of the type of rebase\nthat was in progress and remove the obsolete wording about being in\nthe middle of a 'patch application', since that (an existing\n\"$GIT_DIR\"/rebase-apply/applying) aborts 'git rebase' at an earlier\nstage.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nCurrently, the existence of rebase-merge/ is tested with 'test -d',\nwhile the existence of rebase-apply/ is tested by creating the\ndirectory and then deleting it again. Any good reason for this?\n\nThere were some discussions on the above subject in the first round,\nbut nothing conclusive, so I have left it the way it was for now.\n\n git-rebase.sh |   80 +++++++++++++++++++++++++++++---------------------------\n 1 files changed, 41 insertions(+), 39 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 8c1c4ed..1d34d43 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -56,16 +56,19 @@ git_am_opt=\n rebase_root=\n force_rebase=\n allow_rerere_autoupdate=\n+# Non-empty if a rebase was in progress when 'git rebase' was invoked\n+in_progress=\n+# One of {am, merge, interactive}\n+type=\n+# One of {\"$GIT_DIR\"/rebase-apply, \"$GIT_DIR\"/rebase-merge}\n+state_dir=\n \n read_state () {\n-\tif test -d \"$merge_dir\"\n+\tif test \"$type\" = merge\n \tthen\n-\t\tstate_dir=\"$merge_dir\"\n-\t\tonto_name=$(cat \"$merge_dir\"/onto_name) &&\n-\t\tend=$(cat \"$merge_dir\"/end) &&\n-\t\tmsgnum=$(cat \"$merge_dir\"/msgnum)\n-\telse\n-\t\tstate_dir=\"$apply_dir\"\n+\t\tonto_name=$(cat \"$state_dir\"/onto_name) &&\n+\t\tend=$(cat \"$state_dir\"/end) &&\n+\t\tmsgnum=$(cat \"$state_dir\"/msgnum)\n \tfi &&\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n@@ -207,6 +210,23 @@ test -f \"$apply_dir\"/applying &&\n \n is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n \n+if test -d \"$apply_dir\"\n+then\n+\ttype=am\n+\tstate_dir=\"$apply_dir\"\n+elif test -d \"$merge_dir\"\n+then\n+\tif test -f \"$merge_dir\"/interactive\n+\tthen\n+\t\ttype=interactive\n+\t\tinteractive_rebase=explicit\n+\telse\n+\t\ttype=merge\n+\tfi\n+\tstate_dir=\"$merge_dir\"\n+fi\n+test -n \"$type\" && in_progress=t\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -217,8 +237,7 @@ do\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n \t--continue)\n-\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n-\t\t\tdie \"No rebase in progress?\"\n+\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \n \t\tgit update-index --ignore-submodules --refresh &&\n \t\tgit diff-files --quiet --ignore-submodules || {\n@@ -243,8 +262,7 @@ do\n \t\texit\n \t\t;;\n \t--skip)\n-\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n-\t\t\tdie \"No rebase in progress?\"\n+\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \n \t\tgit reset --hard HEAD || exit $?\n \t\tread_state\n@@ -265,8 +283,7 @@ do\n \t\texit\n \t\t;;\n \t--abort)\n-\t\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" ||\n-\t\t\tdie \"No rebase in progress?\"\n+\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \n \t\tgit rerere clear\n \t\tread_state\n@@ -374,37 +391,22 @@ do\n done\n test $# -gt 2 && usage\n \n-if test $# -eq 0 && test -z \"$rebase_root\"\n+# Make sure no rebase is in progress\n+if test -n \"$in_progress\"\n then\n-\ttest -d \"$merge_dir\" -o -d \"$apply_dir\" || usage\n-\ttest -d \"$merge_dir\" -o -f \"$apply_dir\"/rebasing &&\n-\t\tdie 'A rebase is in progress, try --continue, --skip or --abort.'\n-fi\n-\n-# Make sure we do not have $apply_dir or $merge_dir\n-if test -z \"$do_merge\"\n-then\n-\tif mkdir \"$apply_dir\" 2>/dev/null\n-\tthen\n-\t\trmdir \"$apply_dir\"\n-\telse\n-\t\techo >&2 '\n-It seems that I cannot create a rebase-apply directory, and\n-I wonder if you are in the middle of patch application or another\n-rebase.  If that is not the case, please\n-\trm -fr '\"$apply_dir\"'\n+\tdie '\n+It seems that there is already a '\"${state_dir##*/}\"' directory, and\n+I wonder if you are in the middle of another rebase.  If that is the\n+case, please try\n+\tgit rebase (--continue | --abort | --skip)\n+If that is not the case, please\n+\trm -fr '\"$state_dir\"'\n and run me again.  I am stopping in case you still have something\n valuable there.'\n-\t\texit 1\n-\tfi\n-else\n-\tif test -d \"$merge_dir\"\n-\tthen\n-\t\tdie \"previous rebase directory $merge_dir still exists.\" \\\n-\t\t\t'Try git rebase (--continue | --abort | --skip)'\n-\tfi\n fi\n \n+test $# -eq 0 && test -z \"$rebase_root\" && usage\n+\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n if test -z \"$rebase_root\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160513","messageId":"1297017841-20678-7-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 06/31] rebase: act on command line outside parsing loop","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:35Z","receivedAt":"2011-02-06T18:43:35Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"To later be able to use the command line processing in git-rebase.sh\nfor both interactive and non-interactive rebases, move anything that\nis specific to non-interactive rebase outside of the parsing\nloop. Keep only parsing and validation of command line options in the\nloop.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nMay want to view this patch with --ignore-all-space.\n\n git-rebase--interactive.sh |  300 ++++++++++++++++++++++----------------------\n git-rebase.sh              |  126 ++++++++++---------\n 2 files changed, 217 insertions(+), 209 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5873ba4..824f4f3 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -866,152 +866,158 @@ first and then run 'git rebase --continue' again.\"\n \t\t;;\n \t--)\n \t\tshift\n-\t\ttest -z \"$REBASE_ROOT\" -a $# -ge 1 -a $# -le 2 ||\n-\t\ttest ! -z \"$REBASE_ROOT\" -a $# -le 1 || usage\n-\t\ttest -d \"$DOTEST\" &&\n-\t\t\tdie \"Interactive rebase already started\"\n-\n-\t\tgit var GIT_COMMITTER_IDENT >/dev/null ||\n-\t\t\tdie \"You need to set your committer info first\"\n-\n-\t\tif test -z \"$REBASE_ROOT\"\n-\t\tthen\n-\t\t\tUPSTREAM_ARG=\"$1\"\n-\t\t\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\t\t\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n-\t\t\tshift\n-\t\telse\n-\t\t\tUPSTREAM=\n-\t\t\tUPSTREAM_ARG=--root\n-\t\t\ttest -z \"$ONTO\" &&\n-\t\t\t\tdie \"You must specify --onto when using --root\"\n-\t\tfi\n-\t\trun_pre_rebase_hook \"$UPSTREAM_ARG\" \"$@\"\n-\n-\t\tcomment_for_reflog start\n-\n-\t\trequire_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n-\t\tif test ! -z \"$1\"\n-\t\tthen\n-\t\t\toutput git checkout \"$1\" -- ||\n-\t\t\t\tdie \"Could not checkout $1\"\n-\t\tfi\n+\t\tbreak\n+\t\t;;\n+\tesac\n+\tshift\n+done\n \n-\t\tHEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n-\t\tmkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n+test -z \"$REBASE_ROOT\" -a $# -ge 1 -a $# -le 2 ||\n+test ! -z \"$REBASE_ROOT\" -a $# -le 1 || usage\n+test -d \"$DOTEST\" &&\n+\tdie \"Interactive rebase already started\"\n \n-\t\t: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n-\t\tgit symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n-\t\t\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n+git var GIT_COMMITTER_IDENT >/dev/null ||\n+\tdie \"You need to set your committer info first\"\n \n-\t\techo $HEAD > \"$DOTEST\"/head\n-\t\tcase \"$REBASE_ROOT\" in\n-\t\t'')\n-\t\t\trm -f \"$DOTEST\"/rebase-root ;;\n-\t\t*)\n-\t\t\t: >\"$DOTEST\"/rebase-root ;;\n-\t\tesac\n-\t\techo $ONTO > \"$DOTEST\"/onto\n-\t\ttest -z \"$STRATEGY\" || echo \"$STRATEGY\" > \"$DOTEST\"/strategy\n-\t\ttest t = \"$VERBOSE\" && : > \"$DOTEST\"/verbose\n-\t\tif test t = \"$PRESERVE_MERGES\"\n-\t\tthen\n-\t\t\tif test -z \"$REBASE_ROOT\"\n-\t\t\tthen\n-\t\t\t\tmkdir \"$REWRITTEN\" &&\n-\t\t\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\n-\t\t\t\tdo\n-\t\t\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n-\t\t\t\t\t\tdie \"Could not init rewritten commits\"\n-\t\t\t\tdone\n-\t\t\telse\n-\t\t\t\tmkdir \"$REWRITTEN\" &&\n-\t\t\t\techo $ONTO > \"$REWRITTEN\"/root ||\n-\t\t\t\t\tdie \"Could not init rewritten commits\"\n-\t\t\tfi\n-\t\t\t# No cherry-pick because our first pass is to determine\n-\t\t\t# parents to rewrite and skipping dropped commits would\n-\t\t\t# prematurely end our probe\n-\t\t\tMERGES_OPTION=\n-\t\t\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n-\t\telse\n-\t\t\tMERGES_OPTION=\"--no-merges --cherry-pick\"\n-\t\tfi\n-\n-\t\tSHORTHEAD=$(git rev-parse --short $HEAD)\n-\t\tSHORTONTO=$(git rev-parse --short $ONTO)\n-\t\tif test -z \"$REBASE_ROOT\"\n-\t\t\t# this is now equivalent to ! -z \"$UPSTREAM\"\n-\t\tthen\n-\t\t\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\n-\t\t\tREVISIONS=$UPSTREAM...$HEAD\n-\t\t\tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n-\t\telse\n-\t\t\tREVISIONS=$ONTO...$HEAD\n-\t\t\tSHORTREVISIONS=$SHORTHEAD\n-\t\tfi\n-\t\tgit rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n-\t\t\t--abbrev=7 --reverse --left-right --topo-order \\\n-\t\t\t$REVISIONS | \\\n-\t\t\tsed -n \"s/^>//p\" |\n-\t\twhile read -r shortsha1 rest\n+if test -z \"$REBASE_ROOT\"\n+then\n+\tUPSTREAM_ARG=\"$1\"\n+\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n+\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n+\tshift\n+else\n+\tUPSTREAM=\n+\tUPSTREAM_ARG=--root\n+\ttest -z \"$ONTO\" &&\n+\tdie \"You must specify --onto when using --root\"\n+fi\n+run_pre_rebase_hook \"$UPSTREAM_ARG\" \"$@\"\n+\n+comment_for_reflog start\n+\n+require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n+\n+if test ! -z \"$1\"\n+then\n+\toutput git checkout \"$1\" -- ||\n+\t\tdie \"Could not checkout $1\"\n+fi\n+\n+HEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n+mkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n+\n+: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n+git symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n+\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n+\n+echo $HEAD > \"$DOTEST\"/head\n+case \"$REBASE_ROOT\" in\n+'')\n+\trm -f \"$DOTEST\"/rebase-root ;;\n+*)\n+\t: >\"$DOTEST\"/rebase-root ;;\n+esac\n+echo $ONTO > \"$DOTEST\"/onto\n+test -z \"$STRATEGY\" || echo \"$STRATEGY\" > \"$DOTEST\"/strategy\n+test t = \"$VERBOSE\" && : > \"$DOTEST\"/verbose\n+if test t = \"$PRESERVE_MERGES\"\n+then\n+\tif test -z \"$REBASE_ROOT\"\n+\tthen\n+\t\tmkdir \"$REWRITTEN\" &&\n+\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\n \t\tdo\n-\t\t\tif test t != \"$PRESERVE_MERGES\"\n-\t\t\tthen\n-\t\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n-\t\t\telse\n-\t\t\t\tsha1=$(git rev-parse $shortsha1)\n-\t\t\t\tif test -z \"$REBASE_ROOT\"\n-\t\t\t\tthen\n-\t\t\t\t\tpreserve=t\n-\t\t\t\t\tfor p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-)\n-\t\t\t\t\tdo\n-\t\t\t\t\t\tif test -f \"$REWRITTEN\"/$p -a \\( $p != $ONTO -o $sha1 = $first_after_upstream \\)\n-\t\t\t\t\t\tthen\n-\t\t\t\t\t\t\tpreserve=f\n-\t\t\t\t\t\tfi\n-\t\t\t\t\tdone\n-\t\t\t\telse\n-\t\t\t\t\tpreserve=f\n-\t\t\t\tfi\n-\t\t\t\tif test f = \"$preserve\"\n-\t\t\t\tthen\n-\t\t\t\t\ttouch \"$REWRITTEN\"/$sha1\n-\t\t\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n-\t\t\t\tfi\n-\t\t\tfi\n+\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n+\t\t\t\tdie \"Could not init rewritten commits\"\n \t\tdone\n-\n-\t\t# Watch for commits that been dropped by --cherry-pick\n-\t\tif test t = \"$PRESERVE_MERGES\"\n+\telse\n+\t\tmkdir \"$REWRITTEN\" &&\n+\t\techo $ONTO > \"$REWRITTEN\"/root ||\n+\t\t\tdie \"Could not init rewritten commits\"\n+\tfi\n+\t# No cherry-pick because our first pass is to determine\n+\t# parents to rewrite and skipping dropped commits would\n+\t# prematurely end our probe\n+\tMERGES_OPTION=\n+\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n+else\n+\tMERGES_OPTION=\"--no-merges --cherry-pick\"\n+fi\n+\n+SHORTHEAD=$(git rev-parse --short $HEAD)\n+SHORTONTO=$(git rev-parse --short $ONTO)\n+if test -z \"$REBASE_ROOT\"\n+\t# this is now equivalent to ! -z \"$UPSTREAM\"\n+then\n+\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\n+\tREVISIONS=$UPSTREAM...$HEAD\n+\tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n+else\n+\tREVISIONS=$ONTO...$HEAD\n+\tSHORTREVISIONS=$SHORTHEAD\n+fi\n+git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n+\t--abbrev=7 --reverse --left-right --topo-order \\\n+\t$REVISIONS | \\\n+\tsed -n \"s/^>//p\" |\n+while read -r shortsha1 rest\n+do\n+\tif test t != \"$PRESERVE_MERGES\"\n+\tthen\n+\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\telse\n+\t\tsha1=$(git rev-parse $shortsha1)\n+\t\tif test -z \"$REBASE_ROOT\"\n \t\tthen\n-\t\t\tmkdir \"$DROPPED\"\n-\t\t\t# Save all non-cherry-picked changes\n-\t\t\tgit rev-list $REVISIONS --left-right --cherry-pick | \\\n-\t\t\t\tsed -n \"s/^>//p\" > \"$DOTEST\"/not-cherry-picks\n-\t\t\t# Now all commits and note which ones are missing in\n-\t\t\t# not-cherry-picks and hence being dropped\n-\t\t\tgit rev-list $REVISIONS |\n-\t\t\twhile read rev\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\"/$rev -a \"$(sane_grep \"$rev\" \"$DOTEST\"/not-cherry-picks)\" = \"\"\n+\t\t\t\tif test -f \"$REWRITTEN\"/$p -a \\( $p != $ONTO -o $sha1 = $first_after_upstream \\)\n \t\t\t\tthen\n-\t\t\t\t\t# Use -f2 because if rev-list is telling us this commit is\n-\t\t\t\t\t# not worthwhile, we don't want to track its multiple heads,\n-\t\t\t\t\t# just the history of its first-parent for others that will\n-\t\t\t\t\t# be rebasing on top of it\n-\t\t\t\t\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$DROPPED\"/$rev\n-\t\t\t\t\tshort=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)\n-\t\t\t\t\tsane_grep -v \"^[a-z][a-z]* $short\" <\"$TODO\" > \"${TODO}2\" ; mv \"${TODO}2\" \"$TODO\"\n-\t\t\t\t\trm \"$REWRITTEN\"/$rev\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' \"pick $shortsha1 $rest\" >> \"$TODO\"\n \t\tfi\n+\tfi\n+done\n \n-\t\ttest -s \"$TODO\" || echo noop >> \"$TODO\"\n-\t\ttest -n \"$AUTOSQUASH\" && rearrange_squash \"$TODO\"\n-\t\tcat >> \"$TODO\" << EOF\n+# Watch for commits that been dropped by --cherry-pick\n+if test t = \"$PRESERVE_MERGES\"\n+then\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\" > \"$DOTEST\"/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 -a \"$(sane_grep \"$rev\" \"$DOTEST\"/not-cherry-picks)\" = \"\"\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\tshort=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $short\" <\"$TODO\" > \"${TODO}2\" ; mv \"${TODO}2\" \"$TODO\"\n+\t\t\trm \"$REWRITTEN\"/$rev\n+\t\tfi\n+\tdone\n+fi\n+\n+test -s \"$TODO\" || echo noop >> \"$TODO\"\n+test -n \"$AUTOSQUASH\" && rearrange_squash \"$TODO\"\n+cat >> \"$TODO\" << EOF\n \n # Rebase $SHORTREVISIONS onto $SHORTONTO\n #\n@@ -1028,22 +1034,18 @@ first and then run 'git rebase --continue' again.\"\n #\n EOF\n \n-\t\thas_action \"$TODO\" ||\n-\t\t\tdie_abort \"Nothing to do\"\n+has_action \"$TODO\" ||\n+\tdie_abort \"Nothing to do\"\n \n-\t\tcp \"$TODO\" \"$TODO\".backup\n-\t\tgit_editor \"$TODO\" ||\n-\t\t\tdie_abort \"Could not execute editor\"\n+cp \"$TODO\" \"$TODO\".backup\n+git_editor \"$TODO\" ||\n+\tdie_abort \"Could not execute editor\"\n \n-\t\thas_action \"$TODO\" ||\n-\t\t\tdie_abort \"Nothing to do\"\n+has_action \"$TODO\" ||\n+\tdie_abort \"Nothing to do\"\n \n-\t\ttest -d \"$REWRITTEN\" || test -n \"$NEVER_FF\" || skip_unnecessary_picks\n+test -d \"$REWRITTEN\" || test -n \"$NEVER_FF\" || skip_unnecessary_picks\n \n-\t\toutput git checkout $ONTO || die_abort \"could not detach HEAD\"\n-\t\tgit update-ref ORIG_HEAD $HEAD\n-\t\tdo_rest\n-\t\t;;\n-\tesac\n-\tshift\n-done\n+output git checkout $ONTO || die_abort \"could not detach HEAD\"\n+git update-ref ORIG_HEAD $HEAD\n+do_rest\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 1d34d43..e3fd001 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -62,6 +62,8 @@ in_progress=\n type=\n # One of {\"$GIT_DIR\"/rebase-apply, \"$GIT_DIR\"/rebase-merge}\n state_dir=\n+# One of {'', continue, skip, abort}, as parsed from command line\n+action=\n \n read_state () {\n \tif test \"$type\" = merge\n@@ -236,66 +238,10 @@ do\n \t--verify)\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n-\t--continue)\n-\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\n-\t\tgit update-index --ignore-submodules --refresh &&\n-\t\tgit diff-files --quiet --ignore-submodules || {\n-\t\t\techo \"You must edit all merge conflicts and then\"\n-\t\t\techo \"mark them as resolved using git add\"\n-\t\t\texit 1\n-\t\t}\n-\t\tread_state\n-\t\tif test -d \"$merge_dir\"\n-\t\tthen\n-\t\t\tcontinue_merge\n-\t\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\t\tdo\n-\t\t\t\tcall_merge \"$msgnum\"\n-\t\t\t\tcontinue_merge\n-\t\t\tdone\n-\t\t\tfinish_rb_merge\n-\t\t\texit\n-\t\tfi\n-\t\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n-\t\tmove_to_original_branch\n-\t\texit\n-\t\t;;\n-\t--skip)\n-\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\n-\t\tgit reset --hard HEAD || exit $?\n-\t\tread_state\n-\t\tif test -d \"$merge_dir\"\n-\t\tthen\n-\t\t\tgit rerere clear\n-\t\t\tmsgnum=$(($msgnum + 1))\n-\t\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\t\tdo\n-\t\t\t\tcall_merge \"$msgnum\"\n-\t\t\t\tcontinue_merge\n-\t\t\tdone\n-\t\t\tfinish_rb_merge\n-\t\t\texit\n-\t\tfi\n-\t\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n-\t\tmove_to_original_branch\n-\t\texit\n-\t\t;;\n-\t--abort)\n-\t\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\n-\t\tgit rerere clear\n-\t\tread_state\n-\t\tcase \"$head_name\" in\n-\t\trefs/*)\n-\t\t\tgit symbolic-ref HEAD $head_name ||\n-\t\t\tdie \"Could not move back to $head_name\"\n-\t\t\t;;\n-\t\tesac\n-\t\tgit reset --hard $orig_head\n-\t\trm -r \"$state_dir\"\n-\t\texit\n+\t--continue|--skip|--abort)\n+\t\taction=${1##--}\n+\t\tshift\n+\t\tbreak\n \t\t;;\n \t--onto)\n \t\ttest 2 -le \"$#\" || usage\n@@ -391,6 +337,66 @@ do\n done\n test $# -gt 2 && usage\n \n+test -n \"$action\" && test -z \"$in_progress\" && die \"No rebase in progress?\"\n+\n+case \"$action\" in\n+continue)\n+\tgit update-index --ignore-submodules --refresh &&\n+\tgit diff-files --quiet --ignore-submodules || {\n+\t\techo \"You must edit all merge conflicts and then\"\n+\t\techo \"mark them as resolved using git add\"\n+\t\texit 1\n+\t}\n+\tread_state\n+\tif test -d \"$merge_dir\"\n+\tthen\n+\t\tcontinue_merge\n+\t\twhile test \"$msgnum\" -le \"$end\"\n+\t\tdo\n+\t\t\tcall_merge \"$msgnum\"\n+\t\t\tcontinue_merge\n+\t\tdone\n+\t\tfinish_rb_merge\n+\t\texit\n+\tfi\n+\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+skip)\n+\tgit reset --hard HEAD || exit $?\n+\tread_state\n+\tif test -d \"$merge_dir\"\n+\tthen\n+\t\tgit rerere clear\n+\t\tmsgnum=$(($msgnum + 1))\n+\t\twhile test \"$msgnum\" -le \"$end\"\n+\t\tdo\n+\t\t\tcall_merge \"$msgnum\"\n+\t\t\tcontinue_merge\n+\t\tdone\n+\t\tfinish_rb_merge\n+\t\texit\n+\tfi\n+\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+abort)\n+\tgit rerere clear\n+\tread_state\n+\tcase \"$head_name\" in\n+\trefs/*)\n+\t\tgit symbolic-ref HEAD $head_name ||\n+\t\tdie \"Could not move back to $head_name\"\n+\t\t;;\n+\tesac\n+\tgit reset --hard $orig_head\n+\trm -r \"$state_dir\"\n+\texit\n+\t;;\n+esac\n+\n # Make sure no rebase is in progress\n if test -n \"$in_progress\"\n then\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160518","messageId":"1297017841-20678-8-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 07/31] rebase: stricter check of standalone sub command","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:36Z","receivedAt":"2011-02-06T18:43:36Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The sub commands '--continue', '--skip' or '--abort' may only be used\nstandalone according to the documentation. Other options following the\nsub command are currently not accepted, but options preceeding them\nare. For example, 'git rebase --continue -v' is not accepted, while\n'git rebase -v --continue' is. Tighten up the check and allow no other\noptions when one of these sub commands are used.\n\nOnly check that it is standalone for non-interactive rebase for\nnow. Once the command line processing for interactive rebase has been\nreplaced by the command line processing in git-rebase.sh, this check\nwill also apply to interactive rebase.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nIs this too simplistic? Do we forsee that we want to support passing\noptions when resuming a rebase? Is it better to check for each other\noption that it is not passed (i.e. no '-v', no '-s' etc.)?\n\nMight some users be depending on the current behavior, even though it\nis undocumented?\n\n\n git-rebase.sh              |    4 ++--\n t/t3403-rebase-skip.sh     |    5 +++++\n t/t3407-rebase-abort.sh    |   10 ++++++++++\n t/t3418-rebase-continue.sh |    5 +++++\n 4 files changed, 22 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex e3fd001..d689aad 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -229,6 +229,7 @@ then\n fi\n test -n \"$type\" && in_progress=t\n \n+total_argc=$#\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -239,9 +240,8 @@ do\n \t\tOK_TO_SKIP_PRE_REBASE=\n \t\t;;\n \t--continue|--skip|--abort)\n+\t\ttest $total_argc -eq 1 || usage\n \t\taction=${1##--}\n-\t\tshift\n-\t\tbreak\n \t\t;;\n \t--onto)\n \t\ttest 2 -le \"$#\" || usage\ndiff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh\nindex 64446e3..826500b 100755\n--- a/t/t3403-rebase-skip.sh\n+++ b/t/t3403-rebase-skip.sh\n@@ -35,6 +35,11 @@ test_expect_success 'rebase with git am -3 (default)' '\n \ttest_must_fail git rebase master\n '\n \n+test_expect_success 'rebase --skip can not be used with other options' '\n+\ttest_must_fail git rebase -v --skip &&\n+\ttest_must_fail git rebase --skip -v\n+'\n+\n test_expect_success 'rebase --skip with am -3' '\n \tgit rebase --skip\n \t'\ndiff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh\nindex e573dc8..a6a6c40 100755\n--- a/t/t3407-rebase-abort.sh\n+++ b/t/t3407-rebase-abort.sh\n@@ -84,6 +84,16 @@ testrebase() {\n \t\ttest_cmp reflog_before reflog_after &&\n \t\trm reflog_before reflog_after\n \t'\n+\n+\ttest_expect_success 'rebase --abort can not be used with other options' '\n+\t\tcd \"$work_dir\" &&\n+\t\t# Clean up the state from the previous one\n+\t\tgit reset --hard pre-rebase &&\n+\t\ttest_must_fail git rebase$type master &&\n+\t\ttest_must_fail git rebase -v --abort &&\n+\t\ttest_must_fail git rebase --abort -v &&\n+\t\tgit rebase --abort\n+\t'\n }\n \n testrebase \"\" .git/rebase-apply\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 3b0d273..1d90191 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -40,4 +40,9 @@ test_expect_success 'non-interactive rebase --continue works with touched file'\n \tgit rebase --continue\n '\n \n+test_expect_success 'rebase --continue can not be used with other options' '\n+\ttest_must_fail git rebase -v --continue &&\n+\ttest_must_fail git rebase --continue -v\n+'\n+\n test_done\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160514","messageId":"1297017841-20678-9-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 08/31] rebase: align variable names","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:37Z","receivedAt":"2011-02-06T18:43:37Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"git-rebase--interactive.sh will soon be sourced from\ngit-rebase.sh. Align the names of variables used in these scripts to\nprepare for that.\n\nSome names in git-rebase--interactive.sh, such as \"author_script\" and\n\"amend\", are currently used in their upper case form to refer to a\nfile and in their lower case form to refer to something else. In these\ncases, change the name of the existing lower case variable and\ndowncase the name of the variable that refers to the file.\n\nCurrently, git-rebase.sh uses mostly lower case variable names, while\ngit-rebase--interactive.sh uses mostly upper case variable names. For\nconsistency, downcase all variables, not just the ones that will be\nshared between the two script files.\n\nHelped-by: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nChanges since v1:\n\n * As suggested by Thomas, downcase *all* variables, so that the end\n   result looks consistent.\n\n git-rebase--interactive.sh |  480 ++++++++++++++++++++++----------------------\n git-rebase.sh              |   32 ++--\n 2 files changed, 256 insertions(+), 256 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 824f4f3..2fa348b 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -36,22 +36,22 @@ autosquash         move commits that begin with squash!/fixup! under -i\n . git-sh-setup\n require_work_tree\n \n-DOTEST=\"$GIT_DIR/rebase-merge\"\n+dotest=\"$GIT_DIR/rebase-merge\"\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=\"$DOTEST\"/git-rebase-todo\n+# file and written to the tail of $done.\n+todo=\"$dotest\"/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=\"$DOTEST\"/done\n+done=\"$dotest\"/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=\"$DOTEST\"/message\n+msg=\"$dotest\"/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@@ -61,34 +61,34 @@ MSG=\"$DOTEST\"/message\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+#     # 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=\"$DOTEST\"/message-squash\n+squash_msg=\"$dotest\"/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=\"$DOTEST\"/message-fixup\n+fixup_msg=\"$dotest\"/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+# $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=\"$DOTEST\"/rewritten\n+rewritten=\"$dotest\"/rewritten\n \n-DROPPED=\"$DOTEST\"/dropped\n+dropped=\"$dotest\"/dropped\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=\"$DOTEST\"/author-script\n+author_script=\"$dotest\"/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@@ -96,24 +96,24 @@ AUTHOR_SCRIPT=\"$DOTEST\"/author-script\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=\"$DOTEST\"/amend\n+amend=\"$dotest\"/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=\"$DOTEST\"/rewritten-list\n-REWRITTEN_PENDING=\"$DOTEST\"/rewritten-pending\n-\n-PRESERVE_MERGES=\n-STRATEGY=\n-ONTO=\n-VERBOSE=\n-OK_TO_SKIP_PRE_REBASE=\n-REBASE_ROOT=\n-AUTOSQUASH=\n-test \"$(git config --bool rebase.autosquash)\" = \"true\" && AUTOSQUASH=t\n-NEVER_FF=\n+rewritten_list=\"$dotest\"/rewritten-list\n+rewritten_pending=\"$dotest\"/rewritten-pending\n+\n+preserve_merges=\n+strategy=\n+onto=\n+verbose=\n+ok_to_skip_pre_rebase=\n+rebase_root=\n+autosquash=\n+test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n+force_rebase=\n \n GIT_CHERRY_PICK_HELP=\"\\\n hint: after resolving the conflicts, mark the corrected paths\n@@ -125,7 +125,7 @@ warn () {\n }\n \n output () {\n-\tcase \"$VERBOSE\" in\n+\tcase \"$verbose\" in\n \t'')\n \t\toutput=$(\"$@\" 2>&1 )\n \t\tstatus=$?\n@@ -144,7 +144,7 @@ commit_message () {\n }\n \n run_pre_rebase_hook () {\n-\tif test -z \"$OK_TO_SKIP_PRE_REBASE\" &&\n+\tif test -z \"$ok_to_skip_pre_rebase\" &&\n \t   test -x \"$GIT_DIR/hooks/pre-rebase\"\n \tthen\n \t\t\"$GIT_DIR/hooks/pre-rebase\" ${1+\"$@\"} || {\n@@ -155,10 +155,10 @@ run_pre_rebase_hook () {\n }\n \n \n-ORIG_REFLOG_ACTION=\"$GIT_REFLOG_ACTION\"\n+orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n-\tcase \"$ORIG_REFLOG_ACTION\" in\n+\tcase \"$orig_reflog_action\" in\n \t''|rebase*)\n \t\tGIT_REFLOG_ACTION=\"rebase -i ($1)\"\n \t\texport GIT_REFLOG_ACTION\n@@ -168,16 +168,16 @@ comment_for_reflog () {\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-\tcount=$(sane_grep -c '^[^#]' < \"$DONE\")\n-\ttotal=$(($count+$(sane_grep -c '^[^#]' < \"$TODO\")))\n-\tif test \"$last_count\" != \"$count\"\n+\tsed -e 1q < \"$todo\" >> \"$done\"\n+\tsed -e 1d < \"$todo\" >> \"$todo\".new\n+\tmv -f \"$todo\".new \"$todo\"\n+\tnew_count=$(sane_grep -c '^[^#]' < \"$done\")\n+\ttotal=$(($new_count+$(sane_grep -c '^[^#]' < \"$todo\")))\n+\tif test \"$last_count\" != \"$new_count\"\n \tthen\n-\t\tlast_count=$count\n-\t\tprintf \"Rebasing (%d/%d)\\r\" $count $total\n-\t\ttest -z \"$VERBOSE\" || echo\n+\t\tlast_count=$new_count\n+\t\tprintf \"Rebasing (%d/%d)\\r\" $new_count $total\n+\t\ttest -z \"$verbose\" || echo\n \tfi\n }\n \n@@ -193,22 +193,22 @@ make_patch () {\n \t*)\n \t\techo \"Root commit\"\n \t\t;;\n-\tesac > \"$DOTEST\"/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+\tesac > \"$dotest\"/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\" > \"$DOTEST\"/stopped-sha\n+\techo \"$1\" > \"$dotest\"/stopped-sha\n \tmake_patch \"$1\"\n \tgit rerere\n \tdie \"$2\"\n }\n \n die_abort () {\n-\trm -rf \"$DOTEST\"\n+\trm -rf \"$dotest\"\n \tdie \"$1\"\n }\n \n@@ -228,11 +228,11 @@ do_with_author () {\n pick_one () {\n \tff=--ff\n \tcase \"$1\" in -n) sha1=$2; ff= ;; *) sha1=$1 ;; esac\n-\tcase \"$NEVER_FF\" in '') ;; ?*) ff= ;; esac\n+\tcase \"$force_rebase\" in '') ;; ?*) ff= ;; esac\n \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n-\ttest -d \"$REWRITTEN\" &&\n+\ttest -d \"$rewritten\" &&\n \t\tpick_one_preserving_merges \"$@\" && return\n-\tif test -n \"$REBASE_ROOT\"\n+\tif test -n \"$rebase_root\"\n \tthen\n \t\toutput git cherry-pick \"$@\"\n \t\treturn\n@@ -253,20 +253,20 @@ pick_one_preserving_merges () {\n \tesac\n \tsha1=$(git rev-parse $sha1)\n \n-\tif test -f \"$DOTEST\"/current-commit\n+\tif test -f \"$dotest\"/current-commit\n \tthen\n \t\tif test \"$fast_forward\" = t\n \t\tthen\n \t\t\twhile read current_commit\n \t\t\tdo\n-\t\t\t\tgit rev-parse HEAD > \"$REWRITTEN\"/$current_commit\n-\t\t\tdone <\"$DOTEST\"/current-commit\n-\t\t\trm \"$DOTEST\"/current-commit ||\n+\t\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n+\t\t\tdone <\"$dotest\"/current-commit\n+\t\t\trm \"$dotest\"/current-commit ||\n \t\t\tdie \"Cannot write current commit's replacement sha1\"\n \t\tfi\n \tfi\n \n-\techo $sha1 >> \"$DOTEST\"/current-commit\n+\techo $sha1 >> \"$dotest\"/current-commit\n \n \t# rewrite parents; if none were rewritten, we can fast-forward.\n \tnew_parents=\n@@ -280,9 +280,9 @@ pick_one_preserving_merges () {\n \t\tp=$(expr \"$pend\" : ' \\([^ ]*\\)')\n \t\tpend=\"${pend# $p}\"\n \n-\t\tif test -f \"$REWRITTEN\"/$p\n+\t\tif test -f \"$rewritten\"/$p\n \t\tthen\n-\t\t\tnew_p=$(cat \"$REWRITTEN\"/$p)\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@@ -301,10 +301,10 @@ pick_one_preserving_merges () {\n \t\t\t\t;;\n \t\t\tesac\n \t\telse\n-\t\t\tif test -f \"$DROPPED\"/$p\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\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@@ -333,18 +333,18 @@ pick_one_preserving_merges () {\n \t\t\ttest \"a$1\" = a-n && die \"Refusing to squash a merge: $sha1\"\n \n \t\t\t# redo merge\n-\t\t\tauthor_script=$(get_author_ident_from_commit $sha1)\n-\t\t\teval \"$author_script\"\n-\t\t\tmsg=\"$(commit_message $sha1)\"\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\tif ! do_with_author output \\\n-\t\t\t\tgit merge $STRATEGY -m \"$msg\" $new_parents\n+\t\t\t\tgit merge $strategy -m \"$msg_content\" $new_parents\n \t\t\tthen\n-\t\t\t\tprintf \"%s\\n\" \"$msg\" > \"$GIT_DIR\"/MERGE_MSG\n+\t\t\t\tprintf \"%s\\n\" \"$msg_content\" > \"$GIT_DIR\"/MERGE_MSG\n \t\t\t\tdie_with_patch $sha1 \"Error redoing merge $sha1\"\n \t\t\tfi\n-\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$REWRITTEN_LIST\"\n+\t\t\techo \"$sha1 $(git rev-parse HEAD^0)\" >> \"$rewritten_list\"\n \t\t\t;;\n \t\t*)\n \t\t\toutput git cherry-pick \"$@\" ||\n@@ -365,46 +365,46 @@ nth_string () {\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+\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/^# This is a combination of \\(.*\\) commits\\./\\1/p\" \\\n-\t\t\t-e \"q\" < \"$SQUASH_MSG\".bak)+1))\n+\t\t\t-e \"q\" < \"$squash_msg\".bak)+1))\n \t\t{\n-\t\t\techo \"# This is a combination of $COUNT commits.\"\n+\t\t\techo \"# This is a combination of $count commits.\"\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+\t\t\t}' <\"$squash_msg\".bak\n+\t\t} >\"$squash_msg\"\n \telse\n-\t\tcommit_message HEAD > \"$FIXUP_MSG\" || die \"Cannot write $FIXUP_MSG\"\n-\t\tCOUNT=2\n+\t\tcommit_message HEAD > \"$fixup_msg\" || die \"Cannot write $fixup_msg\"\n+\t\tcount=2\n \t\t{\n \t\t\techo \"# This is a combination of 2 commits.\"\n \t\t\techo \"# The first commit's message is:\"\n \t\t\techo\n-\t\t\tcat \"$FIXUP_MSG\"\n-\t\t} >\"$SQUASH_MSG\"\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\trm -f \"$fixup_msg\"\n \t\techo\n-\t\techo \"# This is the $(nth_string $COUNT) commit message:\"\n+\t\techo \"# This is the $(nth_string $count) commit message:\"\n \t\techo\n \t\tcommit_message $2\n \t\t;;\n \tfixup)\n \t\techo\n-\t\techo \"# The $(nth_string $COUNT) commit message will be skipped:\"\n+\t\techo \"# The $(nth_string $count) commit message will be skipped:\"\n \t\techo\n \t\tcommit_message $2 | sed -e 's/^/#\t/'\n \t\t;;\n-\tesac >>\"$SQUASH_MSG\"\n+\tesac >>\"$squash_msg\"\n }\n \n peek_next_command () {\n-\tsed -n -e \"/^#/d\" -e '/^$/d' -e \"s/ .*//p\" -e \"q\" < \"$TODO\"\n+\tsed -n -e \"/^#/d\" -e '/^$/d' -e \"s/ .*//p\" -e \"q\" < \"$todo\"\n }\n \n # A squash/fixup has failed.  Prepare the long version of the squash\n@@ -414,24 +414,24 @@ peek_next_command () {\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-\tmv \"$SQUASH_MSG\" \"$MSG\" || exit\n-\trm -f \"$FIXUP_MSG\"\n-\tcp \"$MSG\" \"$GIT_DIR\"/MERGE_MSG || exit\n+\tmv \"$squash_msg\" \"$msg\" || exit\n+\trm -f \"$fixup_msg\"\n+\tcp \"$msg\" \"$GIT_DIR\"/MERGE_MSG || exit\n \twarn\n \twarn \"Could not apply $1... $2\"\n \tdie_with_patch $1 \"\"\n }\n \n flush_rewritten_pending() {\n-\ttest -s \"$REWRITTEN_PENDING\" || return\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+\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+\techo \"$oldsha1\" >> \"$rewritten_pending\"\n \n \tcase \"$(peek_next_command)\" in\n \tsquash|s|fixup|f)\n@@ -443,8 +443,8 @@ record_in_rewritten() {\n }\n \n do_next () {\n-\trm -f \"$MSG\" \"$AUTHOR_SCRIPT\" \"$AMEND\" || exit\n-\tread -r command sha1 rest < \"$TODO\"\n+\trm -f \"$msg\" \"$author_script\" \"$amend\" || exit\n+\tread -r command sha1 rest < \"$todo\"\n \tcase \"$command\" in\n \t'#'*|''|noop)\n \t\tmark_action_done\n@@ -472,9 +472,9 @@ do_next () {\n \t\tmark_action_done\n \t\tpick_one $sha1 ||\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n-\t\techo \"$sha1\" > \"$DOTEST\"/stopped-sha\n+\t\techo \"$sha1\" > \"$dotest\"/stopped-sha\n \t\tmake_patch $sha1\n-\t\tgit rev-parse --verify HEAD > \"$AMEND\"\n+\t\tgit rev-parse --verify HEAD > \"$amend\"\n \t\twarn \"Stopped at $sha1... $rest\"\n \t\twarn \"You can amend the commit now, with\"\n \t\twarn\n@@ -497,47 +497,47 @@ do_next () {\n \t\tesac\n \t\tcomment_for_reflog $squash_style\n \n-\t\ttest -f \"$DONE\" && has_action \"$DONE\" ||\n+\t\ttest -f \"$done\" && has_action \"$done\" ||\n \t\t\tdie \"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=$(get_author_ident_from_commit HEAD)\n-\t\techo \"$author_script\" > \"$AUTHOR_SCRIPT\"\n-\t\teval \"$author_script\"\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\toutput git reset --soft HEAD^\n \t\tpick_one -n $sha1 || die_failed_squash $sha1 \"$rest\"\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 --no-verify -F \"$SQUASH_MSG\" ||\n+\t\t\tdo_with_author output git commit --no-verify -F \"$squash_msg\" ||\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\tif test -f \"$fixup_msg\"\n \t\t\tthen\n-\t\t\t\tdo_with_author git commit --no-verify -F \"$FIXUP_MSG\" ||\n+\t\t\t\tdo_with_author git commit --no-verify -F \"$fixup_msg\" ||\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\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 --no-verify -e ||\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\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\tread -r command rest < \"$todo\"\n \t\tmark_action_done\n \t\tprintf 'Executing: %s\\n' \"$rest\"\n \t\t# \"exec\" command doesn't take a sha1 in the todo-list.\n \t\t# => can't just use $sha1 here.\n-\t\tgit rev-parse --verify HEAD > \"$DOTEST\"/stopped-sha\n+\t\tgit rev-parse --verify HEAD > \"$dotest\"/stopped-sha\n \t\t${SHELL:-@SHELL_PATH@} -c \"$rest\" # Actual execution\n \t\tstatus=$?\n \t\tif test \"$status\" -ne 0\n@@ -563,42 +563,42 @@ do_next () {\n \t\twarn \"Unknown command: $command $sha1 $rest\"\n \t\tif git rev-parse --verify -q \"$sha1\" >/dev/null\n \t\tthen\n-\t\t\tdie_with_patch $sha1 \"Please fix this in the file $TODO.\"\n+\t\t\tdie_with_patch $sha1 \"Please fix this in the file $todo.\"\n \t\telse\n-\t\t\tdie \"Please fix this in the file $TODO.\"\n+\t\t\tdie \"Please fix this in the file $todo.\"\n \t\tfi\n \t\t;;\n \tesac\n-\ttest -s \"$TODO\" && return\n+\ttest -s \"$todo\" && return\n \n \tcomment_for_reflog finish &&\n-\tHEADNAME=$(cat \"$DOTEST\"/head-name) &&\n-\tOLDHEAD=$(cat \"$DOTEST\"/head) &&\n-\tSHORTONTO=$(git rev-parse --short $(cat \"$DOTEST\"/onto)) &&\n-\tNEWHEAD=$(git rev-parse HEAD) &&\n-\tcase $HEADNAME in\n+\theadname=$(cat \"$dotest\"/head-name) &&\n+\toldhead=$(cat \"$dotest\"/head) &&\n+\tshortonto=$(git rev-parse --short $(cat \"$dotest\"/onto)) &&\n+\tnewhead=$(git rev-parse HEAD) &&\n+\tcase $headname in\n \trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO\" &&\n-\t\tgit update-ref -m \"$message\" $HEADNAME $NEWHEAD $OLDHEAD &&\n-\t\tgit symbolic-ref HEAD $HEADNAME\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $headname onto $shortonto\" &&\n+\t\tgit update-ref -m \"$message\" $headname $newhead $oldhead &&\n+\t\tgit symbolic-ref HEAD $headname\n \t\t;;\n \tesac && {\n-\t\ttest ! -f \"$DOTEST\"/verbose ||\n-\t\t\tgit diff-tree --stat $(cat \"$DOTEST\"/head)..HEAD\n+\t\ttest ! -f \"$dotest\"/verbose ||\n+\t\t\tgit diff-tree --stat $(cat \"$dotest\"/head)..HEAD\n \t} &&\n \t{\n-\t\ttest -s \"$REWRITTEN_LIST\" &&\n-\t\tgit notes copy --for-rewrite=rebase < \"$REWRITTEN_LIST\" ||\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 \tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n-\t\ttest -s \"$REWRITTEN_LIST\"; then\n-\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$REWRITTEN_LIST\"\n+\t\ttest -s \"$rewritten_list\"; then\n+\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$rewritten_list\"\n \t\ttrue # we don't care if this hook failed\n \tfi &&\n-\trm -rf \"$DOTEST\" &&\n+\trm -rf \"$dotest\" &&\n \tgit gc --auto &&\n-\twarn \"Successfully rebased and updated $HEADNAME.\"\n+\twarn \"Successfully rebased and updated $headname.\"\n \n \texit\n }\n@@ -618,11 +618,11 @@ skip_unnecessary_picks () {\n \t\t# fd=3 means we skip the command\n \t\tcase \"$fd,$command\" in\n \t\t3,pick|3,p)\n-\t\t\t# pick a commit whose parent is current $ONTO -> skip\n+\t\t\t# pick a commit whose parent is current $onto -> skip\n \t\t\tsha1=${rest%% *}\n \t\t\tcase \"$(git rev-parse --verify --quiet \"$sha1\"^)\" in\n-\t\t\t\"$ONTO\"*)\n-\t\t\t\tONTO=$sha1\n+\t\t\t\"$onto\"*)\n+\t\t\t\tonto=$sha1\n \t\t\t\t;;\n \t\t\t*)\n \t\t\t\tfd=1\n@@ -637,11 +637,11 @@ skip_unnecessary_picks () {\n \t\t\t;;\n \t\tesac\n \t\tprintf '%s\\n' \"$command${rest:+ }$rest\" >&$fd\n-\tdone <\"$TODO\" >\"$TODO.new\" 3>>\"$DONE\" &&\n-\tmv -f \"$TODO\".new \"$TODO\" &&\n+\tdone <\"$todo\" >\"$todo.new\" 3>>\"$done\" &&\n+\tmv -f \"$todo\".new \"$todo\" &&\n \tcase \"$(peek_next_command)\" in\n \tsquash|s|fixup|f)\n-\t\trecord_in_rewritten \"$ONTO\"\n+\t\trecord_in_rewritten \"$onto\"\n \t\t;;\n \tesac ||\n \tdie \"Could not skip unnecessary pick commands\"\n@@ -650,17 +650,17 @@ skip_unnecessary_picks () {\n # check if no other options are set\n is_standalone () {\n \ttest $# -eq 2 -a \"$2\" = '--' &&\n-\ttest -z \"$ONTO\" &&\n-\ttest -z \"$PRESERVE_MERGES\" &&\n-\ttest -z \"$STRATEGY\" &&\n-\ttest -z \"$VERBOSE\"\n+\ttest -z \"$onto\" &&\n+\ttest -z \"$preserve_merges\" &&\n+\ttest -z \"$strategy\" &&\n+\ttest -z \"$verbose\"\n }\n \n get_saved_options () {\n-\ttest -d \"$REWRITTEN\" && PRESERVE_MERGES=t\n-\ttest -f \"$DOTEST\"/strategy && STRATEGY=\"$(cat \"$DOTEST\"/strategy)\"\n-\ttest -f \"$DOTEST\"/verbose && VERBOSE=t\n-\ttest -f \"$DOTEST\"/rebase-root && REBASE_ROOT=t\n+\ttest -d \"$rewritten\" && preserve_merges=t\n+\ttest -f \"$dotest\"/strategy && strategy=\"$(cat \"$dotest\"/strategy)\"\n+\ttest -f \"$dotest\"/verbose && verbose=t\n+\ttest -f \"$dotest\"/rebase-root && rebase_root=t\n }\n \n # Rearrange the todo list that has both \"pick sha1 msg\" and\n@@ -699,7 +699,7 @@ rearrange_squash () {\n \t\tesac\n \t\tprintf '%s\\n' \"$pick $sha1 $message\"\n \t\tused=\"$used$sha1 \"\n-\t\twhile read -r squash action msg\n+\t\twhile read -r squash action msg_content\n \t\tdo\n \t\t\tcase \" $used\" in\n \t\t\t*\" $squash \"*) continue ;;\n@@ -709,13 +709,13 @@ rearrange_squash () {\n \t\t\t+*)\n \t\t\t\taction=\"${action#+}\"\n \t\t\t\t# full sha1 prefix test\n-\t\t\t\tcase \"$msg\" in \"$sha1\"*) emit=1;; esac ;;\n+\t\t\t\tcase \"$msg_content\" in \"$sha1\"*) emit=1;; esac ;;\n \t\t\t*)\n \t\t\t\t# message prefix test\n-\t\t\t\tcase \"$message\" in \"$msg\"*) emit=1;; esac ;;\n+\t\t\t\tcase \"$message\" in \"$msg_content\"*) emit=1;; esac ;;\n \t\t\tesac\n \t\t\tif test $emit = 1; then\n-\t\t\t\tprintf '%s\\n' \"$action $squash $action! $msg\"\n+\t\t\t\tprintf '%s\\n' \"$action $squash $action! $msg_content\"\n \t\t\t\tused=\"$used$squash \"\n \t\t\tfi\n \t\tdone <\"$1.sq\"\n@@ -747,17 +747,17 @@ while test $# != 0\n do\n \tcase \"$1\" in\n \t--no-verify)\n-\t\tOK_TO_SKIP_PRE_REBASE=yes\n+\t\tok_to_skip_pre_rebase=yes\n \t\t;;\n \t--verify)\n-\t\tOK_TO_SKIP_PRE_REBASE=\n+\t\tok_to_skip_pre_rebase=\n \t\t;;\n \t--continue)\n \t\tis_standalone \"$@\" || usage\n \t\tget_saved_options\n \t\tcomment_for_reflog continue\n \n-\t\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n+\t\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n \n \t\t# Sanity check\n \t\tgit rev-parse --verify HEAD >/dev/null ||\n@@ -771,26 +771,26 @@ do\n \t\tthen\n \t\t\t: Nothing to commit -- skip this\n \t\telse\n-\t\t\t. \"$AUTHOR_SCRIPT\" ||\n+\t\t\t. \"$author_script\" ||\n \t\t\t\tdie \"Cannot find the author identity\"\n-\t\t\tamend=\n-\t\t\tif test -f \"$AMEND\"\n+\t\t\tcurrent_head=\n+\t\t\tif test -f \"$amend\"\n \t\t\tthen\n-\t\t\t\tamend=$(git rev-parse --verify HEAD)\n-\t\t\t\ttest \"$amend\" = $(cat \"$AMEND\") ||\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 \"\\\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\tgit reset --soft HEAD^ ||\n \t\t\t\tdie \"Cannot rewind the HEAD\"\n \t\t\tfi\n-\t\t\tdo_with_author git commit --no-verify -F \"$MSG\" -e || {\n-\t\t\t\ttest -n \"$amend\" && git reset --soft $amend\n+\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e || {\n+\t\t\t\ttest -n \"$current_head\" && git reset --soft $current_head\n \t\t\t\tdie \"Could not commit staged changes.\"\n \t\t\t}\n \t\tfi\n \n-\t\trecord_in_rewritten \"$(cat \"$DOTEST\"/stopped-sha)\"\n+\t\trecord_in_rewritten \"$(cat \"$dotest\"/stopped-sha)\"\n \n \t\trequire_clean_work_tree \"rebase\"\n \t\tdo_rest\n@@ -801,17 +801,17 @@ first and then run 'git rebase --continue' again.\"\n \t\tcomment_for_reflog abort\n \n \t\tgit rerere clear\n-\t\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n+\t\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n \n-\t\tHEADNAME=$(cat \"$DOTEST\"/head-name)\n-\t\tHEAD=$(cat \"$DOTEST\"/head)\n-\t\tcase $HEADNAME in\n+\t\theadname=$(cat \"$dotest\"/head-name)\n+\t\thead=$(cat \"$dotest\"/head)\n+\t\tcase $headname in\n \t\trefs/*)\n-\t\t\tgit symbolic-ref HEAD $HEADNAME\n+\t\t\tgit symbolic-ref HEAD $headname\n \t\t\t;;\n \t\tesac &&\n-\t\toutput git reset --hard $HEAD &&\n-\t\trm -rf \"$DOTEST\"\n+\t\toutput git reset --hard $head &&\n+\t\trm -rf \"$dotest\"\n \t\texit\n \t\t;;\n \t--skip)\n@@ -820,18 +820,18 @@ first and then run 'git rebase --continue' again.\"\n \t\tcomment_for_reflog skip\n \n \t\tgit rerere clear\n-\t\ttest -d \"$DOTEST\" || die \"No interactive rebase running\"\n+\t\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n \n \t\toutput git reset --hard && do_rest\n \t\t;;\n \t-s)\n \t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t\tSTRATEGY=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n+\t\t\tstrategy=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n \t\t1,*)\n \t\t\tusage ;;\n \t\t*)\n-\t\t\tSTRATEGY=\"-s $2\"\n+\t\t\tstrategy=\"-s $2\"\n \t\t\tshift ;;\n \t\tesac\n \t\t;;\n@@ -839,29 +839,29 @@ first and then run 'git rebase --continue' again.\"\n \t\t# we use merge anyway\n \t\t;;\n \t-v)\n-\t\tVERBOSE=t\n+\t\tverbose=t\n \t\t;;\n \t-p)\n-\t\tPRESERVE_MERGES=t\n+\t\tpreserve_merges=t\n \t\t;;\n \t-i)\n \t\t# yeah, we know\n \t\t;;\n \t--no-ff)\n-\t\tNEVER_FF=t\n+\t\tforce_rebase=t\n \t\t;;\n \t--root)\n-\t\tREBASE_ROOT=t\n+\t\trebase_root=t\n \t\t;;\n \t--autosquash)\n-\t\tAUTOSQUASH=t\n+\t\tautosquash=t\n \t\t;;\n \t--no-autosquash)\n-\t\tAUTOSQUASH=\n+\t\tautosquash=\n \t\t;;\n \t--onto)\n \t\tshift\n-\t\tONTO=$(parse_onto \"$1\") ||\n+\t\tonto=$(parse_onto \"$1\") ||\n \t\t\tdie \"Does not point to a valid commit: $1\"\n \t\t;;\n \t--)\n@@ -872,27 +872,27 @@ first and then run 'git rebase --continue' again.\"\n \tshift\n done\n \n-test -z \"$REBASE_ROOT\" -a $# -ge 1 -a $# -le 2 ||\n-test ! -z \"$REBASE_ROOT\" -a $# -le 1 || usage\n-test -d \"$DOTEST\" &&\n+test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n+test ! -z \"$rebase_root\" -a $# -le 1 || usage\n+test -d \"$dotest\" &&\n \tdie \"Interactive rebase already started\"\n \n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-if test -z \"$REBASE_ROOT\"\n+if test -z \"$rebase_root\"\n then\n-\tUPSTREAM_ARG=\"$1\"\n-\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\ttest -z \"$ONTO\" && ONTO=$UPSTREAM\n+\tupstream_arg=\"$1\"\n+\tupstream=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n+\ttest -z \"$onto\" && onto=$upstream\n \tshift\n else\n-\tUPSTREAM=\n-\tUPSTREAM_ARG=--root\n-\ttest -z \"$ONTO\" &&\n-\tdie \"You must specify --onto when using --root\"\n+\tupstream=\n+\tupstream_arg=--root\n+\ttest -z \"$onto\" &&\n+\t\tdie \"You must specify --onto when using --root\"\n fi\n-run_pre_rebase_hook \"$UPSTREAM_ARG\" \"$@\"\n+run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\n \n@@ -904,76 +904,76 @@ then\n \t\tdie \"Could not checkout $1\"\n fi\n \n-HEAD=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n-mkdir \"$DOTEST\" || die \"Could not create temporary $DOTEST\"\n+head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n+mkdir \"$dotest\" || die \"Could not create temporary $dotest\"\n \n-: > \"$DOTEST\"/interactive || die \"Could not mark as interactive\"\n-git symbolic-ref HEAD > \"$DOTEST\"/head-name 2> /dev/null ||\n-\techo \"detached HEAD\" > \"$DOTEST\"/head-name\n+: > \"$dotest\"/interactive || die \"Could not mark as interactive\"\n+git symbolic-ref HEAD > \"$dotest\"/head-name 2> /dev/null ||\n+\techo \"detached HEAD\" > \"$dotest\"/head-name\n \n-echo $HEAD > \"$DOTEST\"/head\n-case \"$REBASE_ROOT\" in\n+echo $head > \"$dotest\"/head\n+case \"$rebase_root\" in\n '')\n-\trm -f \"$DOTEST\"/rebase-root ;;\n+\trm -f \"$dotest\"/rebase-root ;;\n *)\n-\t: >\"$DOTEST\"/rebase-root ;;\n+\t: >\"$dotest\"/rebase-root ;;\n esac\n-echo $ONTO > \"$DOTEST\"/onto\n-test -z \"$STRATEGY\" || echo \"$STRATEGY\" > \"$DOTEST\"/strategy\n-test t = \"$VERBOSE\" && : > \"$DOTEST\"/verbose\n-if test t = \"$PRESERVE_MERGES\"\n+echo $onto > \"$dotest\"/onto\n+test -z \"$strategy\" || echo \"$strategy\" > \"$dotest\"/strategy\n+test t = \"$verbose\" && : > \"$dotest\"/verbose\n+if test t = \"$preserve_merges\"\n then\n-\tif test -z \"$REBASE_ROOT\"\n+\tif test -z \"$rebase_root\"\n \tthen\n-\t\tmkdir \"$REWRITTEN\" &&\n-\t\tfor c in $(git merge-base --all $HEAD $UPSTREAM)\n+\t\tmkdir \"$rewritten\" &&\n+\t\tfor c in $(git merge-base --all $head $upstream)\n \t\tdo\n-\t\t\techo $ONTO > \"$REWRITTEN\"/$c ||\n+\t\t\techo $onto > \"$rewritten\"/$c ||\n \t\t\t\tdie \"Could not init rewritten commits\"\n \t\tdone\n \telse\n-\t\tmkdir \"$REWRITTEN\" &&\n-\t\techo $ONTO > \"$REWRITTEN\"/root ||\n+\t\tmkdir \"$rewritten\" &&\n+\t\techo $onto > \"$rewritten\"/root ||\n \t\t\tdie \"Could not init rewritten commits\"\n \tfi\n \t# No cherry-pick because our first pass is to determine\n \t# parents to rewrite and skipping dropped commits would\n \t# prematurely end our probe\n-\tMERGES_OPTION=\n-\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $UPSTREAM..$HEAD | head -n 1)\"\n+\tmerges_option=\n+\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $upstream..$head | head -n 1)\"\n else\n-\tMERGES_OPTION=\"--no-merges --cherry-pick\"\n+\tmerges_option=\"--no-merges --cherry-pick\"\n fi\n \n-SHORTHEAD=$(git rev-parse --short $HEAD)\n-SHORTONTO=$(git rev-parse --short $ONTO)\n-if test -z \"$REBASE_ROOT\"\n-\t# this is now equivalent to ! -z \"$UPSTREAM\"\n+shorthead=$(git rev-parse --short $head)\n+shortonto=$(git rev-parse --short $onto)\n+if test -z \"$rebase_root\"\n+\t# this is now equivalent to ! -z \"$upstream\"\n then\n-\tSHORTUPSTREAM=$(git rev-parse --short $UPSTREAM)\n-\tREVISIONS=$UPSTREAM...$HEAD\n-\tSHORTREVISIONS=$SHORTUPSTREAM..$SHORTHEAD\n+\tshortupstream=$(git rev-parse --short $upstream)\n+\trevisions=$upstream...$head\n+\tshortrevisions=$shortupstream..$shorthead\n else\n-\tREVISIONS=$ONTO...$HEAD\n-\tSHORTREVISIONS=$SHORTHEAD\n+\trevisions=$onto...$head\n+\tshortrevisions=$shorthead\n fi\n-git rev-list $MERGES_OPTION --pretty=oneline --abbrev-commit \\\n+git rev-list $merges_option --pretty=oneline --abbrev-commit \\\n \t--abbrev=7 --reverse --left-right --topo-order \\\n-\t$REVISIONS | \\\n+\t$revisions | \\\n \tsed -n \"s/^>//p\" |\n while read -r shortsha1 rest\n do\n-\tif test t != \"$PRESERVE_MERGES\"\n+\tif test t != \"$preserve_merges\"\n \tthen\n-\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$todo\"\n \telse\n \t\tsha1=$(git rev-parse $shortsha1)\n-\t\tif test -z \"$REBASE_ROOT\"\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 -a \\( $p != $ONTO -o $sha1 = $first_after_upstream \\)\n+\t\t\t\tif test -f \"$rewritten\"/$p -a \\( $p != $onto -o $sha1 = $first_after_upstream \\)\n \t\t\t\tthen\n \t\t\t\t\tpreserve=f\n \t\t\t\tfi\n@@ -983,43 +983,43 @@ do\n \t\tfi\n \t\tif test f = \"$preserve\"\n \t\tthen\n-\t\t\ttouch \"$REWRITTEN\"/$sha1\n-\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$TODO\"\n+\t\t\ttouch \"$rewritten\"/$sha1\n+\t\t\tprintf '%s\\n' \"pick $shortsha1 $rest\" >> \"$todo\"\n \t\tfi\n \tfi\n done\n \n # Watch for commits that been dropped by --cherry-pick\n-if test t = \"$PRESERVE_MERGES\"\n+if test t = \"$preserve_merges\"\n then\n-\tmkdir \"$DROPPED\"\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\" > \"$DOTEST\"/not-cherry-picks\n+\tgit rev-list $revisions --left-right --cherry-pick | \\\n+\t\tsed -n \"s/^>//p\" > \"$dotest\"/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+\tgit rev-list $revisions |\n \twhile read rev\n \tdo\n-\t\tif test -f \"$REWRITTEN\"/$rev -a \"$(sane_grep \"$rev\" \"$DOTEST\"/not-cherry-picks)\" = \"\"\n+\t\tif test -f \"$rewritten\"/$rev -a \"$(sane_grep \"$rev\" \"$dotest\"/not-cherry-picks)\" = \"\"\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\tgit rev-list --parents -1 $rev | cut -d' ' -s -f2 > \"$dropped\"/$rev\n \t\t\tshort=$(git rev-list -1 --abbrev-commit --abbrev=7 $rev)\n-\t\t\tsane_grep -v \"^[a-z][a-z]* $short\" <\"$TODO\" > \"${TODO}2\" ; mv \"${TODO}2\" \"$TODO\"\n-\t\t\trm \"$REWRITTEN\"/$rev\n+\t\t\tsane_grep -v \"^[a-z][a-z]* $short\" <\"$todo\" > \"${todo}2\" ; mv \"${todo}2\" \"$todo\"\n+\t\t\trm \"$rewritten\"/$rev\n \t\tfi\n \tdone\n fi\n \n-test -s \"$TODO\" || echo noop >> \"$TODO\"\n-test -n \"$AUTOSQUASH\" && rearrange_squash \"$TODO\"\n-cat >> \"$TODO\" << EOF\n+test -s \"$todo\" || echo noop >> \"$todo\"\n+test -n \"$autosquash\" && rearrange_squash \"$todo\"\n+cat >> \"$todo\" << EOF\n \n-# Rebase $SHORTREVISIONS onto $SHORTONTO\n+# Rebase $shortrevisions onto $shortonto\n #\n # Commands:\n #  p, pick = use commit\n@@ -1034,18 +1034,18 @@ cat >> \"$TODO\" << EOF\n #\n EOF\n \n-has_action \"$TODO\" ||\n+has_action \"$todo\" ||\n \tdie_abort \"Nothing to do\"\n \n-cp \"$TODO\" \"$TODO\".backup\n-git_editor \"$TODO\" ||\n+cp \"$todo\" \"$todo\".backup\n+git_editor \"$todo\" ||\n \tdie_abort \"Could not execute editor\"\n \n-has_action \"$TODO\" ||\n+has_action \"$todo\" ||\n \tdie_abort \"Nothing to do\"\n \n-test -d \"$REWRITTEN\" || test -n \"$NEVER_FF\" || skip_unnecessary_picks\n+test -d \"$rewritten\" || test -n \"$force_rebase\" || skip_unnecessary_picks\n \n-output git checkout $ONTO || die_abort \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $HEAD\n+output git checkout $onto || die_abort \"could not detach HEAD\"\n+git update-ref ORIG_HEAD $head\n do_rest\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d689aad..dfde62f 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -36,13 +36,13 @@ cd_to_toplevel\n \n LF='\n '\n-OK_TO_SKIP_PRE_REBASE=\n-RESOLVEMSG=\"\n+ok_to_skip_pre_rebase=\n+resolvemsg=\"\n When you have resolved this problem run \\\"git rebase --continue\\\".\n If you would prefer to skip this patch, instead run \\\"git rebase --skip\\\".\n To restore the original branch and stop rebasing run \\\"git rebase --abort\\\".\n \"\n-unset newbase\n+unset onto\n strategy=recursive\n strategy_opts=\n do_merge=\n@@ -86,7 +86,7 @@ continue_merge () {\n \tthen\n \t\techo \"You still have unmerged paths in your index\"\n \t\techo \"did you forget to use git add?\"\n-\t\tdie \"$RESOLVEMSG\"\n+\t\tdie \"$resolvemsg\"\n \tfi\n \n \tcmt=`cat \"$merge_dir/current\"`\n@@ -96,7 +96,7 @@ continue_merge () {\n \t\tthen\n \t\t\techo \"Commit failed, please do not call \\\"git commit\\\"\"\n \t\t\techo \"directly, but instead do one of the following: \"\n-\t\t\tdie \"$RESOLVEMSG\"\n+\t\t\tdie \"$resolvemsg\"\n \t\tfi\n \t\tif test -z \"$GIT_QUIET\"\n \t\tthen\n@@ -139,11 +139,11 @@ call_merge () {\n \t\t;;\n \t1)\n \t\tgit rerere $allow_rerere_autoupdate\n-\t\tdie \"$RESOLVEMSG\"\n+\t\tdie \"$resolvemsg\"\n \t\t;;\n \t2)\n \t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n-\t\tdie \"$RESOLVEMSG\"\n+\t\tdie \"$resolvemsg\"\n \t\t;;\n \t*)\n \t\tdie \"Unknown exit code ($rv) from command:\" \\\n@@ -199,7 +199,7 @@ is_interactive () {\n }\n \n run_pre_rebase_hook () {\n-\tif test -z \"$OK_TO_SKIP_PRE_REBASE\" &&\n+\tif test -z \"$ok_to_skip_pre_rebase\" &&\n \t   test -x \"$GIT_DIR/hooks/pre-rebase\"\n \tthen\n \t\t\"$GIT_DIR/hooks/pre-rebase\" ${1+\"$@\"} ||\n@@ -234,10 +234,10 @@ while test $# != 0\n do\n \tcase \"$1\" in\n \t--no-verify)\n-\t\tOK_TO_SKIP_PRE_REBASE=yes\n+\t\tok_to_skip_pre_rebase=yes\n \t\t;;\n \t--verify)\n-\t\tOK_TO_SKIP_PRE_REBASE=\n+\t\tok_to_skip_pre_rebase=\n \t\t;;\n \t--continue|--skip|--abort)\n \t\ttest $total_argc -eq 1 || usage\n@@ -245,7 +245,7 @@ do\n \t\t;;\n \t--onto)\n \t\ttest 2 -le \"$#\" || usage\n-\t\tnewbase=\"$2\"\n+\t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n \t-M|-m|--m|--me|--mer|--merg|--merge)\n@@ -359,7 +359,7 @@ continue)\n \t\tfinish_rb_merge\n \t\texit\n \tfi\n-\tgit am --resolved --3way --resolvemsg=\"$RESOLVEMSG\" &&\n+\tgit am --resolved --3way --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n@@ -378,7 +378,7 @@ skip)\n \t\tfinish_rb_merge\n \t\texit\n \tfi\n-\tgit am -3 --skip --resolvemsg=\"$RESOLVEMSG\" &&\n+\tgit am -3 --skip --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n@@ -425,7 +425,7 @@ then\n \tunset root_flag\n \tupstream_arg=\"$upstream_name\"\n else\n-\ttest -z \"$newbase\" && die \"--root must be used with --onto\"\n+\ttest -z \"$onto\" && die \"--root must be used with --onto\"\n \tunset upstream_name\n \tunset upstream\n \troot_flag=\"--root\"\n@@ -433,7 +433,7 @@ else\n fi\n \n # Make sure the branch to rebase onto is valid.\n-onto_name=${newbase-\"$upstream_name\"}\n+onto_name=${onto-\"$upstream_name\"}\n case \"$onto_name\" in\n *...*)\n \tif\tleft=${onto_name%...*} right=${onto_name#*...} &&\n@@ -554,7 +554,7 @@ then\n \tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n \t\t--src-prefix=a/ --dst-prefix=b/ \\\n \t\t--no-renames $root_flag \"$revisions\" |\n-\tgit am $git_am_opt --rebasing --resolvemsg=\"$RESOLVEMSG\" &&\n+\tgit am $git_am_opt --rebasing --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \tret=$?\n \ttest 0 != $ret -a -d \"$apply_dir\" &&\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160515","messageId":"1297017841-20678-10-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 09/31] rebase: align variable content","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:38Z","receivedAt":"2011-02-06T18:43:38Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Make sure to interpret variables with the same name in the same way in\ngit-rebase.sh and git-rebase--interactive.sh. This will make it easier\nto factor out code from git-rebase.sh to git-rebase--interactive and\nexport the variables.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   16 +++++++++++-----\n git-rebase.sh              |    4 +++-\n 2 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 2fa348b..8b0d7b0 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -339,7 +339,8 @@ pick_one_preserving_merges () {\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\tif ! do_with_author output \\\n-\t\t\t\tgit merge $strategy -m \"$msg_content\" $new_parents\n+\t\t\t\tgit merge ${strategy:+-s $strategy} -m \\\n+\t\t\t\t\t\"$msg_content\" $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 \"Error redoing merge $sha1\"\n@@ -827,11 +828,11 @@ first and then run 'git rebase --continue' again.\"\n \t-s)\n \t\tcase \"$#,$1\" in\n \t\t*,*=*)\n-\t\t\tstrategy=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n+\t\t\tstrategy=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n \t\t1,*)\n \t\t\tusage ;;\n \t\t*)\n-\t\t\tstrategy=\"-s $2\"\n+\t\t\tstrategy=\"$2\"\n \t\t\tshift ;;\n \t\tesac\n \t\t;;\n@@ -860,9 +861,9 @@ first and then run 'git rebase --continue' again.\"\n \t\tautosquash=\n \t\t;;\n \t--onto)\n+\t\ttest 2 -le \"$#\" || usage\n+\t\tonto=\"$2\"\n \t\tshift\n-\t\tonto=$(parse_onto \"$1\") ||\n-\t\t\tdie \"Does not point to a valid commit: $1\"\n \t\t;;\n \t--)\n \t\tshift\n@@ -872,6 +873,11 @@ first and then run 'git rebase --continue' again.\"\n \tshift\n done\n \n+if test -n \"$onto\"\n+then\n+\tonto=$(parse_onto \"$onto\") || die \"Does not point to a valid commit: $1\"\n+fi\n+\n test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n test ! -z \"$rebase_root\" -a $# -le 1 || usage\n test -d \"$dotest\" &&\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex dfde62f..3eac5a4 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -43,7 +43,7 @@ If you would prefer to skip this patch, instead run \\\"git rebase --skip\\\".\n To restore the original branch and stop rebasing run \\\"git rebase --abort\\\".\n \"\n unset onto\n-strategy=recursive\n+strategy=\n strategy_opts=\n do_merge=\n merge_dir=\"$GIT_DIR\"/rebase-merge\n@@ -130,6 +130,7 @@ call_merge () {\n \tthen\n \t\tGIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY\n \tfi\n+\ttest -z \"$strategy\" && strategy=recursive\n \teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n \trv=$?\n \tcase \"$rv\" in\n@@ -267,6 +268,7 @@ do\n \t\tesac\n \t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$newopt\")\"\n \t\tdo_merge=t\n+\t\ttest -z \"$strategy\" && strategy=recursive\n \t\t;;\n \t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n \t\t--strateg=*|--strategy=*|\\\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160538","messageId":"1297017841-20678-11-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 10/31] rebase: factor out command line option processing","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:39Z","receivedAt":"2011-02-06T18:43:39Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Factor out the command line processing in git-rebase--interactive.sh\nto git-rebase.sh. Store the options in variables in git-rebase.sh and\nthen source git-rebase--interactive.sh.\n\nSuggested-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nChanges since v1:\n\n * As suggested by Johannes Sixt, source git-rebase--interactive.sh\n   instead of executing it.\n\nSince this removes the command line processing from\ngit-rebase--interactive.sh, it completely changes its command line\ninterface. Since it is not listed as even a plumbing command, I hope\nthis is fine.\n\n\n git-rebase--interactive.sh |  224 ++++++++++++--------------------------------\n git-rebase.sh              |   58 ++++++++----\n 2 files changed, 100 insertions(+), 182 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 8b0d7b0..9c43c60 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -10,31 +10,7 @@\n # The original idea comes from Eric W. Biederman, in\n # http://article.gmane.org/gmane.comp.version-control.git/22407\n \n-OPTIONS_KEEPDASHDASH=\n-OPTIONS_SPEC=\"\\\n-git-rebase [-i] [options] [--] <upstream> [<branch>]\n-git-rebase [-i] (--continue | --abort | --skip)\n---\n- Available options are\n-v,verbose          display a diffstat of what changed upstream\n-onto=              rebase onto given branch instead of upstream\n-p,preserve-merges  try to recreate merges instead of ignoring them\n-s,strategy=        use the given merge strategy\n-no-ff              cherry-pick all commits, even if unchanged\n-m,merge            always used (no-op)\n-i,interactive      always used (no-op)\n- Actions:\n-continue           continue rebasing process\n-abort              abort rebasing process and restore original branch\n-skip               skip current patch and continue rebasing process\n-no-verify          override pre-rebase hook from stopping the operation\n-verify             allow pre-rebase hook to run\n-root               rebase all reachable commmits up to the root(s)\n-autosquash         move commits that begin with squash!/fixup! under -i\n-\"\n-\n . git-sh-setup\n-require_work_tree\n \n dotest=\"$GIT_DIR/rebase-merge\"\n \n@@ -105,16 +81,6 @@ amend=\"$dotest\"/amend\n rewritten_list=\"$dotest\"/rewritten-list\n rewritten_pending=\"$dotest\"/rewritten-pending\n \n-preserve_merges=\n-strategy=\n-onto=\n-verbose=\n-ok_to_skip_pre_rebase=\n-rebase_root=\n-autosquash=\n-test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n-force_rebase=\n-\n GIT_CHERRY_PICK_HELP=\"\\\n hint: after resolving the conflicts, mark the corrected paths\n hint: with 'git add <paths>' and run 'git rebase --continue'\"\n@@ -648,15 +614,6 @@ skip_unnecessary_picks () {\n \tdie \"Could not skip unnecessary pick commands\"\n }\n \n-# check if no other options are set\n-is_standalone () {\n-\ttest $# -eq 2 -a \"$2\" = '--' &&\n-\ttest -z \"$onto\" &&\n-\ttest -z \"$preserve_merges\" &&\n-\ttest -z \"$strategy\" &&\n-\ttest -z \"$verbose\"\n-}\n-\n get_saved_options () {\n \ttest -d \"$rewritten\" && preserve_merges=t\n \ttest -f \"$dotest\"/strategy && strategy=\"$(cat \"$dotest\"/strategy)\"\n@@ -744,134 +701,77 @@ parse_onto () {\n \tgit rev-parse --verify \"$1^0\"\n }\n \n-while test $# != 0\n-do\n-\tcase \"$1\" in\n-\t--no-verify)\n-\t\tok_to_skip_pre_rebase=yes\n-\t\t;;\n-\t--verify)\n-\t\tok_to_skip_pre_rebase=\n-\t\t;;\n-\t--continue)\n-\t\tis_standalone \"$@\" || usage\n-\t\tget_saved_options\n-\t\tcomment_for_reflog continue\n-\n-\t\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n-\n-\t\t# Sanity check\n-\t\tgit rev-parse --verify HEAD >/dev/null ||\n-\t\t\tdie \"Cannot read HEAD\"\n-\t\tgit update-index --ignore-submodules --refresh &&\n-\t\t\tgit diff-files --quiet --ignore-submodules ||\n-\t\t\tdie \"Working tree is dirty\"\n-\n-\t\t# do we have anything to commit?\n-\t\tif git diff-index --cached --quiet --ignore-submodules HEAD --\n+case \"$action\" in\n+continue)\n+\tget_saved_options\n+\tcomment_for_reflog continue\n+\n+\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n+\n+\t# Sanity check\n+\tgit rev-parse --verify HEAD >/dev/null ||\n+\t\tdie \"Cannot read HEAD\"\n+\tgit update-index --ignore-submodules --refresh &&\n+\t\tgit diff-files --quiet --ignore-submodules ||\n+\t\tdie \"Working tree is dirty\"\n+\n+\t# do we have anything to commit?\n+\tif git diff-index --cached --quiet --ignore-submodules HEAD --\n+\tthen\n+\t\t: Nothing to commit -- skip this\n+\telse\n+\t\t. \"$author_script\" ||\n+\t\t\tdie \"Cannot find the author identity\"\n+\t\tcurrent_head=\n+\t\tif test -f \"$amend\"\n \t\tthen\n-\t\t\t: Nothing to commit -- skip this\n-\t\telse\n-\t\t\t. \"$author_script\" ||\n-\t\t\t\tdie \"Cannot find the author identity\"\n-\t\t\tcurrent_head=\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 \"\\\n+\t\t\tcurrent_head=$(git rev-parse --verify HEAD)\n+\t\t\ttest \"$current_head\" = $(cat \"$amend\") ||\n+\t\t\tdie \"\\\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\tgit reset --soft HEAD^ ||\n-\t\t\t\tdie \"Cannot rewind the HEAD\"\n-\t\t\tfi\n-\t\t\tdo_with_author git commit --no-verify -F \"$msg\" -e || {\n-\t\t\t\ttest -n \"$current_head\" && git reset --soft $current_head\n-\t\t\t\tdie \"Could not commit staged changes.\"\n-\t\t\t}\n+\t\t\tgit reset --soft HEAD^ ||\n+\t\t\tdie \"Cannot rewind the HEAD\"\n \t\tfi\n+\t\tdo_with_author git commit --no-verify -F \"$msg\" -e || {\n+\t\t\ttest -n \"$current_head\" && git reset --soft $current_head\n+\t\t\tdie \"Could not commit staged changes.\"\n+\t\t}\n+\tfi\n \n-\t\trecord_in_rewritten \"$(cat \"$dotest\"/stopped-sha)\"\n+\trecord_in_rewritten \"$(cat \"$dotest\"/stopped-sha)\"\n \n-\t\trequire_clean_work_tree \"rebase\"\n-\t\tdo_rest\n-\t\t;;\n-\t--abort)\n-\t\tis_standalone \"$@\" || usage\n-\t\tget_saved_options\n-\t\tcomment_for_reflog abort\n-\n-\t\tgit rerere clear\n-\t\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n-\n-\t\theadname=$(cat \"$dotest\"/head-name)\n-\t\thead=$(cat \"$dotest\"/head)\n-\t\tcase $headname in\n-\t\trefs/*)\n-\t\t\tgit symbolic-ref HEAD $headname\n-\t\t\t;;\n-\t\tesac &&\n-\t\toutput git reset --hard $head &&\n-\t\trm -rf \"$dotest\"\n-\t\texit\n-\t\t;;\n-\t--skip)\n-\t\tis_standalone \"$@\" || usage\n-\t\tget_saved_options\n-\t\tcomment_for_reflog skip\n+\trequire_clean_work_tree \"rebase\"\n+\tdo_rest\n+\t;;\n+abort)\n+\tget_saved_options\n+\tcomment_for_reflog abort\n \n-\t\tgit rerere clear\n-\t\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n+\tgit rerere clear\n+\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n \n-\t\toutput git reset --hard && do_rest\n-\t\t;;\n-\t-s)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tstrategy=$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tstrategy=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n-\t\t;;\n-\t-m)\n-\t\t# we use merge anyway\n-\t\t;;\n-\t-v)\n-\t\tverbose=t\n-\t\t;;\n-\t-p)\n-\t\tpreserve_merges=t\n-\t\t;;\n-\t-i)\n-\t\t# yeah, we know\n-\t\t;;\n-\t--no-ff)\n-\t\tforce_rebase=t\n-\t\t;;\n-\t--root)\n-\t\trebase_root=t\n-\t\t;;\n-\t--autosquash)\n-\t\tautosquash=t\n-\t\t;;\n-\t--no-autosquash)\n-\t\tautosquash=\n-\t\t;;\n-\t--onto)\n-\t\ttest 2 -le \"$#\" || usage\n-\t\tonto=\"$2\"\n-\t\tshift\n-\t\t;;\n-\t--)\n-\t\tshift\n-\t\tbreak\n+\theadname=$(cat \"$dotest\"/head-name)\n+\thead=$(cat \"$dotest\"/head)\n+\tcase $headname in\n+\trefs/*)\n+\t\tgit symbolic-ref HEAD $headname\n \t\t;;\n-\tesac\n-\tshift\n-done\n+\tesac &&\n+\toutput git reset --hard $head &&\n+\trm -rf \"$dotest\"\n+\texit\n+\t;;\n+skip)\n+\tget_saved_options\n+\tcomment_for_reflog skip\n+\n+\tgit rerere clear\n+\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n+\n+\toutput git reset --hard && do_rest\n+\t;;\n+esac\n \n if test -n \"$onto\"\n then\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 3eac5a4..aa1bcaf 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -64,6 +64,9 @@ type=\n state_dir=\n # One of {'', continue, skip, abort}, as parsed from command line\n action=\n+preserve_merges=\n+autosquash=\n+test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n \n read_state () {\n \tif test \"$type\" = merge\n@@ -176,27 +179,12 @@ finish_rb_merge () {\n \tsay All done.\n }\n \n-is_interactive () {\n-\twhile test $# != 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t\t-i|--interactive)\n-\t\t\t\tinteractive_rebase=explicit\n-\t\t\t\tbreak\n-\t\t\t;;\n-\t\t\t-p|--preserve-merges)\n-\t\t\t\tinteractive_rebase=implied\n-\t\t\t;;\n-\t\tesac\n-\t\tshift\n-\tdone\n-\n+run_interactive_rebase () {\n \tif [ \"$interactive_rebase\" = implied ]; then\n \t\tGIT_EDITOR=:\n \t\texport GIT_EDITOR\n \tfi\n-\n-\ttest -n \"$interactive_rebase\" || test -f \"$merge_dir\"/interactive\n+\t. git-rebase--interactive \"$@\"\n }\n \n run_pre_rebase_hook () {\n@@ -211,8 +199,6 @@ run_pre_rebase_hook () {\n test -f \"$apply_dir\"/applying &&\n \tdie 'It looks like git-am is in progress. Cannot rebase.'\n \n-is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n-\n if test -d \"$apply_dir\"\n then\n \ttype=am\n@@ -249,6 +235,19 @@ do\n \t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n+\t-i|--interactive)\n+\t\tinteractive_rebase=explicit\n+\t\t;;\n+\t-p|--preserve-merges)\n+\t\tpreserve_merges=t\n+\t\ttest -z \"$interactive_rebase\" && interactive_rebase=implied\n+\t\t;;\n+\t--autosquash)\n+\t\tautosquash=t\n+\t\t;;\n+\t--no-autosquash)\n+\t\tautosquash=\n+\t\t;;\n \t-M|-m|--m|--me|--mer|--merg|--merge)\n \t\tdo_merge=t\n \t\t;;\n@@ -339,7 +338,11 @@ do\n done\n test $# -gt 2 && usage\n \n-test -n \"$action\" && test -z \"$in_progress\" && die \"No rebase in progress?\"\n+if test -n \"$action\"\n+then\n+\ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n+\ttest \"$type\" = interactive && run_interactive_rebase\n+fi\n \n case \"$action\" in\n continue)\n@@ -415,6 +418,21 @@ fi\n \n test $# -eq 0 && test -z \"$rebase_root\" && usage\n \n+if test -n \"$interactive_rebase\"\n+then\n+\ttype=interactive\n+\tstate_dir=\"$merge_dir\"\n+elif test -n \"$do_merge\"\n+then\n+\ttype=merge\n+\tstate_dir=\"$merge_dir\"\n+else\n+\ttype=am\n+\tstate_dir=\"$apply_dir\"\n+fi\n+\n+test \"$type\" = interactive && run_interactive_rebase \"$@\"\n+\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n if test -z \"$rebase_root\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160516","messageId":"1297017841-20678-12-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 11/31] rebase -i: remove now unnecessary directory checks","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:40Z","receivedAt":"2011-02-06T18:43:40Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove directory checks from git-rebase--interactive.sh that are done in\ngit-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nSquash with previous?\n\n\n git-rebase--interactive.sh |    6 ------\n 1 files changed, 0 insertions(+), 6 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 9c43c60..4f4fb29 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -706,8 +706,6 @@ continue)\n \tget_saved_options\n \tcomment_for_reflog continue\n \n-\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n-\n \t# Sanity check\n \tgit rev-parse --verify HEAD >/dev/null ||\n \t\tdie \"Cannot read HEAD\"\n@@ -749,7 +747,6 @@ abort)\n \tcomment_for_reflog abort\n \n \tgit rerere clear\n-\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n \n \theadname=$(cat \"$dotest\"/head-name)\n \thead=$(cat \"$dotest\"/head)\n@@ -767,7 +764,6 @@ skip)\n \tcomment_for_reflog skip\n \n \tgit rerere clear\n-\ttest -d \"$dotest\" || die \"No interactive rebase running\"\n \n \toutput git reset --hard && do_rest\n \t;;\n@@ -780,8 +776,6 @@ fi\n \n test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n test ! -z \"$rebase_root\" -a $# -le 1 || usage\n-test -d \"$dotest\" &&\n-\tdie \"Interactive rebase already started\"\n \n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160520","messageId":"1297017841-20678-13-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 12/31] rebase: reorder validation steps","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:41Z","receivedAt":"2011-02-06T18:43:41Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Reorder validation steps in preparation for the validation to be factored\nout from git-rebase--interactive.sh into git-rebase.sh.\n\nThe main functional difference is that the pre-rebase hook will no longer\nbe run if the work tree is dirty.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    4 ++--\n git-rebase.sh              |   10 +++++-----\n 2 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 4f4fb29..0f04f36 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -792,12 +792,12 @@ else\n \ttest -z \"$onto\" &&\n \t\tdie \"You must specify --onto when using --root\"\n fi\n+require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n+\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\n \n-require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n if test ! -z \"$1\"\n then\n \toutput git checkout \"$1\" -- ||\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex aa1bcaf..4a83d10 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -433,8 +433,6 @@ fi\n \n test \"$type\" = interactive && run_interactive_rebase \"$@\"\n \n-require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n if test -z \"$rebase_root\"\n then\n \t# The upstream head must be given.  Make sure it is valid.\n@@ -476,9 +474,6 @@ case \"$onto_name\" in\n \t;;\n esac\n \n-# If a hook exists, give it a chance to interrupt\n-run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n-\n # If the branch to rebase is given, that is the branch we will rebase\n # $branch_name -- branch being rebased, or HEAD (already detached)\n # $orig_head -- commit object name of tip of the branch before rebasing\n@@ -517,6 +512,8 @@ case \"$#\" in\n esac\n orig_head=$branch\n \n+require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n+\n # Now we are rebasing commits $upstream..$branch (or with --root,\n # everything leading up to $branch) on top of $onto\n \n@@ -538,6 +535,9 @@ then\n \tfi\n fi\n \n+# If a hook exists, give it a chance to interrupt\n+run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n+\n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160519","messageId":"1297017841-20678-14-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 13/31] rebase: factor out reference parsing","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:42Z","receivedAt":"2011-02-06T18:43:42Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove the parsing and validation of references (onto, upstream, branch)\nfrom git-rebase--interactive.sh and rely on the information exported from\ngit-rebase.sh.\n\nBy using the parsing of the --onto parameter in git-rebase.sh, this\nimproves the error message when the parameter is invalid.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nShould the check for set GIT_COMMITTER_IDENT be done for\nnon-interactive rebase as well or does it only make sense for\ninteractive rebase?\n\n\n git-rebase--interactive.sh |   48 +++----------------------------------------\n git-rebase.sh              |    9 ++++---\n 2 files changed, 9 insertions(+), 48 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0f04f36..fbe12a6 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -682,25 +682,6 @@ rearrange_squash () {\n \trm -f \"$1.sq\" \"$1.rearranged\"\n }\n \n-LF='\n-'\n-parse_onto () {\n-\tcase \"$1\" in\n-\t*...*)\n-\t\tif\tleft=${1%...*} right=${1#*...} &&\n-\t\t\tonto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})\n-\t\tthen\n-\t\t\tcase \"$onto\" in\n-\t\t\t?*\"$LF\"?* | '')\n-\t\t\t\texit 1 ;;\n-\t\t\tesac\n-\t\t\techo \"$onto\"\n-\t\t\texit 0\n-\t\tfi\n-\tesac\n-\tgit rev-parse --verify \"$1^0\"\n-}\n-\n case \"$action\" in\n continue)\n \tget_saved_options\n@@ -769,47 +750,26 @@ skip)\n \t;;\n esac\n \n-if test -n \"$onto\"\n-then\n-\tonto=$(parse_onto \"$onto\") || die \"Does not point to a valid commit: $1\"\n-fi\n-\n-test -z \"$rebase_root\" -a $# -ge 1 -a $# -le 2 ||\n-test ! -z \"$rebase_root\" -a $# -le 1 || usage\n-\n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-if test -z \"$rebase_root\"\n-then\n-\tupstream_arg=\"$1\"\n-\tupstream=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-\ttest -z \"$onto\" && onto=$upstream\n-\tshift\n-else\n-\tupstream=\n-\tupstream_arg=--root\n-\ttest -z \"$onto\" &&\n-\t\tdie \"You must specify --onto when using --root\"\n-fi\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\n \n-if test ! -z \"$1\"\n+if test ! -z \"$switch_to\"\n then\n-\toutput git checkout \"$1\" -- ||\n-\t\tdie \"Could not checkout $1\"\n+\toutput git checkout \"$switch_to\" -- ||\n+\t\tdie \"Could not checkout $switch_to\"\n fi\n \n head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n mkdir \"$dotest\" || die \"Could not create temporary $dotest\"\n \n : > \"$dotest\"/interactive || die \"Could not mark as interactive\"\n-git symbolic-ref HEAD > \"$dotest\"/head-name 2> /dev/null ||\n-\techo \"detached HEAD\" > \"$dotest\"/head-name\n+echo \"$head_name\" > \"$dotest\"/head-name\n \n echo $head > \"$dotest\"/head\n case \"$rebase_root\" in\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 4a83d10..0f5f5fb 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -431,8 +431,6 @@ else\n \tstate_dir=\"$apply_dir\"\n fi\n \n-test \"$type\" = interactive && run_interactive_rebase \"$@\"\n-\n if test -z \"$rebase_root\"\n then\n \t# The upstream head must be given.  Make sure it is valid.\n@@ -443,7 +441,7 @@ then\n \tunset root_flag\n \tupstream_arg=\"$upstream_name\"\n else\n-\ttest -z \"$onto\" && die \"--root must be used with --onto\"\n+\ttest -z \"$onto\" && die \"You must specify --onto when using --root\"\n \tunset upstream_name\n \tunset upstream\n \troot_flag=\"--root\"\n@@ -470,7 +468,8 @@ case \"$onto_name\" in\n \tfi\n \t;;\n *)\n-\tonto=$(git rev-parse --verify \"${onto_name}^0\") || exit\n+\tonto=$(git rev-parse --verify \"${onto_name}^0\") ||\n+\tdie \"Does not point to a valid commit: $1\"\n \t;;\n esac\n \n@@ -512,6 +511,8 @@ case \"$#\" in\n esac\n orig_head=$branch\n \n+test \"$type\" = interactive && run_interactive_rebase \"$@\"\n+\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n # Now we are rebasing commits $upstream..$branch (or with --root,\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160522","messageId":"1297017841-20678-15-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 14/31] rebase: factor out clean work tree check","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:43Z","receivedAt":"2011-02-06T18:43:43Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove the check for clean work tree from git-rebase--interactive.sh and\nrely on the check in git-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    2 --\n git-rebase.sh              |    4 ++--\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex fbe12a6..1ba98a2 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -753,8 +753,6 @@ esac\n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n-\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n comment_for_reflog start\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 0f5f5fb..265f01d 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -511,10 +511,10 @@ case \"$#\" in\n esac\n orig_head=$branch\n \n-test \"$type\" = interactive && run_interactive_rebase \"$@\"\n-\n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n+test \"$type\" = interactive && run_interactive_rebase \"$@\"\n+\n # Now we are rebasing commits $upstream..$branch (or with --root,\n # everything leading up to $branch) on top of $onto\n \n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160521","messageId":"1297017841-20678-16-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 15/31] rebase: factor out call to pre-rebase hook","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:44Z","receivedAt":"2011-02-06T18:43:44Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Remove the call to the pre-rebase hook from\ngit-rebase--interactive.sh and rely on the call in\ngit-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   14 --------------\n git-rebase.sh              |   12 +++++++-----\n 2 files changed, 7 insertions(+), 19 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 1ba98a2..f94f057 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -109,18 +109,6 @@ commit_message () {\n \tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\n }\n \n-run_pre_rebase_hook () {\n-\tif test -z \"$ok_to_skip_pre_rebase\" &&\n-\t   test -x \"$GIT_DIR/hooks/pre-rebase\"\n-\tthen\n-\t\t\"$GIT_DIR/hooks/pre-rebase\" ${1+\"$@\"} || {\n-\t\t\techo >&2 \"The pre-rebase hook refused to rebase.\"\n-\t\t\texit 1\n-\t\t}\n-\tfi\n-}\n-\n-\n orig_reflog_action=\"$GIT_REFLOG_ACTION\"\n \n comment_for_reflog () {\n@@ -753,8 +741,6 @@ esac\n git var GIT_COMMITTER_IDENT >/dev/null ||\n \tdie \"You need to set your committer info first\"\n \n-run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n-\n comment_for_reflog start\n \n if test ! -z \"$switch_to\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 265f01d..87d7fde 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -184,7 +184,7 @@ run_interactive_rebase () {\n \t\tGIT_EDITOR=:\n \t\texport GIT_EDITOR\n \tfi\n-\t. git-rebase--interactive \"$@\"\n+\t. git-rebase--interactive\n }\n \n run_pre_rebase_hook () {\n@@ -513,15 +513,15 @@ orig_head=$branch\n \n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n-test \"$type\" = interactive && run_interactive_rebase \"$@\"\n-\n # Now we are rebasing commits $upstream..$branch (or with --root,\n # everything leading up to $branch) on top of $onto\n \n # Check if we are already based on $onto with linear history,\n-# but this should be done only when upstream and onto are the same.\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\" \"$branch\")\n-if test \"$upstream\" = \"$onto\" && test \"$mb\" = \"$onto\" &&\n+if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n+\ttest \"$mb\" = \"$onto\" &&\n \t# linear history?\n \t! (git rev-list --parents \"$onto\"..\"$branch\" | sane_grep \" .* \") > /dev/null\n then\n@@ -539,6 +539,8 @@ fi\n # If a hook exists, give it a chance to interrupt\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n+test \"$type\" = interactive && run_interactive_rebase\n+\n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160539","messageId":"1297017841-20678-17-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 16/31] rebase -i: support --stat","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:45Z","receivedAt":"2011-02-06T18:43:45Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Move up the code that displays the diffstat if '--stat' is passed, so\nthat it will be executed before calling git-rebase--interactive.sh.\n\nA side effect is that the diffstat is now displayed before \"First,\nrewinding head to replay your work on top of it...\".\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |   14 +++++++-------\n 1 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 87d7fde..c8a7e4e 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -539,13 +539,6 @@ fi\n # If a hook exists, give it a chance to interrupt\n run_pre_rebase_hook \"$upstream_arg\" \"$@\"\n \n-test \"$type\" = interactive && run_interactive_rebase\n-\n-# Detach HEAD and reset the tree\n-say \"First, rewinding head to replay your work on top of it...\"\n-git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $branch\n-\n if test -n \"$diffstat\"\n then\n \tif test -n \"$verbose\"\n@@ -556,6 +549,13 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n+test \"$type\" = interactive && run_interactive_rebase\n+\n+# Detach HEAD and reset the tree\n+say \"First, rewinding head to replay your work on top of it...\"\n+git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n+git update-ref ORIG_HEAD $branch\n+\n # If the $onto is a proper descendant of the tip of the branch, then\n # we just fast-forwarded.\n if test \"$mb\" = \"$branch\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160524","messageId":"1297017841-20678-18-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 17/31] rebase: remove $branch as synonym for $orig_head","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:46Z","receivedAt":"2011-02-06T18:43:46Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"The variables $branch and $orig_head were used as synonyms. To avoid\nconfusion, remove $branch. The name 'orig_head' seems more suitable,\nsince that is the name used when the variable is persisted.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |   19 +++++++++----------\n 1 files changed, 9 insertions(+), 10 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex c8a7e4e..ed34906 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -485,10 +485,10 @@ case \"$#\" in\n \tswitch_to=\"$1\"\n \n \tif git show-ref --verify --quiet -- \"refs/heads/$1\" &&\n-\t   branch=$(git rev-parse -q --verify \"refs/heads/$1\")\n+\t   orig_head=$(git rev-parse -q --verify \"refs/heads/$1\")\n \tthen\n \t\thead_name=\"refs/heads/$1\"\n-\telif branch=$(git rev-parse -q --verify \"$1\")\n+\telif orig_head=$(git rev-parse -q --verify \"$1\")\n \tthen\n \t\thead_name=\"detached HEAD\"\n \telse\n@@ -506,24 +506,23 @@ case \"$#\" in\n \t\thead_name=\"detached HEAD\"\n \t\tbranch_name=HEAD ;# detached\n \tfi\n-\tbranch=$(git rev-parse --verify \"${branch_name}^0\") || exit\n+\torig_head=$(git rev-parse --verify \"${branch_name}^0\") || exit\n \t;;\n esac\n-orig_head=$branch\n \n require_clean_work_tree \"rebase\" \"Please commit or stash them.\"\n \n-# Now we are rebasing commits $upstream..$branch (or with --root,\n-# everything leading up to $branch) on top of $onto\n+# Now we are rebasing commits $upstream..$orig_head (or with --root,\n+# everything leading up to $orig_head) on top of $onto\n \n # Check if we are already based on $onto with linear history,\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\" \"$branch\")\n+mb=$(git merge-base \"$onto\" \"$orig_head\")\n if test \"$type\" != interactive && test \"$upstream\" = \"$onto\" &&\n \ttest \"$mb\" = \"$onto\" &&\n \t# linear history?\n-\t! (git rev-list --parents \"$onto\"..\"$branch\" | sane_grep \" .* \") > /dev/null\n+\t! (git rev-list --parents \"$onto\"..\"$orig_head\" | sane_grep \" .* \") > /dev/null\n then\n \tif test -z \"$force_rebase\"\n \tthen\n@@ -554,11 +553,11 @@ test \"$type\" = interactive && run_interactive_rebase\n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n git checkout -q \"$onto^0\" || die \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $branch\n+git update-ref ORIG_HEAD $orig_head\n \n # If the $onto is a proper descendant of the tip of the branch, then\n # we just fast-forwarded.\n-if test \"$mb\" = \"$branch\"\n+if test \"$mb\" = \"$orig_head\"\n then\n \tsay \"Fast-forwarded $branch_name to $onto_name.\"\n \tmove_to_original_branch\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160523","messageId":"1297017841-20678-19-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:47Z","receivedAt":"2011-02-06T18:43:47Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Extract the code for merge-based rebase to git-rebase--merge.sh.\n\nSuggested-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nChanges since v1:\n\n * As suggested by Johannes Sixt, git-rebase--$type is now sourced\n   instead of executed.\n\nWhat copyright year? Most of the code is just extracted from\ngit-rebase.sh, which has copyright year 2005. Does that matter?\n\nWould read_initial_state be a better name than read_basic_state?\n\n\n .gitignore           |    1 +\n Makefile             |    1 +\n git-rebase--merge.sh |  154 +++++++++++++++++++++++++++++++++++++++++++++++\n git-rebase.sh        |  162 ++++----------------------------------------------\n 4 files changed, 167 insertions(+), 151 deletions(-)\n create mode 100644 git-rebase--merge.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex 3dd6ef7..a8b98b4 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -103,6 +103,7 @@\n /git-read-tree\n /git-rebase\n /git-rebase--interactive\n+/git-rebase--merge\n /git-receive-pack\n /git-reflog\n /git-relink\ndiff --git a/Makefile b/Makefile\nindex 775ee83..f47550f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -370,6 +370,7 @@ SCRIPT_SH += git-mergetool.sh\n SCRIPT_SH += git-pull.sh\n SCRIPT_SH += git-quiltimport.sh\n SCRIPT_SH += git-rebase--interactive.sh\n+SCRIPT_SH += git-rebase--merge.sh\n SCRIPT_SH += git-rebase.sh\n SCRIPT_SH += git-repack.sh\n SCRIPT_SH += git-request-pull.sh\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nnew file mode 100644\nindex 0000000..c04ce8a\n--- /dev/null\n+++ b/git-rebase--merge.sh\n@@ -0,0 +1,154 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Junio C Hamano.\n+#\n+\n+. git-sh-setup\n+\n+prec=4\n+\n+read_state () {\n+\tonto_name=$(cat \"$state_dir\"/onto_name) &&\n+\tend=$(cat \"$state_dir\"/end) &&\n+\tmsgnum=$(cat \"$state_dir\"/msgnum)\n+}\n+\n+continue_merge () {\n+\ttest -d \"$state_dir\" || die \"$state_dir directory does not exist\"\n+\n+\tunmerged=$(git ls-files -u)\n+\tif test -n \"$unmerged\"\n+\tthen\n+\t\techo \"You still have unmerged paths in your index\"\n+\t\techo \"did you forget to use git add?\"\n+\t\tdie \"$resolvemsg\"\n+\tfi\n+\n+\tcmt=`cat \"$state_dir/current\"`\n+\tif ! git diff-index --quiet --ignore-submodules HEAD --\n+\tthen\n+\t\tif ! git commit --no-verify -C \"$cmt\"\n+\t\tthen\n+\t\t\techo \"Commit failed, please do not call \\\"git commit\\\"\"\n+\t\t\techo \"directly, but instead do one of the following: \"\n+\t\t\tdie \"$resolvemsg\"\n+\t\tfi\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n+\t\tfi\n+\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$state_dir/rewritten\"\n+\telse\n+\t\tif test -z \"$GIT_QUIET\"\n+\t\tthen\n+\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n+\t\tfi\n+\tfi\n+\ttest -z \"$GIT_QUIET\" &&\n+\tGIT_PAGER='' git log --format=%s -1 \"$cmt\"\n+\n+\t# onto the next patch:\n+\tmsgnum=$(($msgnum + 1))\n+\techo \"$msgnum\" >\"$state_dir/msgnum\"\n+}\n+\n+call_merge () {\n+\tcmt=\"$(cat \"$state_dir/cmt.$1\")\"\n+\techo \"$cmt\" > \"$state_dir/current\"\n+\thd=$(git rev-parse --verify HEAD)\n+\tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n+\tmsgnum=$(cat \"$state_dir/msgnum\")\n+\teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n+\teval GITHEAD_$hd='$onto_name'\n+\texport GITHEAD_$cmt GITHEAD_$hd\n+\tif test -n \"$GIT_QUIET\"\n+\tthen\n+\t\tGIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY\n+\tfi\n+\ttest -z \"$strategy\" && strategy=recursive\n+\teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n+\trv=$?\n+\tcase \"$rv\" in\n+\t0)\n+\t\tunset GITHEAD_$cmt GITHEAD_$hd\n+\t\treturn\n+\t\t;;\n+\t1)\n+\t\tgit rerere $allow_rerere_autoupdate\n+\t\tdie \"$resolvemsg\"\n+\t\t;;\n+\t2)\n+\t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n+\t\tdie \"$resolvemsg\"\n+\t\t;;\n+\t*)\n+\t\tdie \"Unknown exit code ($rv) from command:\" \\\n+\t\t\t\"git-merge-$strategy $cmt^ -- HEAD $cmt\"\n+\t\t;;\n+\tesac\n+}\n+\n+finish_rb_merge () {\n+\tmove_to_original_branch\n+\tgit notes copy --for-rewrite=rebase < \"$state_dir\"/rewritten\n+\tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n+\t\ttest -s \"$state_dir\"/rewritten; then\n+\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$state_dir\"/rewritten\n+\tfi\n+\trm -r \"$state_dir\"\n+\tsay All done.\n+}\n+\n+case \"$action\" in\n+continue)\n+\tread_state\n+\tcontinue_merge\n+\twhile test \"$msgnum\" -le \"$end\"\n+\tdo\n+\t\tcall_merge \"$msgnum\"\n+\t\tcontinue_merge\n+\tdone\n+\tfinish_rb_merge\n+\texit\n+\t;;\n+skip)\n+\tread_state\n+\tgit rerere clear\n+\tmsgnum=$(($msgnum + 1))\n+\twhile test \"$msgnum\" -le \"$end\"\n+\tdo\n+\t\tcall_merge \"$msgnum\"\n+\t\tcontinue_merge\n+\tdone\n+\tfinish_rb_merge\n+\texit\n+\t;;\n+esac\n+\n+mkdir -p \"$state_dir\"\n+echo \"$onto_name\" > \"$state_dir/onto_name\"\n+echo \"$head_name\" > \"$state_dir/head-name\"\n+echo \"$onto\" > \"$state_dir/onto\"\n+echo \"$orig_head\" > \"$state_dir/orig-head\"\n+echo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+\n+msgnum=0\n+for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n+do\n+\tmsgnum=$(($msgnum + 1))\n+\techo \"$cmt\" > \"$state_dir/cmt.$msgnum\"\n+done\n+\n+echo 1 >\"$state_dir/msgnum\"\n+echo $msgnum >\"$state_dir/end\"\n+\n+end=$msgnum\n+msgnum=1\n+\n+while test \"$msgnum\" -le \"$end\"\n+do\n+\tcall_merge \"$msgnum\"\n+\tcontinue_merge\n+done\n+\n+finish_rb_merge\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex ed34906..44e169f 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -48,7 +48,6 @@ strategy_opts=\n do_merge=\n merge_dir=\"$GIT_DIR\"/rebase-merge\n apply_dir=\"$GIT_DIR\"/rebase-apply\n-prec=4\n verbose=\n diffstat=\n test \"$(git config --bool rebase.stat)\" = true && diffstat=t\n@@ -68,94 +67,13 @@ preserve_merges=\n autosquash=\n test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n \n-read_state () {\n-\tif test \"$type\" = merge\n-\tthen\n-\t\tonto_name=$(cat \"$state_dir\"/onto_name) &&\n-\t\tend=$(cat \"$state_dir\"/end) &&\n-\t\tmsgnum=$(cat \"$state_dir\"/msgnum)\n-\tfi &&\n+read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n \torig_head=$(cat \"$state_dir\"/orig-head) &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n-continue_merge () {\n-\ttest -d \"$merge_dir\" || die \"$merge_dir directory does not exist\"\n-\n-\tunmerged=$(git ls-files -u)\n-\tif test -n \"$unmerged\"\n-\tthen\n-\t\techo \"You still have unmerged paths in your index\"\n-\t\techo \"did you forget to use git add?\"\n-\t\tdie \"$resolvemsg\"\n-\tfi\n-\n-\tcmt=`cat \"$merge_dir/current\"`\n-\tif ! git diff-index --quiet --ignore-submodules HEAD --\n-\tthen\n-\t\tif ! git commit --no-verify -C \"$cmt\"\n-\t\tthen\n-\t\t\techo \"Commit failed, please do not call \\\"git commit\\\"\"\n-\t\t\techo \"directly, but instead do one of the following: \"\n-\t\t\tdie \"$resolvemsg\"\n-\t\tfi\n-\t\tif test -z \"$GIT_QUIET\"\n-\t\tthen\n-\t\t\tprintf \"Committed: %0${prec}d \" $msgnum\n-\t\tfi\n-\t\techo \"$cmt $(git rev-parse HEAD^0)\" >> \"$merge_dir/rewritten\"\n-\telse\n-\t\tif test -z \"$GIT_QUIET\"\n-\t\tthen\n-\t\t\tprintf \"Already applied: %0${prec}d \" $msgnum\n-\t\tfi\n-\tfi\n-\ttest -z \"$GIT_QUIET\" &&\n-\tGIT_PAGER='' git log --format=%s -1 \"$cmt\"\n-\n-\t# onto the next patch:\n-\tmsgnum=$(($msgnum + 1))\n-\techo \"$msgnum\" >\"$merge_dir/msgnum\"\n-}\n-\n-call_merge () {\n-\tcmt=\"$(cat \"$merge_dir/cmt.$1\")\"\n-\techo \"$cmt\" > \"$merge_dir/current\"\n-\thd=$(git rev-parse --verify HEAD)\n-\tcmt_name=$(git symbolic-ref HEAD 2> /dev/null || echo HEAD)\n-\tmsgnum=$(cat \"$merge_dir/msgnum\")\n-\teval GITHEAD_$cmt='\"${cmt_name##refs/heads/}~$(($end - $msgnum))\"'\n-\teval GITHEAD_$hd='$onto_name'\n-\texport GITHEAD_$cmt GITHEAD_$hd\n-\tif test -n \"$GIT_QUIET\"\n-\tthen\n-\t\tGIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY\n-\tfi\n-\ttest -z \"$strategy\" && strategy=recursive\n-\teval 'git-merge-$strategy' $strategy_opts '\"$cmt^\" -- \"$hd\" \"$cmt\"'\n-\trv=$?\n-\tcase \"$rv\" in\n-\t0)\n-\t\tunset GITHEAD_$cmt GITHEAD_$hd\n-\t\treturn\n-\t\t;;\n-\t1)\n-\t\tgit rerere $allow_rerere_autoupdate\n-\t\tdie \"$resolvemsg\"\n-\t\t;;\n-\t2)\n-\t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n-\t\tdie \"$resolvemsg\"\n-\t\t;;\n-\t*)\n-\t\tdie \"Unknown exit code ($rv) from command:\" \\\n-\t\t\t\"git-merge-$strategy $cmt^ -- HEAD $cmt\"\n-\t\t;;\n-\tesac\n-}\n-\n move_to_original_branch () {\n \tcase \"$head_name\" in\n \trefs/*)\n@@ -168,23 +86,12 @@ move_to_original_branch () {\n \tesac\n }\n \n-finish_rb_merge () {\n-\tmove_to_original_branch\n-\tgit notes copy --for-rewrite=rebase < \"$merge_dir\"/rewritten\n-\tif test -x \"$GIT_DIR\"/hooks/post-rewrite &&\n-\t\ttest -s \"$merge_dir\"/rewritten; then\n-\t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$merge_dir\"/rewritten\n-\tfi\n-\trm -r \"$merge_dir\"\n-\tsay All done.\n-}\n-\n-run_interactive_rebase () {\n+run_specific_rebase () {\n \tif [ \"$interactive_rebase\" = implied ]; then\n \t\tGIT_EDITOR=:\n \t\texport GIT_EDITOR\n \tfi\n-\t. git-rebase--interactive\n+\ttest \"$type\" != am && . git-rebase--$type\n }\n \n run_pre_rebase_hook () {\n@@ -341,7 +248,7 @@ test $# -gt 2 && usage\n if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\ttest \"$type\" = interactive && run_interactive_rebase\n+\ttest \"$type\" = interactive && run_specific_rebase\n fi\n \n case \"$action\" in\n@@ -352,44 +259,23 @@ continue)\n \t\techo \"mark them as resolved using git add\"\n \t\texit 1\n \t}\n-\tread_state\n-\tif test -d \"$merge_dir\"\n-\tthen\n-\t\tcontinue_merge\n-\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\tdo\n-\t\t\tcall_merge \"$msgnum\"\n-\t\t\tcontinue_merge\n-\t\tdone\n-\t\tfinish_rb_merge\n-\t\texit\n-\tfi\n+\tread_basic_state\n+\trun_specific_rebase\n \tgit am --resolved --3way --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n skip)\n \tgit reset --hard HEAD || exit $?\n-\tread_state\n-\tif test -d \"$merge_dir\"\n-\tthen\n-\t\tgit rerere clear\n-\t\tmsgnum=$(($msgnum + 1))\n-\t\twhile test \"$msgnum\" -le \"$end\"\n-\t\tdo\n-\t\t\tcall_merge \"$msgnum\"\n-\t\t\tcontinue_merge\n-\t\tdone\n-\t\tfinish_rb_merge\n-\t\texit\n-\tfi\n+\tread_basic_state\n+\trun_specific_rebase\n \tgit am -3 --skip --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n abort)\n \tgit rerere clear\n-\tread_state\n+\tread_basic_state\n \tcase \"$head_name\" in\n \trefs/*)\n \t\tgit symbolic-ref HEAD $head_name ||\n@@ -548,7 +434,7 @@ then\n \tGIT_PAGER='' git diff --stat --summary \"$mb\" \"$onto\"\n fi\n \n-test \"$type\" = interactive && run_interactive_rebase\n+test \"$type\" = interactive && run_specific_rebase\n \n # Detach HEAD and reset the tree\n say \"First, rewinding head to replay your work on top of it...\"\n@@ -590,30 +476,4 @@ fi\n # start doing a rebase with git-merge\n # this is rename-aware if the recursive (default) strategy is used\n \n-mkdir -p \"$merge_dir\"\n-echo \"$onto_name\" > \"$merge_dir/onto_name\"\n-echo \"$head_name\" > \"$merge_dir/head-name\"\n-echo \"$onto\" > \"$merge_dir/onto\"\n-echo \"$orig_head\" > \"$merge_dir/orig-head\"\n-echo \"$GIT_QUIET\" > \"$merge_dir/quiet\"\n-\n-msgnum=0\n-for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\n-do\n-\tmsgnum=$(($msgnum + 1))\n-\techo \"$cmt\" > \"$merge_dir/cmt.$msgnum\"\n-done\n-\n-echo 1 >\"$merge_dir/msgnum\"\n-echo $msgnum >\"$merge_dir/end\"\n-\n-end=$msgnum\n-msgnum=1\n-\n-while test \"$msgnum\" -le \"$end\"\n-do\n-\tcall_merge \"$msgnum\"\n-\tcontinue_merge\n-done\n-\n-finish_rb_merge\n+run_specific_rebase\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160537","messageId":"1297017841-20678-20-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 19/31] rebase: extract am code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:48Z","receivedAt":"2011-02-06T18:43:48Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Extract the code for am-based rebase to git-rebase--am.sh.\n\nSuggested-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n .gitignore        |    1 +\n Makefile          |    1 +\n git-rebase--am.sh |   34 ++++++++++++++++++++++++++++++++++\n git-rebase.sh     |   31 ++-----------------------------\n 4 files changed, 38 insertions(+), 29 deletions(-)\n create mode 100644 git-rebase--am.sh\n\ndiff --git a/.gitignore b/.gitignore\nindex a8b98b4..7aaf5c7 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -102,6 +102,7 @@\n /git-quiltimport\n /git-read-tree\n /git-rebase\n+/git-rebase--am\n /git-rebase--interactive\n /git-rebase--merge\n /git-receive-pack\ndiff --git a/Makefile b/Makefile\nindex f47550f..3cc60cb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -369,6 +369,7 @@ SCRIPT_SH += git-merge-resolve.sh\n SCRIPT_SH += git-mergetool.sh\n SCRIPT_SH += git-pull.sh\n SCRIPT_SH += git-quiltimport.sh\n+SCRIPT_SH += git-rebase--am.sh\n SCRIPT_SH += git-rebase--interactive.sh\n SCRIPT_SH += git-rebase--merge.sh\n SCRIPT_SH += git-rebase.sh\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nnew file mode 100644\nindex 0000000..263987c\n--- /dev/null\n+++ b/git-rebase--am.sh\n@@ -0,0 +1,34 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Junio C Hamano.\n+#\n+\n+. git-sh-setup\n+\n+case \"$action\" in\n+continue)\n+\tgit am --resolved --3way --resolvemsg=\"$resolvemsg\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+skip)\n+\tgit am --skip -3 --resolvemsg=\"$resolvemsg\" &&\n+\tmove_to_original_branch\n+\texit\n+\t;;\n+esac\n+\n+test -n \"$rebase_root\" && root_flag=--root\n+\n+git format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n+\t--src-prefix=a/ --dst-prefix=b/ \\\n+\t--no-renames $root_flag \"$revisions\" |\n+git am $git_am_opt --rebasing --resolvemsg=\"$resolvemsg\" &&\n+move_to_original_branch\n+ret=$?\n+test 0 != $ret -a -d \"$state_dir\" &&\n+\techo $head_name > \"$state_dir/head-name\" &&\n+\techo $onto > \"$state_dir/onto\" &&\n+\techo $orig_head > \"$state_dir/orig-head\" &&\n+\techo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+exit $ret\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 44e169f..c60221b 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -91,7 +91,7 @@ run_specific_rebase () {\n \t\tGIT_EDITOR=:\n \t\texport GIT_EDITOR\n \tfi\n-\ttest \"$type\" != am && . git-rebase--$type\n+\t. git-rebase--$type\n }\n \n run_pre_rebase_hook () {\n@@ -261,17 +261,11 @@ continue)\n \t}\n \tread_basic_state\n \trun_specific_rebase\n-\tgit am --resolved --3way --resolvemsg=\"$resolvemsg\" &&\n-\tmove_to_original_branch\n-\texit\n \t;;\n skip)\n \tgit reset --hard HEAD || exit $?\n \tread_basic_state\n \trun_specific_rebase\n-\tgit am -3 --skip --resolvemsg=\"$resolvemsg\" &&\n-\tmove_to_original_branch\n-\texit\n \t;;\n abort)\n \tgit rerere clear\n@@ -324,14 +318,12 @@ then\n \tshift\n \tupstream=`git rev-parse --verify \"${upstream_name}^0\"` ||\n \tdie \"invalid upstream $upstream_name\"\n-\tunset root_flag\n \tupstream_arg=\"$upstream_name\"\n else\n \ttest -z \"$onto\" && die \"You must specify --onto when using --root\"\n \tunset upstream_name\n \tunset upstream\n-\troot_flag=\"--root\"\n-\tupstream_arg=\"$root_flag\"\n+\tupstream_arg=--root\n fi\n \n # Make sure the branch to rebase onto is valid.\n@@ -457,23 +449,4 @@ else\n \trevisions=\"$upstream..$orig_head\"\n fi\n \n-if test -z \"$do_merge\"\n-then\n-\tgit format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n-\t\t--src-prefix=a/ --dst-prefix=b/ \\\n-\t\t--no-renames $root_flag \"$revisions\" |\n-\tgit am $git_am_opt --rebasing --resolvemsg=\"$resolvemsg\" &&\n-\tmove_to_original_branch\n-\tret=$?\n-\ttest 0 != $ret -a -d \"$apply_dir\" &&\n-\t\techo $head_name > \"$apply_dir/head-name\" &&\n-\t\techo $onto > \"$apply_dir/onto\" &&\n-\t\techo $orig_head > \"$apply_dir/orig-head\" &&\n-\t\techo \"$GIT_QUIET\" > \"$apply_dir/quiet\"\n-\texit $ret\n-fi\n-\n-# start doing a rebase with git-merge\n-# this is rename-aware if the recursive (default) strategy is used\n-\n run_specific_rebase\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160525","messageId":"1297017841-20678-21-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 20/31] rebase: show consistent conflict resolution hint","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:49Z","receivedAt":"2011-02-06T18:43:49Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"When rebase stops due to conflict, interactive rebase currently\ndisplays a different hint to the user than non-interactive rebase\ndoes. Use the same message for both types of rebase.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nShould we include the \"mark the corrected paths with 'git add\n<paths>'\" part?\n\n\n git-rebase--interactive.sh |    4 +---\n 1 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex f94f057..0499f9e 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -81,9 +81,7 @@ amend=\"$dotest\"/amend\n rewritten_list=\"$dotest\"/rewritten-list\n rewritten_pending=\"$dotest\"/rewritten-pending\n \n-GIT_CHERRY_PICK_HELP=\"\\\n-hint: after resolving the conflicts, mark the corrected paths\n-hint: with 'git add <paths>' and run 'git rebase --continue'\"\n+GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n export GIT_CHERRY_PICK_HELP\n \n warn () {\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160526","messageId":"1297017841-20678-22-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 21/31] rebase -i: align variable names","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:50Z","receivedAt":"2011-02-06T18:43:50Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Rename variables HEAD and OLDHEAD to orig_head and HEADNAME to\nhead_name, which are the names used in git-rebase.sh. This prepares\nfor factoring out of the code that persists these variables during the\nentire rebase process. Using the same variable names to mean the same\nthing in both files also makes the code easier to read.\n\nWhile at it, also remove the DOTEST variable and use the state_dir\nvariable that was inherited from git-rebase.sh instead.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |  120 +++++++++++++++++++++----------------------\n 1 files changed, 59 insertions(+), 61 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 0499f9e..fa8bfda 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -12,22 +12,20 @@\n \n . git-sh-setup\n \n-dotest=\"$GIT_DIR/rebase-merge\"\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=\"$dotest\"/git-rebase-todo\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=\"$dotest\"/done\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=\"$dotest\"/message\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@@ -42,14 +40,14 @@ msg=\"$dotest\"/message\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=\"$dotest\"/message-squash\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=\"$dotest\"/message-fixup\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@@ -57,14 +55,14 @@ fixup_msg=\"$dotest\"/message-fixup\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=\"$dotest\"/rewritten\n+rewritten=\"$state_dir\"/rewritten\n \n-dropped=\"$dotest\"/dropped\n+dropped=\"$state_dir\"/dropped\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=\"$dotest\"/author-script\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@@ -72,14 +70,14 @@ author_script=\"$dotest\"/author-script\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=\"$dotest\"/amend\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=\"$dotest\"/rewritten-list\n-rewritten_pending=\"$dotest\"/rewritten-pending\n+rewritten_list=\"$state_dir\"/rewritten-list\n+rewritten_pending=\"$state_dir\"/rewritten-pending\n \n GIT_CHERRY_PICK_HELP=\"$resolvemsg\"\n export GIT_CHERRY_PICK_HELP\n@@ -145,7 +143,7 @@ make_patch () {\n \t*)\n \t\techo \"Root commit\"\n \t\t;;\n-\tesac > \"$dotest\"/patch\n+\tesac > \"$state_dir\"/patch\n \ttest -f \"$msg\" ||\n \t\tcommit_message \"$1\" > \"$msg\"\n \ttest -f \"$author_script\" ||\n@@ -153,14 +151,14 @@ make_patch () {\n }\n \n die_with_patch () {\n-\techo \"$1\" > \"$dotest\"/stopped-sha\n+\techo \"$1\" > \"$state_dir\"/stopped-sha\n \tmake_patch \"$1\"\n \tgit rerere\n \tdie \"$2\"\n }\n \n die_abort () {\n-\trm -rf \"$dotest\"\n+\trm -rf \"$state_dir\"\n \tdie \"$1\"\n }\n \n@@ -205,20 +203,20 @@ pick_one_preserving_merges () {\n \tesac\n \tsha1=$(git rev-parse $sha1)\n \n-\tif test -f \"$dotest\"/current-commit\n+\tif test -f \"$state_dir\"/current-commit\n \tthen\n \t\tif test \"$fast_forward\" = t\n \t\tthen\n \t\t\twhile read current_commit\n \t\t\tdo\n \t\t\t\tgit rev-parse HEAD > \"$rewritten\"/$current_commit\n-\t\t\tdone <\"$dotest\"/current-commit\n-\t\t\trm \"$dotest\"/current-commit ||\n+\t\t\tdone <\"$state_dir\"/current-commit\n+\t\t\trm \"$state_dir\"/current-commit ||\n \t\t\tdie \"Cannot write current commit's replacement sha1\"\n \t\tfi\n \tfi\n \n-\techo $sha1 >> \"$dotest\"/current-commit\n+\techo $sha1 >> \"$state_dir\"/current-commit\n \n \t# rewrite parents; if none were rewritten, we can fast-forward.\n \tnew_parents=\n@@ -425,7 +423,7 @@ do_next () {\n \t\tmark_action_done\n \t\tpick_one $sha1 ||\n \t\t\tdie_with_patch $sha1 \"Could not apply $sha1... $rest\"\n-\t\techo \"$sha1\" > \"$dotest\"/stopped-sha\n+\t\techo \"$sha1\" > \"$state_dir\"/stopped-sha\n \t\tmake_patch $sha1\n \t\tgit rev-parse --verify HEAD > \"$amend\"\n \t\twarn \"Stopped at $sha1... $rest\"\n@@ -490,7 +488,7 @@ do_next () {\n \t\tprintf 'Executing: %s\\n' \"$rest\"\n \t\t# \"exec\" command doesn't take a sha1 in the todo-list.\n \t\t# => can't just use $sha1 here.\n-\t\tgit rev-parse --verify HEAD > \"$dotest\"/stopped-sha\n+\t\tgit rev-parse --verify HEAD > \"$state_dir\"/stopped-sha\n \t\t${SHELL:-@SHELL_PATH@} -c \"$rest\" # Actual execution\n \t\tstatus=$?\n \t\tif test \"$status\" -ne 0\n@@ -525,19 +523,19 @@ do_next () {\n \ttest -s \"$todo\" && return\n \n \tcomment_for_reflog finish &&\n-\theadname=$(cat \"$dotest\"/head-name) &&\n-\toldhead=$(cat \"$dotest\"/head) &&\n-\tshortonto=$(git rev-parse --short $(cat \"$dotest\"/onto)) &&\n+\thead_name=$(cat \"$state_dir\"/head-name) &&\n+\torig_head=$(cat \"$state_dir\"/head) &&\n+\tshortonto=$(git rev-parse --short $(cat \"$state_dir\"/onto)) &&\n \tnewhead=$(git rev-parse HEAD) &&\n-\tcase $headname in\n+\tcase $head_name in\n \trefs/*)\n-\t\tmessage=\"$GIT_REFLOG_ACTION: $headname onto $shortonto\" &&\n-\t\tgit update-ref -m \"$message\" $headname $newhead $oldhead &&\n-\t\tgit symbolic-ref HEAD $headname\n+\t\tmessage=\"$GIT_REFLOG_ACTION: $head_name onto $shortonto\" &&\n+\t\tgit update-ref -m \"$message\" $head_name $newhead $orig_head &&\n+\t\tgit symbolic-ref HEAD $head_name\n \t\t;;\n \tesac && {\n-\t\ttest ! -f \"$dotest\"/verbose ||\n-\t\t\tgit diff-tree --stat $(cat \"$dotest\"/head)..HEAD\n+\t\ttest ! -f \"$state_dir\"/verbose ||\n+\t\t\tgit diff-tree --stat $(cat \"$state_dir\"/head)..HEAD\n \t} &&\n \t{\n \t\ttest -s \"$rewritten_list\" &&\n@@ -549,9 +547,9 @@ do_next () {\n \t\t\"$GIT_DIR\"/hooks/post-rewrite rebase < \"$rewritten_list\"\n \t\ttrue # we don't care if this hook failed\n \tfi &&\n-\trm -rf \"$dotest\" &&\n+\trm -rf \"$state_dir\" &&\n \tgit gc --auto &&\n-\twarn \"Successfully rebased and updated $headname.\"\n+\twarn \"Successfully rebased and updated $head_name.\"\n \n \texit\n }\n@@ -602,9 +600,9 @@ skip_unnecessary_picks () {\n \n get_saved_options () {\n \ttest -d \"$rewritten\" && preserve_merges=t\n-\ttest -f \"$dotest\"/strategy && strategy=\"$(cat \"$dotest\"/strategy)\"\n-\ttest -f \"$dotest\"/verbose && verbose=t\n-\ttest -f \"$dotest\"/rebase-root && rebase_root=t\n+\ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n+\ttest -f \"$state_dir\"/verbose && verbose=t\n+\ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n # Rearrange the todo list that has both \"pick sha1 msg\" and\n@@ -704,7 +702,7 @@ first and then run 'git rebase --continue' again.\"\n \t\t}\n \tfi\n \n-\trecord_in_rewritten \"$(cat \"$dotest\"/stopped-sha)\"\n+\trecord_in_rewritten \"$(cat \"$state_dir\"/stopped-sha)\"\n \n \trequire_clean_work_tree \"rebase\"\n \tdo_rest\n@@ -715,15 +713,15 @@ abort)\n \n \tgit rerere clear\n \n-\theadname=$(cat \"$dotest\"/head-name)\n-\thead=$(cat \"$dotest\"/head)\n-\tcase $headname in\n+\thead_name=$(cat \"$state_dir\"/head-name)\n+\torig_head=$(cat \"$state_dir\"/head)\n+\tcase $head_name in\n \trefs/*)\n-\t\tgit symbolic-ref HEAD $headname\n+\t\tgit symbolic-ref HEAD $head_name\n \t\t;;\n \tesac &&\n-\toutput git reset --hard $head &&\n-\trm -rf \"$dotest\"\n+\toutput git reset --hard $orig_head &&\n+\trm -rf \"$state_dir\"\n \texit\n \t;;\n skip)\n@@ -747,28 +745,28 @@ then\n \t\tdie \"Could not checkout $switch_to\"\n fi\n \n-head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n-mkdir \"$dotest\" || die \"Could not create temporary $dotest\"\n+orig_head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n+mkdir \"$state_dir\" || die \"Could not create temporary $state_dir\"\n \n-: > \"$dotest\"/interactive || die \"Could not mark as interactive\"\n-echo \"$head_name\" > \"$dotest\"/head-name\n+: > \"$state_dir\"/interactive || die \"Could not mark as interactive\"\n+echo \"$head_name\" > \"$state_dir\"/head-name\n \n-echo $head > \"$dotest\"/head\n+echo $orig_head > \"$state_dir\"/head\n case \"$rebase_root\" in\n '')\n-\trm -f \"$dotest\"/rebase-root ;;\n+\trm -f \"$state_dir\"/rebase-root ;;\n *)\n-\t: >\"$dotest\"/rebase-root ;;\n+\t: >\"$state_dir\"/rebase-root ;;\n esac\n-echo $onto > \"$dotest\"/onto\n-test -z \"$strategy\" || echo \"$strategy\" > \"$dotest\"/strategy\n-test t = \"$verbose\" && : > \"$dotest\"/verbose\n+echo $onto > \"$state_dir\"/onto\n+test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n+test t = \"$verbose\" && : > \"$state_dir\"/verbose\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\n \tthen\n \t\tmkdir \"$rewritten\" &&\n-\t\tfor c in $(git merge-base --all $head $upstream)\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 \"Could not init rewritten commits\"\n@@ -782,21 +780,21 @@ then\n \t# parents to rewrite and skipping dropped commits would\n \t# prematurely end our probe\n \tmerges_option=\n-\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $upstream..$head | head -n 1)\"\n+\tfirst_after_upstream=\"$(git rev-list --reverse --first-parent $upstream..$orig_head | head -n 1)\"\n else\n \tmerges_option=\"--no-merges --cherry-pick\"\n fi\n \n-shorthead=$(git rev-parse --short $head)\n+shorthead=$(git rev-parse --short $orig_head)\n shortonto=$(git rev-parse --short $onto)\n if test -z \"$rebase_root\"\n \t# this is now equivalent to ! -z \"$upstream\"\n then\n \tshortupstream=$(git rev-parse --short $upstream)\n-\trevisions=$upstream...$head\n+\trevisions=$upstream...$orig_head\n \tshortrevisions=$shortupstream..$shorthead\n else\n-\trevisions=$onto...$head\n+\trevisions=$onto...$orig_head\n \tshortrevisions=$shorthead\n fi\n git rev-list $merges_option --pretty=oneline --abbrev-commit \\\n@@ -837,13 +835,13 @@ then\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\" > \"$dotest\"/not-cherry-picks\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 -a \"$(sane_grep \"$rev\" \"$dotest\"/not-cherry-picks)\" = \"\"\n+\t\tif test -f \"$rewritten\"/$rev -a \"$(sane_grep \"$rev\" \"$state_dir\"/not-cherry-picks)\" = \"\"\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@@ -889,5 +887,5 @@ has_action \"$todo\" ||\n test -d \"$rewritten\" || test -n \"$force_rebase\" || skip_unnecessary_picks\n \n output git checkout $onto || die_abort \"could not detach HEAD\"\n-git update-ref ORIG_HEAD $head\n+git update-ref ORIG_HEAD $orig_head\n do_rest\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160527","messageId":"1297017841-20678-23-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 22/31] rebase: make -v a tiny bit more verbose","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:51Z","receivedAt":"2011-02-06T18:43:51Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"To make it possible to later remove the handling of --abort from\ngit-rebase--interactive.sh, align the implementation in git-rebase.sh\nwith the former by making it a bit more verbose.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nWhat do we really want to print when -v is passed? Interactive rebase\nis currently quite a bit more verbose than non-interactive rebase.\n\n\n git-rebase--interactive.sh |   14 --------------\n git-rebase.sh              |   18 ++++++++++++++++--\n 2 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex fa8bfda..affa467 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -86,20 +86,6 @@ warn () {\n \tprintf '%s\\n' \"$*\" >&2\n }\n \n-output () {\n-\tcase \"$verbose\" in\n-\t'')\n-\t\toutput=$(\"$@\" 2>&1 )\n-\t\tstatus=$?\n-\t\ttest $status != 0 && printf \"%s\\n\" \"$output\"\n-\t\treturn $status\n-\t\t;;\n-\t*)\n-\t\t\"$@\"\n-\t\t;;\n-\tesac\n-}\n-\n # Output the commit message for the specified commit.\n commit_message () {\n \tgit cat-file commit \"$1\" | sed \"1,/^$/d\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex c60221b..42d635b 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -74,6 +74,20 @@ read_basic_state () {\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n+output () {\n+\tcase \"$verbose\" in\n+\t'')\n+\t\toutput=$(\"$@\" 2>&1 )\n+\t\tstatus=$?\n+\t\ttest $status != 0 && printf \"%s\\n\" \"$output\"\n+\t\treturn $status\n+\t\t;;\n+\t*)\n+\t\t\"$@\"\n+\t\t;;\n+\tesac\n+}\n+\n move_to_original_branch () {\n \tcase \"$head_name\" in\n \trefs/*)\n@@ -263,7 +277,7 @@ continue)\n \trun_specific_rebase\n \t;;\n skip)\n-\tgit reset --hard HEAD || exit $?\n+\toutput git reset --hard HEAD || exit $?\n \tread_basic_state\n \trun_specific_rebase\n \t;;\n@@ -276,7 +290,7 @@ abort)\n \t\tdie \"Could not move back to $head_name\"\n \t\t;;\n \tesac\n-\tgit reset --hard $orig_head\n+\toutput git reset --hard $orig_head\n \trm -r \"$state_dir\"\n \texit\n \t;;\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160530","messageId":"1297017841-20678-24-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 23/31] rebase: factor out sub command handling","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:52Z","receivedAt":"2011-02-06T18:43:52Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Factor out the common parts of the handling of the sub commands\n'--continue', '--skip' and '--abort'. The '--abort' handling can\nhandled completely in git-rebase.sh.\n\nAfter this refactoring, the calls to git-rebase--am.sh,\ngit-rebase--merge.sh and git-rebase--interactive.sh will be better\naligned. There will only be one call to interactive rebase that will\nshortcut the very last part of git-rebase.sh.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   34 +++-------------------------------\n git-rebase.sh              |   17 +++++++++++++++--\n 2 files changed, 18 insertions(+), 33 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex affa467..4af0bc6 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -509,9 +509,7 @@ do_next () {\n \ttest -s \"$todo\" && return\n \n \tcomment_for_reflog finish &&\n-\thead_name=$(cat \"$state_dir\"/head-name) &&\n-\torig_head=$(cat \"$state_dir\"/head) &&\n-\tshortonto=$(git rev-parse --short $(cat \"$state_dir\"/onto)) &&\n+\tshortonto=$(git rev-parse --short $onto) &&\n \tnewhead=$(git rev-parse HEAD) &&\n \tcase $head_name in\n \trefs/*)\n@@ -521,7 +519,7 @@ do_next () {\n \t\t;;\n \tesac && {\n \t\ttest ! -f \"$state_dir\"/verbose ||\n-\t\t\tgit diff-tree --stat $(cat \"$state_dir\"/head)..HEAD\n+\t\t\tgit diff-tree --stat $orig_head..HEAD\n \t} &&\n \t{\n \t\ttest -s \"$rewritten_list\" &&\n@@ -655,14 +653,6 @@ rearrange_squash () {\n case \"$action\" in\n continue)\n \tget_saved_options\n-\tcomment_for_reflog continue\n-\n-\t# Sanity check\n-\tgit rev-parse --verify HEAD >/dev/null ||\n-\t\tdie \"Cannot read HEAD\"\n-\tgit update-index --ignore-submodules --refresh &&\n-\t\tgit diff-files --quiet --ignore-submodules ||\n-\t\tdie \"Working tree is dirty\"\n \n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet --ignore-submodules HEAD --\n@@ -693,30 +683,12 @@ first and then run 'git rebase --continue' again.\"\n \trequire_clean_work_tree \"rebase\"\n \tdo_rest\n \t;;\n-abort)\n-\tget_saved_options\n-\tcomment_for_reflog abort\n-\n-\tgit rerere clear\n-\n-\thead_name=$(cat \"$state_dir\"/head-name)\n-\torig_head=$(cat \"$state_dir\"/head)\n-\tcase $head_name in\n-\trefs/*)\n-\t\tgit symbolic-ref HEAD $head_name\n-\t\t;;\n-\tesac &&\n-\toutput git reset --hard $orig_head &&\n-\trm -rf \"$state_dir\"\n-\texit\n-\t;;\n skip)\n \tget_saved_options\n-\tcomment_for_reflog skip\n \n \tgit rerere clear\n \n-\toutput git reset --hard && do_rest\n+\tdo_rest\n \t;;\n esac\n \ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 42d635b..21bb027 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -70,7 +70,12 @@ test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n-\torig_head=$(cat \"$state_dir\"/orig-head) &&\n+\tif test \"$type\" = interactive\n+\tthen\n+\t\torig_head=$(cat \"$state_dir\"/head)\n+\telse\n+\t\torig_head=$(cat \"$state_dir\"/orig-head)\n+\tfi &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n@@ -262,11 +267,19 @@ test $# -gt 2 && usage\n if test -n \"$action\"\n then\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n-\ttest \"$type\" = interactive && run_specific_rebase\n+\t# Only interactive rebase uses detailed reflog messages\n+\tif test \"$type\" = interactive && 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 case \"$action\" in\n continue)\n+\t# Sanity check\n+\tgit rev-parse --verify HEAD >/dev/null ||\n+\t\tdie \"Cannot read HEAD\"\n \tgit update-index --ignore-submodules --refresh &&\n \tgit diff-files --quiet --ignore-submodules || {\n \t\techo \"You must edit all merge conflicts and then\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160533","messageId":"1297017841-20678-25-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 24/31] rebase: extract code for writing basic state","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:53Z","receivedAt":"2011-02-06T18:43:53Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Extract the code for writing the state to rebase-apply/ or\nrebase-merge/ when a rebase is initiated. This will make it easier to\nlater make both interactive and non-interactive rebase remember the\noptions used.\n\nNote that non-interactive rebase stores the sha1 of the original head\nin a file called orig-head, while interactive rebase stores it in a\nfile called head. Change this by writing to orig-head in both\ncases. When reading, try to read from orig-head. If that fails, read\nfrom head instead. This protects users who upgraded git while they had\nan ongoing interactive rebase, while still making it possible to\nremove the code that reads from head at some point in the future.\n\nHelped-by: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nChanges since v1:\n\n * As suggested by Thomas, always write to orig-head file. When\n   reading, try orig-head first and fall back to reading from head.\n\n\n git-rebase--am.sh          |    6 +-----\n git-rebase--interactive.sh |    5 +----\n git-rebase--merge.sh       |    5 +----\n git-rebase.sh              |   16 +++++++++++++---\n 4 files changed, 16 insertions(+), 16 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex 263987c..c9604a6 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -26,9 +26,5 @@ git format-patch -k --stdout --full-index --ignore-if-in-upstream \\\n git am $git_am_opt --rebasing --resolvemsg=\"$resolvemsg\" &&\n move_to_original_branch\n ret=$?\n-test 0 != $ret -a -d \"$state_dir\" &&\n-\techo $head_name > \"$state_dir/head-name\" &&\n-\techo $onto > \"$state_dir/onto\" &&\n-\techo $orig_head > \"$state_dir/orig-head\" &&\n-\techo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+test 0 != $ret -a -d \"$state_dir\" && write_basic_state\n exit $ret\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 4af0bc6..437cc52 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -707,16 +707,13 @@ orig_head=$(git rev-parse --verify HEAD) || die \"No HEAD?\"\n mkdir \"$state_dir\" || die \"Could not create temporary $state_dir\"\n \n : > \"$state_dir\"/interactive || die \"Could not mark as interactive\"\n-echo \"$head_name\" > \"$state_dir\"/head-name\n-\n-echo $orig_head > \"$state_dir\"/head\n+write_basic_state\n case \"$rebase_root\" in\n '')\n \trm -f \"$state_dir\"/rebase-root ;;\n *)\n \t: >\"$state_dir\"/rebase-root ;;\n esac\n-echo $onto > \"$state_dir\"/onto\n test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n test t = \"$verbose\" && : > \"$state_dir\"/verbose\n if test t = \"$preserve_merges\"\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex c04ce8a..eb0f7bc 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -127,10 +127,7 @@ esac\n \n mkdir -p \"$state_dir\"\n echo \"$onto_name\" > \"$state_dir/onto_name\"\n-echo \"$head_name\" > \"$state_dir/head-name\"\n-echo \"$onto\" > \"$state_dir/onto\"\n-echo \"$orig_head\" > \"$state_dir/orig-head\"\n-echo \"$GIT_QUIET\" > \"$state_dir/quiet\"\n+write_basic_state\n \n msgnum=0\n for cmt in `git rev-list --reverse --no-merges \"$revisions\"`\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 21bb027..5a399aa 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -70,15 +70,25 @@ test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n-\tif test \"$type\" = interactive\n+\t# We always write to orig-head, but interactive rebase used to write to\n+\t# head. Fall back to reading from head to cover for the case that the\n+\t# user upgraded git with an ongoing interactive rebase.\n+\tif test -f \"$state_dir\"/orig-head\n \tthen\n-\t\torig_head=$(cat \"$state_dir\"/head)\n-\telse\n \t\torig_head=$(cat \"$state_dir\"/orig-head)\n+\telse\n+\t\torig_head=$(cat \"$state_dir\"/head)\n \tfi &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n }\n \n+write_basic_state () {\n+\techo \"$head_name\" > \"$state_dir\"/head-name &&\n+\techo \"$onto\" > \"$state_dir\"/onto &&\n+\techo \"$orig_head\" > \"$state_dir\"/orig-head &&\n+\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet\n+}\n+\n output () {\n \tcase \"$verbose\" in\n \t'')\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160529","messageId":"1297017841-20678-26-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 25/31] rebase: remember verbose option","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:54Z","receivedAt":"2011-02-06T18:43:54Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Currently, only interactive rebase remembers the value of the '-v'\nflag from the initial invocation. Make non-interactive rebase also\nremember it.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    2 --\n git-rebase.sh              |    6 ++++--\n 2 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 437cc52..f076a6e 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -585,7 +585,6 @@ skip_unnecessary_picks () {\n get_saved_options () {\n \ttest -d \"$rewritten\" && preserve_merges=t\n \ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n-\ttest -f \"$state_dir\"/verbose && verbose=t\n \ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n@@ -715,7 +714,6 @@ case \"$rebase_root\" in\n \t: >\"$state_dir\"/rebase-root ;;\n esac\n test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n-test t = \"$verbose\" && : > \"$state_dir\"/verbose\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 5a399aa..8a36e7a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -79,14 +79,16 @@ read_basic_state () {\n \telse\n \t\torig_head=$(cat \"$state_dir\"/head)\n \tfi &&\n-\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n+\tGIT_QUIET=$(cat \"$state_dir\"/quiet) &&\n+\ttest -f \"$state_dir\"/verbose && verbose=t\n }\n \n write_basic_state () {\n \techo \"$head_name\" > \"$state_dir\"/head-name &&\n \techo \"$onto\" > \"$state_dir\"/onto &&\n \techo \"$orig_head\" > \"$state_dir\"/orig-head &&\n-\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet\n+\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet &&\n+\ttest t = \"$verbose\" && : > \"$state_dir\"/verbose\n }\n \n output () {\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160536","messageId":"1297017841-20678-27-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 26/31] rebase: remember strategy and strategy options","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:55Z","receivedAt":"2011-02-06T18:43:55Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"When a rebase is resumed, interactive rebase remembers any merge\nstrategy passed when the rebase was initated. Make non-interactive\nrebase remember any merge strategy as well. Also make non-interactive\nrebase remember any merge strategy options.\n\nTo be able to resume a rebase that was initiated with an older version\nof git (older than this commit), make sure not to expect the saved\noption files to exist.\n\nTest case idea taken from Junio's 71fc224 (t3402: test \"rebase\n-s<strategy> -X<opt>\", 2010-11-11).\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |    2 --\n git-rebase.sh              |    6 ++++++\n t/t3418-rebase-continue.sh |   29 +++++++++++++++++++++++++++++\n 3 files changed, 35 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex f076a6e..5773b75 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -584,7 +584,6 @@ skip_unnecessary_picks () {\n \n get_saved_options () {\n \ttest -d \"$rewritten\" && preserve_merges=t\n-\ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n \ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n@@ -713,7 +712,6 @@ case \"$rebase_root\" in\n *)\n \t: >\"$state_dir\"/rebase-root ;;\n esac\n-test -z \"$strategy\" || echo \"$strategy\" > \"$state_dir\"/strategy\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 8a36e7a..f4ad7c1 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -81,6 +81,9 @@ read_basic_state () {\n \tfi &&\n \tGIT_QUIET=$(cat \"$state_dir\"/quiet) &&\n \ttest -f \"$state_dir\"/verbose && verbose=t\n+\ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n+\ttest -f \"$state_dir\"/strategy_opts &&\n+\t\tstrategy_opts=\"$(cat \"$state_dir\"/strategy_opts)\"\n }\n \n write_basic_state () {\n@@ -89,6 +92,9 @@ write_basic_state () {\n \techo \"$orig_head\" > \"$state_dir\"/orig-head &&\n \techo \"$GIT_QUIET\" > \"$state_dir\"/quiet &&\n \ttest t = \"$verbose\" && : > \"$state_dir\"/verbose\n+\ttest -n \"$strategy\" && echo \"$strategy\" > \"$state_dir\"/strategy\n+\ttest -n \"$strategy_opts\" && echo \"$strategy_opts\" > \\\n+\t\t\"$state_dir\"/strategy_opts\n }\n \n output () {\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 1d90191..5469546 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -45,4 +45,33 @@ test_expect_success 'rebase --continue can not be used with other options' '\n \ttest_must_fail git rebase --continue -v\n '\n \n+test_expect_success 'rebase --continue remembers merge strategy and options' '\n+\trm -fr .git/rebase-* &&\n+\tgit reset --hard commit-new-file-F2-on-topic-branch &&\n+\ttest_commit \"commit-new-file-F3-on-topic-branch\" F3 32 &&\n+\ttest_when_finished \"rm -fr test-bin funny.was.run\" &&\n+\tmkdir test-bin &&\n+\tcat >test-bin/git-merge-funny <<-EOF\n+\t#!$SHELL_PATH\n+\tcase \"\\$1\" in --opt) ;; *) exit 2 ;; esac\n+\tshift &&\n+\t>funny.was.run &&\n+\texec git merge-recursive \"\\$@\"\n+\tEOF\n+\tchmod +x test-bin/git-merge-funny &&\n+\t(\n+\t\tPATH=./test-bin:$PATH\n+\t\ttest_must_fail git rebase -s funny -Xopt master topic\n+\t) &&\n+\ttest -f funny.was.run &&\n+\trm funny.was.run &&\n+\techo \"Resolved\" >F2 &&\n+\tgit add F2 &&\n+\t(\n+\t\tPATH=./test-bin:$PATH\n+\t\tgit rebase --continue\n+\t) &&\n+\ttest -f funny.was.run\n+'\n+\n test_done\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160535","messageId":"1297017841-20678-28-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 27/31] rebase -m: remember allow_rerere_autoupdate option","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:56Z","receivedAt":"2011-02-06T18:43:56Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"If '--[no-]allow_rerere_autoupdate' is passed when 'git rebase -m' is\ncalled and a merge conflict occurs, the flag will be forgotten for the\nrest of the rebase process. Make rebase remember it by saving the\nvalue.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nallow_rerere_autoupdate is only used by git-rebase--merge. Still ok to\nwrite and read it here?\n\nShould allow_rerere_autoupdate also be added to git_am_opt?\n\n\n git-rebase.sh              |    4 ++++\n t/t3418-rebase-continue.sh |   21 +++++++++++++++++++++\n 2 files changed, 25 insertions(+), 0 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex f4ad7c1..be9ec2a 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -84,6 +84,8 @@ read_basic_state () {\n \ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n \ttest -f \"$state_dir\"/strategy_opts &&\n \t\tstrategy_opts=\"$(cat \"$state_dir\"/strategy_opts)\"\n+\ttest -f \"$state_dir\"/allow_rerere_autoupdate &&\n+\t\tallow_rerere_autoupdate=\"$(cat \"$state_dir\"/allow_rerere_autoupdate)\"\n }\n \n write_basic_state () {\n@@ -95,6 +97,8 @@ write_basic_state () {\n \ttest -n \"$strategy\" && echo \"$strategy\" > \"$state_dir\"/strategy\n \ttest -n \"$strategy_opts\" && echo \"$strategy_opts\" > \\\n \t\t\"$state_dir\"/strategy_opts\n+\ttest -n \"$allow_rerere_autoupdate\" && echo \"$allow_rerere_autoupdate\" > \\\n+\t\t\"$state_dir\"/allow_rerere_autoupdate\n }\n \n output () {\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 5469546..1e855cd 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -74,4 +74,25 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '\n \ttest -f funny.was.run\n '\n \n+test_expect_success 'rebase --continue remembers --rerere-autoupdate' '\n+\trm -fr .git/rebase-* &&\n+\tgit reset --hard commit-new-file-F3-on-topic-branch &&\n+\tgit checkout master\n+\ttest_commit \"commit-new-file-F3\" F3 3 &&\n+\tgit config rerere.enabled true &&\n+\ttest_must_fail git rebase -m master topic &&\n+\techo \"Resolved\" >F2 &&\n+\tgit add F2 &&\n+\ttest_must_fail git rebase --continue &&\n+\techo \"Resolved\" >F3 &&\n+\tgit add F3 &&\n+\tgit rebase --continue &&\n+\tgit reset --hard topic@{1} &&\n+\ttest_must_fail git rebase -m --rerere-autoupdate master &&\n+\ttest \"$(cat F2)\" = \"Resolved\" &&\n+\ttest_must_fail git rebase --continue &&\n+\ttest \"$(cat F3)\" = \"Resolved\" &&\n+\tgit rebase --continue\n+'\n+\n test_done\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160528","messageId":"1297017841-20678-29-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 28/31] rebase -m: don't print exit code 2 when merge fails","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:57Z","receivedAt":"2011-02-06T18:43:57Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"When the merge strategy fails, a message suggesting the user to try\nanother strategy is displayed. Remove the \"$rv\" (which is always equal\nto \"2\" in this case) from that message.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--merge.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\nindex eb0f7bc..26afc75 100644\n--- a/git-rebase--merge.sh\n+++ b/git-rebase--merge.sh\n@@ -78,7 +78,7 @@ call_merge () {\n \t\tdie \"$resolvemsg\"\n \t\t;;\n \t2)\n-\t\techo \"Strategy: $rv $strategy failed, try another\" 1>&2\n+\t\techo \"Strategy: $strategy failed, try another\" 1>&2\n \t\tdie \"$resolvemsg\"\n \t\t;;\n \t*)\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160534","messageId":"1297017841-20678-30-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 29/31] git-rebase--am: remove unnecessary --3way option","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:58Z","receivedAt":"2011-02-06T18:43:58Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Since 22db240 (git-am: propagate --3way options as well, 2008-12-04),\nthe --3way has been propageted across failure, so it is since\npointless to pass it to git-am when resuming.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--am.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--am.sh b/git-rebase--am.sh\nindex c9604a6..c815a24 100644\n--- a/git-rebase--am.sh\n+++ b/git-rebase--am.sh\n@@ -7,12 +7,12 @@\n \n case \"$action\" in\n continue)\n-\tgit am --resolved --3way --resolvemsg=\"$resolvemsg\" &&\n+\tgit am --resolved --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n skip)\n-\tgit am --skip -3 --resolvemsg=\"$resolvemsg\" &&\n+\tgit am --skip --resolvemsg=\"$resolvemsg\" &&\n \tmove_to_original_branch\n \texit\n \t;;\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160531","messageId":"1297017841-20678-31-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 30/31] rebase -i: don't read unused variable preserve_merges","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:43:59Z","receivedAt":"2011-02-06T18:43:59Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Since 8e4a91b (rebase -i: remember the settings of -v, -s and -p when\ninterrupted, 2007-07-08), the variable preserve_merges (then called\nPRESERVE_MERGES) was detected from the state saved in\n$GIT_DIR/rebase-merge in order to be used when the rebase resumed, but\nits value was never actually used. The variable's value was only used\nwhen the rebase was initated.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nChanges since v1:\n\n * Added back call to get_saved_options that I had removed by mistake\n   while reordering commits.\n\n git-rebase--interactive.sh |    1 -\n 1 files changed, 0 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 5773b75..cf19bf5 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -583,7 +583,6 @@ skip_unnecessary_picks () {\n }\n \n get_saved_options () {\n-\ttest -d \"$rewritten\" && preserve_merges=t\n \ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n }\n \n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160532","messageId":"1297017841-20678-32-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"[PATCH v2 31/31] rebase -i: remove unnecessary state rebase-root","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-06T18:44:00Z","receivedAt":"2011-02-06T18:44:00Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Before calling 'git cherry-pick', interactive rebase currently checks\nif we are rebasing from root (if --root was passed). If we are, the\n'--ff' flag to 'git cherry-pick' is omitted. However, according to the\ndocumentation for 'git cherry-pick --ff', \"If the current HEAD is the\nsame as the parent of the cherry-picked commit, then a fast forward to\nthis commit will be performed.\". This should never be the case when\nrebasing from root, so it should not matter whether --ff is passed, so\nsimplify the code by removing the condition.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase--interactive.sh |   19 -------------------\n 1 files changed, 0 insertions(+), 19 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex cf19bf5..6566d31 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -168,11 +168,6 @@ pick_one () {\n \toutput git rev-parse --verify $sha1 || die \"Invalid commit name: $sha1\"\n \ttest -d \"$rewritten\" &&\n \t\tpick_one_preserving_merges \"$@\" && return\n-\tif test -n \"$rebase_root\"\n-\tthen\n-\t\toutput git cherry-pick \"$@\"\n-\t\treturn\n-\tfi\n \toutput git cherry-pick $ff \"$@\"\n }\n \n@@ -582,10 +577,6 @@ skip_unnecessary_picks () {\n \tdie \"Could not skip unnecessary pick commands\"\n }\n \n-get_saved_options () {\n-\ttest -f \"$state_dir\"/rebase-root && rebase_root=t\n-}\n-\n # Rearrange the todo list that has both \"pick sha1 msg\" and\n # \"pick sha1 fixup!/squash! msg\" appears in it so that the latter\n # comes immediately after the former, and change \"pick\" to\n@@ -649,8 +640,6 @@ rearrange_squash () {\n \n case \"$action\" in\n continue)\n-\tget_saved_options\n-\n \t# do we have anything to commit?\n \tif git diff-index --cached --quiet --ignore-submodules HEAD --\n \tthen\n@@ -681,8 +670,6 @@ first and then run 'git rebase --continue' again.\"\n \tdo_rest\n \t;;\n skip)\n-\tget_saved_options\n-\n \tgit rerere clear\n \n \tdo_rest\n@@ -705,12 +692,6 @@ mkdir \"$state_dir\" || die \"Could not create temporary $state_dir\"\n \n : > \"$state_dir\"/interactive || die \"Could not mark as interactive\"\n write_basic_state\n-case \"$rebase_root\" in\n-'')\n-\trm -f \"$state_dir\"/rebase-root ;;\n-*)\n-\t: >\"$state_dir\"/rebase-root ;;\n-esac\n if test t = \"$preserve_merges\"\n then\n \tif test -z \"$rebase_root\"\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"160846","messageId":"7vd3mz33xb.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-10T22:44:48Z","receivedAt":"2011-02-10T22:44:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I see there are a few minor fix-ups made since the last round.\n\nThe majority of the difference between the old one and this round was the\ndowncasing of the variables, which was a bit distracting to read the\nremainder, but overall the result looks better.\n\nI am not sure if forbidding \"-v --continue\" adds any value; would it be\ntoo much effort to allow \"--continue -v\" instead to achieve the same\ndegree of consistency between the two?\n\nHonestly speaking, I do not deeply care either way, but the users may want\nto say \"ok, keep going but this time with verbose output\", no?\n"},{"id":"160922","messageId":"alpine.DEB.2.00.1102111811300.26684@debian","threadId":"26148","inReplyTo":"7vd3mz33xb.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-12T00:55:13Z","receivedAt":"2011-02-12T00:55:13Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Thu, 10 Feb 2011, Junio C Hamano wrote:\n\n> I am not sure if forbidding \"-v --continue\" adds any value;\n\nIf I remember correctly, it was just the simplest possible way to not\nhave to handle cases like \"-i/-p/-m --continue\" specially.\n\n> would it be\n> too much effort to allow \"--continue -v\" instead to achieve the same\n> degree of consistency between the two?\n\nI think it would be doable. Maybe something like:\n\n * Check that only the allowable options (-v/-q, -s, -X,\n   --[no-]rerere-autoupdate) are passed together with --continue or\n   --skip. For simplicity, maybe we can just accept the same set of\n   flags with --abort as well, even though only -v/-q would make any\n   sense.\n\n * When reading the saved state, first check for each of the options\n   if it is already set. If it is, write it to disk instead, to make\n   sure it is remembered across future interruptions. Otherwise, just\n   read it as usual.\n\nI think that should be all that's needed. I'll have a look at it when\nI get some time.\n\n\n/Martin\n"},{"id":"161020","messageId":"alpine.DEB.2.00.1102132047500.4253@debian","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102111811300.26684@debian","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-14T01:54:55Z","receivedAt":"2011-02-14T01:54:55Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Fri, 11 Feb 2011, Martin von Zweigbergk wrote:\n\n> On Thu, 10 Feb 2011, Junio C Hamano wrote:\n> \n> > I am not sure if forbidding \"-v --continue\" adds any value; would it be\n> > too much effort to allow \"--continue -v\" instead to achieve the same\n> > degree of consistency between the two?\n> \n> I'll have a look at it when\n> I get some time.\n\nThis would apply on top of mz/rebase after dropping 95135b0 (rebase:\nstricter check of standalone sub command, 2011-02-06). If you agree\nwith it, I will include it in a future re-roll.\n\n-- 8< --\nSubject: [PATCH/RFC] rebase: allow options to be overridden when resuming\n\nThe sub commands '--continue', '--skip' or '--abort' may only be used\nstandalone according to the documentation. Other options following the\nsub command are currently not accepted, but options preceeding them\nare. For example, 'git rebase --continue -v' is not accepted, while\n'git rebase -v --continue' is. In the latter case, the verbose option\nwill only be used until the rebase is interrupted (e.g. for editing,\nor due to conflict). From that point on, the intial settings will be\nused again.\n\nImprove the situation by allowing options to be combined with sub\ncommands both before and after the sub command itself. Persist the new\nvalue to make sure it is remembered across interruptions.\n\nFail if options that can not be used together with sub commands, such\nas '-i', are used. For simplicity, allow the same set of options for\nall three sub commands, even though e.g. '-s' makes no sense when\ncombined with '--abort'.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n Documentation/git-rebase.txt |    2 +-\n git-rebase.sh                |   51 ++++++++++++++++++++++++++++++++----------\n t/t3418-rebase-continue.sh   |   12 ++++++++++\n 3 files changed, 52 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt\nindex 96680c8..095a67f 100644\n--- a/Documentation/git-rebase.txt\n+++ b/Documentation/git-rebase.txt\n@@ -13,7 +13,7 @@ SYNOPSIS\n 'git rebase' [-i | --interactive] [options] --onto <newbase>\n \t--root [<branch>]\n \n-'git rebase' --continue | --skip | --abort\n+'git rebase' --continue | --skip | --abort [options]\n \n DESCRIPTION\n -----------\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 34a2a0a..5abfeac 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -67,6 +67,16 @@ preserve_merges=\n autosquash=\n test \"$(git config --bool rebase.autosquash)\" = \"true\" && autosquash=t\n \n+write_options() {\n+\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet &&\n+\ttest t = \"$verbose\" && : > \"$state_dir\"/verbose\n+\ttest -n \"$strategy\" && echo \"$strategy\" > \"$state_dir\"/strategy\n+\ttest -n \"$strategy_opts\" && echo \"$strategy_opts\" > \\\n+\t\t\"$state_dir\"/strategy_opts\n+\ttest -n \"$allow_rerere_autoupdate\" && echo \"$allow_rerere_autoupdate\" > \\\n+\t\t\"$state_dir\"/allow_rerere_autoupdate\n+}\n+\n read_basic_state () {\n \thead_name=$(cat \"$state_dir\"/head-name) &&\n \tonto=$(cat \"$state_dir\"/onto) &&\n@@ -78,9 +88,21 @@ read_basic_state () {\n \t\torig_head=$(cat \"$state_dir\"/orig-head)\n \telse\n \t\torig_head=$(cat \"$state_dir\"/head)\n-\tfi &&\n-\tGIT_QUIET=$(cat \"$state_dir\"/quiet) &&\n-\ttest -f \"$state_dir\"/verbose && verbose=t\n+\tfi\n+\t# First write any overriding options from the command line\n+\twrite_options\n+\tif test -n \"$GIT_QUIET\"\n+\tthen\n+\t\trm \"$state_dir\"/verbose\n+\telse\n+\t\tGIT_QUIET=$(cat \"$state_dir\"/quiet)\n+\tfi\n+\tif test t = \"$verbose\"\n+\tthen\n+\t\trm \"$state_dir\"/quiet\n+\telse\n+\t\ttest -f \"$state_dir\"/verbose && verbose=t\n+\tfi\n \ttest -f \"$state_dir\"/strategy && strategy=\"$(cat \"$state_dir\"/strategy)\"\n \ttest -f \"$state_dir\"/strategy_opts &&\n \t\tstrategy_opts=\"$(cat \"$state_dir\"/strategy_opts)\"\n@@ -92,13 +114,7 @@ write_basic_state () {\n \techo \"$head_name\" > \"$state_dir\"/head-name &&\n \techo \"$onto\" > \"$state_dir\"/onto &&\n \techo \"$orig_head\" > \"$state_dir\"/orig-head &&\n-\techo \"$GIT_QUIET\" > \"$state_dir\"/quiet &&\n-\ttest t = \"$verbose\" && : > \"$state_dir\"/verbose\n-\ttest -n \"$strategy\" && echo \"$strategy\" > \"$state_dir\"/strategy\n-\ttest -n \"$strategy_opts\" && echo \"$strategy_opts\" > \\\n-\t\t\"$state_dir\"/strategy_opts\n-\ttest -n \"$allow_rerere_autoupdate\" && echo \"$allow_rerere_autoupdate\" > \\\n-\t\t\"$state_dir\"/allow_rerere_autoupdate\n+\twrite_options\n }\n \n output () {\n@@ -164,6 +180,7 @@ then\n fi\n test -n \"$type\" && in_progress=t\n \n+resume_incompatible=\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -174,11 +191,11 @@ do\n \t\tok_to_skip_pre_rebase=\n \t\t;;\n \t--continue|--skip|--abort)\n+\t\ttest -n \"$action\" && usage\n \t\taction=${1##--}\n-\t\tshift\n-\t\tbreak\n \t\t;;\n \t--onto)\n+\t\tresume_incompatible=t\n \t\ttest 2 -le \"$#\" || usage\n \t\tonto=\"$2\"\n \t\tshift\n@@ -197,6 +214,7 @@ do\n \t\tautosquash=\n \t\t;;\n \t-M|-m|--m|--me|--mer|--merg|--merge)\n+\t\tresume_incompatible=t\n \t\tdo_merge=t\n \t\t;;\n \t-X*|--strategy-option*)\n@@ -232,9 +250,11 @@ do\n \t\tdo_merge=t\n \t\t;;\n \t-n|--no-stat)\n+\t\tresume_incompatible=t\n \t\tdiffstat=\n \t\t;;\n \t--stat)\n+\t\tresume_incompatible=t\n \t\tdiffstat=t\n \t\t;;\n \t-v|--verbose)\n@@ -249,6 +269,7 @@ do\n \t\tdiffstat=\n \t\t;;\n \t--whitespace=*)\n+\t\tresume_incompatible=t\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\tcase \"$1\" in\n \t\t--whitespace=fix|--whitespace=strip)\n@@ -257,19 +278,24 @@ do\n \t\tesac\n \t\t;;\n \t--ignore-whitespace)\n+\t\tresume_incompatible=t\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\t;;\n \t--committer-date-is-author-date|--ignore-date)\n+\t\tresume_incompatible=t\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\tforce_rebase=t\n \t\t;;\n \t-C*)\n+\t\tresume_incompatible=t\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\t;;\n \t--root)\n+\t\tresume_incompatible=t\n \t\trebase_root=t\n \t\t;;\n \t-f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)\n+\t\tresume_incompatible=t\n \t\tforce_rebase=t\n \t\t;;\n \t--rerere-autoupdate|--no-rerere-autoupdate)\n@@ -288,6 +314,7 @@ test $# -gt 2 && usage\n \n if test -n \"$action\"\n then\n+\ttest -n \"$resume_incompatible\" && \"--$action used with incompatible option\"\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \t# Only interactive rebase uses detailed reflog messages\n \tif test \"$type\" = interactive && test \"$GIT_REFLOG_ACTION\" = rebase\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 15cef3c..1581f00 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -90,4 +90,16 @@ test_expect_success 'rebase --continue remembers --rerere-autoupdate' '\n \tgit rebase --continue\n '\n \n+test_expect_success 'rebase --continue --no-rerere-autoupdate overrides' '\n+\trm -fr .git/rebase-* &&\n+\tgit reset --hard topic@{1} &&\n+\ttest_must_fail git rebase -m --rerere-autoupdate master &&\n+\ttest \"$(cat F2)\" = \"Resolved\" &&\n+\tgit rebase --continue --no-rerere-autoupdate &&\n+\ttest \"$(cat F3)\" = \"Resolved\" &&\n+\ttest_must_fail git rebase --continue &&\n+\tgit add F3 &&\n+\tgit rebase --continue\n+'\n+\n test_done\n-- \n1.7.4.rc2.33.g8a14f\n"},{"id":"161023","messageId":"alpine.DEB.2.00.1102132205110.4253@debian","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102132047500.4253@debian","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-14T03:15:11Z","receivedAt":"2011-02-14T03:15:11Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Sun, 13 Feb 2011, Martin von Zweigbergk wrote:\n\n> On Fri, 11 Feb 2011, Martin von Zweigbergk wrote:\n> \n> > On Thu, 10 Feb 2011, Junio C Hamano wrote:\n> > \n> > > I am not sure if forbidding \"-v --continue\" adds any value; would it be\n> > > too much effort to allow \"--continue -v\" instead to achieve the same\n> > > degree of consistency between the two?\n> > \n> > I'll have a look at it when\n> > I get some time.\n> \n> This would apply on top of mz/rebase after dropping 95135b0 (rebase:\n> stricter check of standalone sub command, 2011-02-06). If you agree\n> with it, I will include it in a future re-roll.\n\nSorry, anyone who intends to test it, squash in this missing\ntest_must_fail first.\n\n-- 8< --\ndiff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh\nindex 1581f00..02ac92f 100755\n--- a/t/t3418-rebase-continue.sh\n+++ b/t/t3418-rebase-continue.sh\n@@ -95,7 +95,7 @@ test_expect_success 'rebase --continue --no-rerere-autoupdate overrides' '\n \tgit reset --hard topic@{1} &&\n \ttest_must_fail git rebase -m --rerere-autoupdate master &&\n \ttest \"$(cat F2)\" = \"Resolved\" &&\n-\tgit rebase --continue --no-rerere-autoupdate &&\n+\ttest_must_fail git rebase --continue --no-rerere-autoupdate &&\n \ttest \"$(cat F3)\" = \"Resolved\" &&\n \ttest_must_fail git rebase --continue &&\n \tgit add F3 &&\n"},{"id":"161032","messageId":"4D58E17C.9090001@viscovery.net","threadId":"26148","inReplyTo":"1297017841-20678-19-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-02-14T08:02:04Z","receivedAt":"2011-02-14T08:02:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 2/6/2011 19:43, schrieb Martin von Zweigbergk:\n> diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\n> new file mode 100644\n> index 0000000..c04ce8a\n> --- /dev/null\n> +++ b/git-rebase--merge.sh\n\nThis should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n\n-- Hannes\n"},{"id":"161047","messageId":"alpine.DEB.2.00.1102140854580.4346@debian","threadId":"26148","inReplyTo":"4D58E17C.9090001@viscovery.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-14T13:56:02Z","receivedAt":"2011-02-14T13:56:02Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Mon, 14 Feb 2011, Johannes Sixt wrote:\n\n> Am 2/6/2011 19:43, schrieb Martin von Zweigbergk:\n> > diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\n> > new file mode 100644\n> > index 0000000..c04ce8a\n> > --- /dev/null\n> > +++ b/git-rebase--merge.sh\n> \n> This should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n\nThanks.\n"},{"id":"161137","messageId":"7v62smqgkb.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102132047500.4253@debian","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-15T00:36:52Z","receivedAt":"2011-02-15T00:36:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n\n> Improve the situation by allowing options to be combined with sub\n> commands both before and after the sub command itself. Persist the new\n> value to make sure it is remembered across interruptions.\n\nI somehow suspected that it would be much more messy, but with your\nrefactoring, things do not look that bad as I feared ;-)\n\nThe only use case it might be useful, however, is to start without -v,\nrealize that a verbose output may help you resolve conflicts better, and\ncontinuing with the verbose option, which conceptually should be helpful.\n\nBut in practice I doubt the ability to ask for -v output in the middle\nwould be so helpful, so doing this may not be worth it.\n\nI am not a regular rebaser anymore, so I wouldn't be a good judge beyond\njust my gut feeling.  Comments from heavy rebase users who often see\nconflicts are appreciated.\n"},{"id":"161304","messageId":"4D5BE49D.1040402@viscovery.net","threadId":"26148","inReplyTo":"1297017841-20678-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-02-16T14:52:13Z","receivedAt":"2011-02-16T14:52:13Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"There's one annoying regression with this series: It does not accept\nabbreviated options anymore. In particular, 'git rebase --cont' is now an\nerror. I use this a lot since I don't have command completion. This used\nto work (only) with interactive rebase.\n\nAnd a side note: the error message is -- during a rebase that stopped at\nan 'edit' instruction:\n\n$ git rebase --cont\nUsage: git rebase [--interactive | -i] [-v] [--force-rebase | -f]\n[--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]\n\nIt nowhere mentions --continue, --skip, --abort etc. That's perhaps worth\nfixing.\n\n-- Hannes\n"},{"id":"161366","messageId":"alpine.DEB.2.00.1102162212360.14950@debian","threadId":"26148","inReplyTo":"4D5BE49D.1040402@viscovery.net","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-17T03:41:55Z","receivedAt":"2011-02-17T03:41:55Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Wed, 16 Feb 2011, Johannes Sixt wrote:\n\n> There's one annoying regression with this series: It does not accept\n> abbreviated options anymore. In particular, 'git rebase --cont' is now an\n> error. I use this a lot since I don't have command completion. This used\n> to work (only) with interactive rebase.\n\nSorry about that :-(. That must of course be because I removed the\nOPTIONS_SPEC from git-rebase--interactive.sh. Sounds like I should add\nit back in git-rebase.sh. Can someone explain what the\nOPTIONS_KEEPDASHDASH is for? Should I add that as well?\n\n> And a side note: the error message is -- during a rebase that stopped at\n> an 'edit' instruction:\n> \n> $ git rebase --cont\n> Usage: git rebase [--interactive | -i] [-v] [--force-rebase | -f]\n> [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]\n> \n> It nowhere mentions --continue, --skip, --abort etc. That's perhaps worth\n> fixing.\n\nMakes sense. If others agree, I will add that as well.\n\n/Martin\n"},{"id":"161876","messageId":"alpine.DEB.2.00.1102220847500.5290@debian","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102132047500.4253@debian","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-22T13:58:09Z","receivedAt":"2011-02-22T13:58:09Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Sun, 13 Feb 2011, Martin von Zweigbergk wrote:\n\n> On Fri, 11 Feb 2011, Martin von Zweigbergk wrote:\n> \n> > On Thu, 10 Feb 2011, Junio C Hamano wrote:\n> > \n> > > I am not sure if forbidding \"-v --continue\" adds any value; would it be\n> > > too much effort to allow \"--continue -v\" instead to achieve the same\n> > > degree of consistency between the two?\n> > \n> > I'll have a look at it when\n> > I get some time.\n> \n> This would apply on top of mz/rebase after dropping 95135b0 (rebase:\n> stricter check of standalone sub command, 2011-02-06). If you agree\n> with it, I will include it in a future re-roll.\n\nAny opinions about this, anyone? I have one example: I was rebasing\nsome things the other day where I thought there would be no conflicts.\nAfter applying a number of patches, it turned out there were\nconflicts. I think allowing 'git rebase --continue -sours' would have\nbeen useful in that case. It's rare enough that I don't care much,\nthough.\n\nThe reason I'm asking is that I have a patch that fixes the problems\nwith the command line parsing that Johannes Sixt pointed out in\nanother mail on this thread and would like to know if I should make it\napply on top of this patch or not.\n\n\n/Martin\n"},{"id":"161906","messageId":"7vd3mjdge1.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102220847500.5290@debian","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-22T19:21:42Z","receivedAt":"2011-02-22T19:21:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n\n> On Sun, 13 Feb 2011, Martin von Zweigbergk wrote:\n> ...\n>> This would apply on top of mz/rebase after dropping 95135b0 (rebase:\n>> stricter check of standalone sub command, 2011-02-06). If you agree\n>> with it, I will include it in a future re-roll.\n>\n> Any opinions about this, anyone? I have one example: I was rebasing\n> some things the other day where I thought there would be no conflicts.\n> After applying a number of patches, it turned out there were\n> conflicts. I think allowing 'git rebase --continue -sours' would have\n> been useful in that case. It's rare enough that I don't care much,\n> though.\n\nHmm, do you think applying -sours throughout to the rest of the series\nwould have been a safe thing, or do you think you would rather wanted to\nsee -sours applied only to that particular one?\n\n> The reason I'm asking is that I have a patch that fixes the problems\n> with the command line parsing that Johannes Sixt pointed out in\n> another mail on this thread and would like to know if I should make it\n> apply on top of this patch or not.\n\nIt is a good idea to build a change you are more certain of first,\nexcluding the ones you have doubts about.\n\nBesides, this part of the patch would need fixing anyway ;-)\n\n@@ -288,6 +314,7 @@ test $# -gt 2 && usage\n \n if test -n \"$action\"\n then\n+\ttest -n \"$resume_incompatible\" && \"--$action used with incompatible option\"\n \ttest -z \"$in_progress\" && die \"No rebase in progress?\"\n \t# Only interactive rebase uses detailed reflog messages\n \tif test \"$type\" = interactive && test \"$GIT_REFLOG_ACTION\" = rebase\n"},{"id":"162020","messageId":"alpine.DEB.2.00.1102230613040.5290@debian","threadId":"26148","inReplyTo":"7vd3mjdge1.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 00/31] refactor rebase","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-23T11:26:33Z","receivedAt":"2011-02-23T11:26:33Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Tue, 22 Feb 2011, Junio C Hamano wrote:\n\n> Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n> \n> > On Sun, 13 Feb 2011, Martin von Zweigbergk wrote:\n> > ...\n> >> This would apply on top of mz/rebase after dropping 95135b0 (rebase:\n> >> stricter check of standalone sub command, 2011-02-06). If you agree\n> >> with it, I will include it in a future re-roll.\n> >\n> > Any opinions about this, anyone? I have one example: I was rebasing\n> > some things the other day where I thought there would be no conflicts.\n> > After applying a number of patches, it turned out there were\n> > conflicts. I think allowing 'git rebase --continue -sours' would have\n> > been useful in that case. It's rare enough that I don't care much,\n> > though.\n> \n> Hmm, do you think applying -sours throughout to the rest of the series\n> would have been a safe thing, or do you think you would rather wanted to\n> see -sours applied only to that particular one?\n\nIn this particular case, I actually wanted it on the rest of the\nseries, but it was such a degenerate case that it doesn't really\nmatter (I just wanted the history graph for testing and didn't care\nabout the trees).\n\n> > The reason I'm asking is that I have a patch that fixes the problems\n> > with the command line parsing that Johannes Sixt pointed out in\n> > another mail on this thread and would like to know if I should make it\n> > apply on top of this patch or not.\n> \n> It is a good idea to build a change you are more certain of first,\n> excluding the ones you have doubts about.\n\nTrue. Will do.\n\nLet's leave this patch for now then and get back to it in a few years\nwhen/if someone actually requests it ;-). I agree that it's not clear\nat this point what the desired behavior is.\n"},{"id":"162101","messageId":"1298516875-10765-1-git-send-email-martin.von.zweigbergk@gmail.com","threadId":"26148","inReplyTo":"4D5BE49D.1040402@viscovery.net","subject":"[PATCH] rebase: define options in OPTIONS_SPEC","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-24T03:07:55Z","receivedAt":"2011-02-24T03:07:55Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Interactive rebase used to have its own command line processing. Since\nit used the 'git rev-parse --parseopt' functionality exposed through\ngit-sh-setup, it had some flexibility, like matching prefixes of long\noptions, that non-interactive rebase didn't. When interactive rebase's\ncommand line processing was factored out into git-rebase.sh in cf432ca\n(rebase: factor out command line option processing, 2011-02-06), this\nflexibility was lost. Give back that flexibility to interactive and\nnon-interactive.\n\nAlso improve the usage message to contain the --continue, --skip and\n--abort commands.\n---\n\nApplies on top of mz/rebase.\n\nAre USAGE and LONG_USAGE still needed?\n\nI based the definitions on the now-lost OPTIONS_SPEC from interactive\nrebase. I added some descriptions that were not too hard to describe\nin a concise way. The rest, I simply hid (with the \"*\" marker). Should\nthe list be exhaustive?\n\nWhat is the difference between the \"options\" and \"actions\" sections?\n\n git-rebase.sh |  104 ++++++++++++++++++++++++++++++++------------------------\n 1 files changed, 59 insertions(+), 45 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex a040ab5..7857059 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -28,7 +28,42 @@ Example:       git-rebase master~1 topic\n '\n \n SUBDIRECTORY_OK=Yes\n-OPTIONS_SPEC=\n+OPTIONS_KEEPDASHDASH=\n+OPTIONS_SPEC=\"\\\n+git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]\n+git rebase [-i] [options] --onto <newbase> --root [<branch>]\n+git-rebase [-i] --continue | --abort | --skip\n+--\n+ Available options are\n+v,verbose          display a diffstat of what changed upstream\n+q,quiet            be quiet. implies --no-stat\n+onto=              rebase onto given branch instead of upstream\n+p,preserve-merges  try to recreate merges instead of ignoring them\n+s,strategy=        use the given merge strategy\n+no-ff              cherry-pick all commits, even if unchanged\n+m,merge            use merging strategies to rebase\n+i,interactive      let the user edit the list of commits to rebase\n+f,force-rebase*    -\n+X,strategy-option= pass the argument through to the merge strategy\n+stat*              -\n+n,no-stat*         -\n+whitespace=*       -\n+ignore-whitespace* -\n+committer-date-is-author-date* -\n+ignore-date*       -\n+C=*                -\n+rerere-autoupdate* -\n+no-rerere-autoupdate* -\n+ Actions:\n+continue           continue rebasing process\n+abort              abort rebasing process and restore original branch\n+skip               skip current patch and continue rebasing process\n+no-verify          override pre-rebase hook from stopping the operation\n+verify             allow pre-rebase hook to run\n+root               rebase all reachable commmits up to the root(s)\n+autosquash         move commits that begin with squash!/fixup! under -i\n+no-autosquash*     -\n+\"\n . git-sh-setup\n set_reflog_action rebase\n require_work_tree\n@@ -175,7 +210,7 @@ do\n \t\tok_to_skip_pre_rebase=\n \t\t;;\n \t--continue|--skip|--abort)\n-\t\ttest $total_argc -eq 1 || usage\n+\t\ttest $total_argc -eq 2 || usage\n \t\taction=${1##--}\n \t\t;;\n \t--onto)\n@@ -183,10 +218,10 @@ do\n \t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n-\t-i|--interactive)\n+\t-i)\n \t\tinteractive_rebase=explicit\n \t\t;;\n-\t-p|--preserve-merges)\n+\t-p)\n \t\tpreserve_merges=t\n \t\ttest -z \"$interactive_rebase\" && interactive_rebase=implied\n \t\t;;\n@@ -196,62 +231,42 @@ do\n \t--no-autosquash)\n \t\tautosquash=\n \t\t;;\n-\t-M|-m|--m|--me|--mer|--merg|--merge)\n+\t-M|-m)\n \t\tdo_merge=t\n \t\t;;\n-\t-X*|--strategy-option*)\n-\t\tcase \"$#,$1\" in\n-\t\t1,-X|1,--strategy-option)\n-\t\t\tusage ;;\n-\t\t*,-X|*,--strategy-option)\n-\t\t\tnewopt=\"$2\"\n-\t\t\tshift ;;\n-\t\t*,--strategy-option=*)\n-\t\t\tnewopt=\"$(expr \" $1\" : ' --strategy-option=\\(.*\\)')\" ;;\n-\t\t*,-X*)\n-\t\t\tnewopt=\"$(expr \" $1\" : ' -X\\(.*\\)')\" ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\tesac\n-\t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$newopt\")\"\n+\t-X)\n+\t\tshift\n+\t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$1\")\"\n \t\tdo_merge=t\n \t\ttest -z \"$strategy\" && strategy=recursive\n \t\t;;\n-\t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n-\t\t--strateg=*|--strategy=*|\\\n-\t-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tstrategy=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tstrategy=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n+\t-s)\n+\t\tshift\n+\t\tstrategy=\"$1\"\n \t\tdo_merge=t\n \t\t;;\n-\t-n|--no-stat)\n+\t-n)\n \t\tdiffstat=\n \t\t;;\n \t--stat)\n \t\tdiffstat=t\n \t\t;;\n-\t-v|--verbose)\n+\t-v)\n \t\tverbose=t\n \t\tdiffstat=t\n \t\tGIT_QUIET=\n \t\t;;\n-\t-q|--quiet)\n+\t-q)\n \t\tGIT_QUIET=t\n \t\tgit_am_opt=\"$git_am_opt -q\"\n \t\tverbose=\n \t\tdiffstat=\n \t\t;;\n-\t--whitespace=*)\n-\t\tgit_am_opt=\"$git_am_opt $1\"\n+\t--whitespace)\n+\t\tshift\n+\t\tgit_am_opt=\"$git_am_opt --whitespace=$1\"\n \t\tcase \"$1\" in\n-\t\t--whitespace=fix|--whitespace=strip)\n+\t\tfix|strip)\n \t\t\tforce_rebase=t\n \t\t\t;;\n \t\tesac\n@@ -263,22 +278,21 @@ do\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\tforce_rebase=t\n \t\t;;\n-\t-C*)\n-\t\tgit_am_opt=\"$git_am_opt $1\"\n+\t-C)\n+\t\tshift\n+\t\tgit_am_opt=\"$git_am_opt -C$1\"\n \t\t;;\n \t--root)\n \t\trebase_root=t\n \t\t;;\n-\t-f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)\n+\t-f|--no-ff)\n \t\tforce_rebase=t\n \t\t;;\n \t--rerere-autoupdate|--no-rerere-autoupdate)\n \t\tallow_rerere_autoupdate=\"$1\"\n \t\t;;\n-\t-*)\n-\t\tusage\n-\t\t;;\n-\t*)\n+\t--)\n+\t\tshift\n \t\tbreak\n \t\t;;\n \tesac\n-- \n1.7.4.1.79.gba571.dirty\n"},{"id":"162104","messageId":"alpine.DEB.2.00.1102232216180.11038@debian","threadId":"26148","inReplyTo":"4D58E17C.9090001@viscovery.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-24T03:27:23Z","receivedAt":"2011-02-24T03:27:23Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Mon, 14 Feb 2011, Johannes Sixt wrote:\n\n> Am 2/6/2011 19:43, schrieb Martin von Zweigbergk:\n> > diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh\n> > new file mode 100644\n> > index 0000000..c04ce8a\n> > --- /dev/null\n> > +++ b/git-rebase--merge.sh\n> \n> This should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n\nI was just about to fix now and I noticed that quite a few other\nscript files are mode 100644. Should all be changed to mode 100755 or\nis there some kind of rule as to which mode they should be? Both\ngit-sh-setup.sh and git-parse-remote.sh are also mode 100644 and I\n(think I) know that both are always sourced. If the rule is that\nsourced scripts should be mode 100644 (but I'm just guessing here),\nthen I should actually have changed the mode of\ngit-rebase--interactive.sh to that mode instead. Please advice.\n\n\n/Martin\n"},{"id":"162109","messageId":"20110224080734.GB25595@sigill.intra.peff.net","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102232216180.11038@debian","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-24T08:07:34Z","receivedAt":"2011-02-24T08:07:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 23, 2011 at 10:27:23PM -0500, Martin von Zweigbergk wrote:\n\n> > > +++ b/git-rebase--merge.sh\n> > \n> > This should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n> \n> I was just about to fix now and I noticed that quite a few other\n> script files are mode 100644. Should all be changed to mode 100755 or\n> is there some kind of rule as to which mode they should be? Both\n> git-sh-setup.sh and git-parse-remote.sh are also mode 100644 and I\n> (think I) know that both are always sourced. If the rule is that\n> sourced scripts should be mode 100644 (but I'm just guessing here),\n> then I should actually have changed the mode of\n> git-rebase--interactive.sh to that mode instead. Please advice.\n\nYes, sourced scripts should not have an executable bit. See 46bac90 for\nrationale.\n\n-Peff\n"},{"id":"162110","messageId":"20110224080904.GC25595@sigill.intra.peff.net","threadId":"26148","inReplyTo":"20110224080734.GB25595@sigill.intra.peff.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-24T08:09:04Z","receivedAt":"2011-02-24T08:09:04Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 24, 2011 at 03:07:34AM -0500, Jeff King wrote:\n\n> On Wed, Feb 23, 2011 at 10:27:23PM -0500, Martin von Zweigbergk wrote:\n> \n> > > > +++ b/git-rebase--merge.sh\n> > > \n> > > This should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n> > \n> > I was just about to fix now and I noticed that quite a few other\n> > script files are mode 100644. Should all be changed to mode 100755 or\n> > is there some kind of rule as to which mode they should be? Both\n> > git-sh-setup.sh and git-parse-remote.sh are also mode 100644 and I\n> > (think I) know that both are always sourced. If the rule is that\n> > sourced scripts should be mode 100644 (but I'm just guessing here),\n> > then I should actually have changed the mode of\n> > git-rebase--interactive.sh to that mode instead. Please advice.\n> \n> Yes, sourced scripts should not have an executable bit. See 46bac90 for\n> rationale.\n\nAnd I should have mentioned: they should go in SCRIPT_LIB in the\nMakefile, not SCRIPT_SH.\n\n-Peff\n"},{"id":"162205","messageId":"alpine.DEB.2.00.1102242229230.11894@debian","threadId":"26148","inReplyTo":"20110224080904.GC25595@sigill.intra.peff.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-02-25T03:32:06Z","receivedAt":"2011-02-25T03:32:06Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Thu, 24 Feb 2011, Jeff King wrote:\n\n> On Thu, Feb 24, 2011 at 03:07:34AM -0500, Jeff King wrote:\n> \n> > On Wed, Feb 23, 2011 at 10:27:23PM -0500, Martin von Zweigbergk wrote:\n> > \n> > > > > +++ b/git-rebase--merge.sh\n> > > > \n> > > > This should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n> > > \n> > > I was just about to fix now and I noticed that quite a few other\n> > > script files are mode 100644. Should all be changed to mode 100755 or\n> > > is there some kind of rule as to which mode they should be? Both\n> > > git-sh-setup.sh and git-parse-remote.sh are also mode 100644 and I\n> > > (think I) know that both are always sourced. If the rule is that\n> > > sourced scripts should be mode 100644 (but I'm just guessing here),\n> > > then I should actually have changed the mode of\n> > > git-rebase--interactive.sh to that mode instead. Please advice.\n> > \n> > Yes, sourced scripts should not have an executable bit. See 46bac90 for\n> > rationale.\n> \n> And I should have mentioned: they should go in SCRIPT_LIB in the\n> Makefile, not SCRIPT_SH.\n\nThanks. The below should hopefully fix my mistakes.\n\n-- 8< --\nSubject: [PATCH] Makefile: do not install sourced rebase scripts\n\nWhen git-rebase.sh recently started sourcing\ngit-rebase--interactive.sh instead of executing it, executable bit of\nthe latter file should have been turned off and it should have been\nmoved from SCRIPT_SH to SCRIPT_LIB in the Makefile. Its two new\nsiblings, git-rebase--am.sh and git-rebase--merge.sh (whose executable\nbits are already off) should also be moved to SCRIPT_LIB in the\nMakefile.\n\nReported-by: Johannes Sixt <j6t@kdbg.org>\nHelped-by: Jeff King <peff@peff.net>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nApplies on top of mz/rebase.\n\n Makefile                   |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n mode change 100755 => 100644 git-rebase--interactive.sh\n\ndiff --git a/Makefile b/Makefile\nindex b2501cc..e722b95 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -369,9 +369,6 @@ SCRIPT_SH += git-merge-resolve.sh\n SCRIPT_SH += git-mergetool.sh\n SCRIPT_SH += git-pull.sh\n SCRIPT_SH += git-quiltimport.sh\n-SCRIPT_SH += git-rebase--am.sh\n-SCRIPT_SH += git-rebase--interactive.sh\n-SCRIPT_SH += git-rebase--merge.sh\n SCRIPT_SH += git-rebase.sh\n SCRIPT_SH += git-repack.sh\n SCRIPT_SH += git-request-pull.sh\n@@ -382,6 +379,9 @@ SCRIPT_SH += git-web--browse.sh\n SCRIPT_LIB += git-mergetool--lib\n SCRIPT_LIB += git-parse-remote\n SCRIPT_LIB += git-sh-setup\n+SCRIPT_LIB += git-rebase--am.sh\n+SCRIPT_LIB += git-rebase--interactive.sh\n+SCRIPT_LIB += git-rebase--merge.sh\n \n SCRIPT_PERL += git-add--interactive.perl\n SCRIPT_PERL += git-difftool.perl\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nold mode 100755\nnew mode 100644\n-- \n1.7.4.1.79.gba571.dirty\n"},{"id":"162218","messageId":"20110225090238.GB16861@sigill.intra.peff.net","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1102242229230.11894@debian","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-02-25T09:02:39Z","receivedAt":"2011-02-25T09:02:39Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 24, 2011 at 10:32:06PM -0500, Martin von Zweigbergk wrote:\n\n> Subject: [PATCH] Makefile: do not install sourced rebase scripts\n> \n> When git-rebase.sh recently started sourcing\n> git-rebase--interactive.sh instead of executing it, executable bit of\n> the latter file should have been turned off and it should have been\n> moved from SCRIPT_SH to SCRIPT_LIB in the Makefile. Its two new\n> siblings, git-rebase--am.sh and git-rebase--merge.sh (whose executable\n> bits are already off) should also be moved to SCRIPT_LIB in the\n> Makefile.\n\nLooks right, but...\n\n> @@ -382,6 +379,9 @@ SCRIPT_SH += git-web--browse.sh\n>  SCRIPT_LIB += git-mergetool--lib\n>  SCRIPT_LIB += git-parse-remote\n>  SCRIPT_LIB += git-sh-setup\n> +SCRIPT_LIB += git-rebase--am.sh\n> +SCRIPT_LIB += git-rebase--interactive.sh\n> +SCRIPT_LIB += git-rebase--merge.sh\n\nWe usually keep these sorted.\n\n-Peff\n"},{"id":"162268","messageId":"7vwrkn9815.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"20110225090238.GB16861@sigill.intra.peff.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-25T20:24:54Z","receivedAt":"2011-02-25T20:24:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> Looks right, but...\n>\n>> @@ -382,6 +379,9 @@ SCRIPT_SH += git-web--browse.sh\n>>  SCRIPT_LIB += git-mergetool--lib\n>>  SCRIPT_LIB += git-parse-remote\n>>  SCRIPT_LIB += git-sh-setup\n>> +SCRIPT_LIB += git-rebase--am.sh\n>> +SCRIPT_LIB += git-rebase--interactive.sh\n>> +SCRIPT_LIB += git-rebase--merge.sh\n>\n> We usually keep these sorted.\n\nAlso SCRIPT_LIB omits .sh (which feels inconsistent) and the above will\nbreak the build.\n\nNo need to resend, as I've already fixed it up.\n\nThanks.\n"},{"id":"162269","messageId":"m3sjvb7tg4.fsf@localhost.localdomain","threadId":"26148","inReplyTo":"20110224080904.GC25595@sigill.intra.peff.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-02-25T20:27:03Z","receivedAt":"2011-02-25T20:27:03Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Jeff King <peff@peff.net> writes:\n> On Thu, Feb 24, 2011 at 03:07:34AM -0500, Jeff King wrote:\n> > On Wed, Feb 23, 2011 at 10:27:23PM -0500, Martin von Zweigbergk wrote:\n> > \n> > > > > +++ b/git-rebase--merge.sh\n> > > > \n> > > > This should be mode 100755. (Ditto for git-rebase--am.sh in 19/31)\n> > > \n> > > I was just about to fix now and I noticed that quite a few other\n> > > script files are mode 100644. Should all be changed to mode 100755 or\n> > > is there some kind of rule as to which mode they should be? Both\n> > > git-sh-setup.sh and git-parse-remote.sh are also mode 100644 and I\n> > > (think I) know that both are always sourced. If the rule is that\n> > > sourced scripts should be mode 100644 (but I'm just guessing here),\n> > > then I should actually have changed the mode of\n> > > git-rebase--interactive.sh to that mode instead. Please advice.\n> > \n> > Yes, sourced scripts should not have an executable bit. See 46bac90 for\n> > rationale.\n> \n> And I should have mentioned: they should go in SCRIPT_LIB in the\n> Makefile, not SCRIPT_SH.\n\nShouldn't this information be in Documentation/CodingGuidelines, and\nperhaps also (checking if one doesn't accidentally change executable\nbit on sourced scripts) in Documentation/SubmittingPatches?\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"162354","messageId":"7v7hcl4uan.fsf@alter.siamese.dyndns.org","threadId":"26148","inReplyTo":"1298516875-10765-1-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH] rebase: define options in OPTIONS_SPEC","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-02-27T10:59:44Z","receivedAt":"2011-02-27T10:59:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n\n> What is the difference between the \"options\" and \"actions\" sections?\n\nFor historical reasons, \"git rebase\" does not take subcommands in the way\nmany other commands do (e.g. \"git bisect start\", \"git rerere remaining\",\n\"git stash save\").  Some --option to the command are used for specifying\nthe subcommand.  \"git rebase --continue\", if it were designed to be\nconsistent with the other commands, would have been \"git rebase continue\"\ninstead.  \"Actions\" part lists them.\n\nThis is somewhat unfortunate, but is understandable given that \"rebase\"\ndidn't have its own options at all, and there was only one mode of\noperation, namely, to start the rebase process.  It allowed the user to be\nterse, i.e. instead off having to say \"git rebase onto master\", it was\nsufficient to say \"git rebase master\".\n\nWhen \"git rebase --continue\" was introduced (before, you were supposed to\nsay \"git am --resolved\", which was nonsense from the UI point of view),\nsomebody should have noticed this as a problem and started a process to\ndeprecate the \"git rebase <branchname>\" and to require explicit subcommand\nnames, just like we did to \"git stash [save]\", but that didn't happen.\n\nPerhaps this is something to consider at 2.0 boundary.\n"},{"id":"162510","messageId":"alpine.DEB.2.00.1102272055320.5025@debian","threadId":"26148","inReplyTo":"7v7hcl4uan.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] rebase: define options in OPTIONS_SPEC","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-03-01T01:59:26Z","receivedAt":"2011-03-01T01:59:26Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Sun, 27 Feb 2011, Junio C Hamano wrote:\n\n> Martin von Zweigbergk <martin.von.zweigbergk@gmail.com> writes:\n> \n> > What is the difference between the \"options\" and \"actions\" sections?\n> \n> For historical reasons, \"git rebase\" does not take subcommands in the way\n> many other commands do (e.g. \"git bisect start\", \"git rerere remaining\",\n> \"git stash save\").  Some --option to the command are used for specifying\n> the subcommand.  \"git rebase --continue\", if it were designed to be\n> consistent with the other commands, would have been \"git rebase continue\"\n> instead.  \"Actions\" part lists them.\n> \n> This is somewhat unfortunate, but is understandable given that \"rebase\"\n> didn't have its own options at all, and there was only one mode of\n> operation, namely, to start the rebase process.  It allowed the user to be\n> terse, i.e. instead off having to say \"git rebase onto master\", it was\n> sufficient to say \"git rebase master\".\n> \n> When \"git rebase --continue\" was introduced (before, you were supposed to\n> say \"git am --resolved\", which was nonsense from the UI point of view),\n> somebody should have noticed this as a problem and started a process to\n> deprecate the \"git rebase <branchname>\" and to require explicit subcommand\n> names, just like we did to \"git stash [save]\", but that didn't happen.\n> \n> Perhaps this is something to consider at 2.0 boundary.\n> \n\nThanks for the explanation. It sounds like I should leave only\n--continue, --skip and --abort in the \"Actions\" section.\n\nI just noticed another problem with my patch. I had assumed that\nspecifying 'n,no-stat ...' on one line would give me a '-n' argument\nto handle if e.g. '-n', '--no-stat' or '--no-sta' was passed. To my\nsurprise, when passing '--no-stat' on the command line, parse-options\ngives me the long form back. If I pass '--no-sta', I get the curious\n\nerror: Ambiguous option: no-sta (could be --no-stat or --no-stat)\n\nI figured these are related to the automatic support for negative\noptions (now I understand what you were talking about when you\nmentioned that to someone a few days ago). So here comes an updated\npatch where I have marked all of the options except for a few\n(e.g. 'autosquash') with a '!' to tell parse-options that they have no\nnegative forms.\n\n\nAnd thanks for fixing up my patch that moved the rebase scripts to\nSCRIPT_LIB.\n\n\n-- 8< --\nSubject: [PATCH v2] rebase: define options in OPTIONS_SPEC\n\nInteractive rebase used to have its own command line processing. Since\nit used the 'git rev-parse --parseopt' functionality exposed through\ngit-sh-setup, it had some flexibility, like matching prefixes of long\noptions, that non-interactive rebase didn't. When interactive rebase's\ncommand line processing was factored out into git-rebase.sh in cf432ca\n(rebase: factor out command line option processing, 2011-02-06), this\nflexibility was lost. Give back that flexibility to interactive and\nnon-interactive by defining its options in OPTIONS_SPEC.\n\nAlso improve the usage message to contain the --continue, --skip and\n--abort sub commands.\n\nReported-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\nApplies on top of mz/rebase.\n\nAre USAGE and LONG_USAGE still needed?\n\nI based the definitions on the now-lost OPTIONS_SPEC from interactive\nrebase and on Documentation/git-rebase.txt.\n\n git-rebase.sh |  101 +++++++++++++++++++++++++++++++-------------------------\n 1 files changed, 56 insertions(+), 45 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex a040ab5..7a54bfc 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -28,7 +28,39 @@ Example:       git-rebase master~1 topic\n '\n \n SUBDIRECTORY_OK=Yes\n-OPTIONS_SPEC=\n+OPTIONS_KEEPDASHDASH=\n+OPTIONS_SPEC=\"\\\n+git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]\n+git rebase [-i] [options] --onto <newbase> --root [<branch>]\n+git-rebase [-i] --continue | --abort | --skip\n+--\n+ Available options are\n+v,verbose!         display a diffstat of what changed upstream\n+q,quiet!           be quiet. implies --no-stat\n+onto=!             rebase onto given branch instead of upstream\n+p,preserve-merges! try to recreate merges instead of ignoring them\n+s,strategy=!       use the given merge strategy\n+no-ff!             cherry-pick all commits, even if unchanged\n+m,merge!           use merging strategies to rebase\n+i,interactive!     let the user edit the list of commits to rebase\n+f,force-rebase!    force rebase even if branch is up to date\n+X,strategy-option=! pass the argument through to the merge strategy\n+stat!              display a diffstat of what changed upstream\n+n,no-stat!         do not show diffstat of what changed upstream\n+verify             allow pre-rebase hook to run\n+rerere-autoupdate  allow rerere to update index with resolved conflicts\n+root!              rebase all reachable commits up to the root(s)\n+autosquash         move commits that begin with squash!/fixup! under -i\n+committer-date-is-author-date! passed to 'git am'\n+ignore-date!       passed to 'git am'\n+whitespace=!       passed to 'git apply'\n+ignore-whitespace! passed to 'git apply'\n+C=!                passed to 'git apply'\n+ Actions:\n+continue!          continue rebasing process\n+abort!             abort rebasing process and restore original branch\n+skip!              skip current patch and continue rebasing process\n+\"\n . git-sh-setup\n set_reflog_action rebase\n require_work_tree\n@@ -175,7 +207,7 @@ do\n \t\tok_to_skip_pre_rebase=\n \t\t;;\n \t--continue|--skip|--abort)\n-\t\ttest $total_argc -eq 1 || usage\n+\t\ttest $total_argc -eq 2 || usage\n \t\taction=${1##--}\n \t\t;;\n \t--onto)\n@@ -183,10 +215,10 @@ do\n \t\tonto=\"$2\"\n \t\tshift\n \t\t;;\n-\t-i|--interactive)\n+\t-i)\n \t\tinteractive_rebase=explicit\n \t\t;;\n-\t-p|--preserve-merges)\n+\t-p)\n \t\tpreserve_merges=t\n \t\ttest -z \"$interactive_rebase\" && interactive_rebase=implied\n \t\t;;\n@@ -196,62 +228,42 @@ do\n \t--no-autosquash)\n \t\tautosquash=\n \t\t;;\n-\t-M|-m|--m|--me|--mer|--merg|--merge)\n+\t-M|-m)\n \t\tdo_merge=t\n \t\t;;\n-\t-X*|--strategy-option*)\n-\t\tcase \"$#,$1\" in\n-\t\t1,-X|1,--strategy-option)\n-\t\t\tusage ;;\n-\t\t*,-X|*,--strategy-option)\n-\t\t\tnewopt=\"$2\"\n-\t\t\tshift ;;\n-\t\t*,--strategy-option=*)\n-\t\t\tnewopt=\"$(expr \" $1\" : ' --strategy-option=\\(.*\\)')\" ;;\n-\t\t*,-X*)\n-\t\t\tnewopt=\"$(expr \" $1\" : ' -X\\(.*\\)')\" ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\tesac\n-\t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$newopt\")\"\n+\t-X)\n+\t\tshift\n+\t\tstrategy_opts=\"$strategy_opts $(git rev-parse --sq-quote \"--$1\")\"\n \t\tdo_merge=t\n \t\ttest -z \"$strategy\" && strategy=recursive\n \t\t;;\n-\t-s=*|--s=*|--st=*|--str=*|--stra=*|--strat=*|--strate=*|\\\n-\t\t--strateg=*|--strategy=*|\\\n-\t-s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)\n-\t\tcase \"$#,$1\" in\n-\t\t*,*=*)\n-\t\t\tstrategy=`expr \"z$1\" : 'z-[^=]*=\\(.*\\)'` ;;\n-\t\t1,*)\n-\t\t\tusage ;;\n-\t\t*)\n-\t\t\tstrategy=\"$2\"\n-\t\t\tshift ;;\n-\t\tesac\n+\t-s)\n+\t\tshift\n+\t\tstrategy=\"$1\"\n \t\tdo_merge=t\n \t\t;;\n-\t-n|--no-stat)\n+\t-n)\n \t\tdiffstat=\n \t\t;;\n \t--stat)\n \t\tdiffstat=t\n \t\t;;\n-\t-v|--verbose)\n+\t-v)\n \t\tverbose=t\n \t\tdiffstat=t\n \t\tGIT_QUIET=\n \t\t;;\n-\t-q|--quiet)\n+\t-q)\n \t\tGIT_QUIET=t\n \t\tgit_am_opt=\"$git_am_opt -q\"\n \t\tverbose=\n \t\tdiffstat=\n \t\t;;\n-\t--whitespace=*)\n-\t\tgit_am_opt=\"$git_am_opt $1\"\n+\t--whitespace)\n+\t\tshift\n+\t\tgit_am_opt=\"$git_am_opt --whitespace=$1\"\n \t\tcase \"$1\" in\n-\t\t--whitespace=fix|--whitespace=strip)\n+\t\tfix|strip)\n \t\t\tforce_rebase=t\n \t\t\t;;\n \t\tesac\n@@ -263,22 +275,21 @@ do\n \t\tgit_am_opt=\"$git_am_opt $1\"\n \t\tforce_rebase=t\n \t\t;;\n-\t-C*)\n-\t\tgit_am_opt=\"$git_am_opt $1\"\n+\t-C)\n+\t\tshift\n+\t\tgit_am_opt=\"$git_am_opt -C$1\"\n \t\t;;\n \t--root)\n \t\trebase_root=t\n \t\t;;\n-\t-f|--f|--fo|--for|--forc|--force|--force-r|--force-re|--force-reb|--force-reba|--force-rebas|--force-rebase|--no-ff)\n+\t-f|--no-ff)\n \t\tforce_rebase=t\n \t\t;;\n \t--rerere-autoupdate|--no-rerere-autoupdate)\n \t\tallow_rerere_autoupdate=\"$1\"\n \t\t;;\n-\t-*)\n-\t\tusage\n-\t\t;;\n-\t*)\n+\t--)\n+\t\tshift\n \t\tbreak\n \t\t;;\n \tesac\n-- \n1.7.4.79.gcbe20\n"},{"id":"162592","messageId":"20110301220428.GE23945@sigill.intra.peff.net","threadId":"26148","inReplyTo":"m3sjvb7tg4.fsf@localhost.localdomain","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-03-01T22:04:29Z","receivedAt":"2011-03-01T22:04:29Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Feb 25, 2011 at 12:27:03PM -0800, Jakub Narebski wrote:\n\n> > > Yes, sourced scripts should not have an executable bit. See 46bac90 for\n> > > rationale.\n> > \n> > And I should have mentioned: they should go in SCRIPT_LIB in the\n> > Makefile, not SCRIPT_SH.\n> \n> Shouldn't this information be in Documentation/CodingGuidelines, and\n> perhaps also (checking if one doesn't accidentally change executable\n> bit on sourced scripts) in Documentation/SubmittingPatches?\n\nI think it might make more sense as comments in the Makefile, which is\nnot very well commented for people tweaking non-config bits. Patches\nwelcome.\n\n-Peff\n"},{"id":"162597","messageId":"201103012343.33781.jnareb@gmail.com","threadId":"26148","inReplyTo":"20110301220428.GE23945@sigill.intra.peff.net","subject":"Re: [PATCH v2 18/31] rebase: extract merge code to new source file","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-03-01T22:43:31Z","receivedAt":"2011-03-01T22:43:31Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Tue, 1 Mar 2011, Jeff King wrote:\n> On Fri, Feb 25, 2011 at 12:27:03PM -0800, Jakub Narebski wrote:\n> \n> > > > Yes, sourced scripts should not have an executable bit. See 46bac90 for\n> > > > rationale.\n> > > \n> > > And I should have mentioned: they should go in SCRIPT_LIB in the\n> > > Makefile, not SCRIPT_SH.\n> > \n> > Shouldn't this information be in Documentation/CodingGuidelines, and\n> > perhaps also (checking if one doesn't accidentally change executable\n> > bit on sourced scripts) in Documentation/SubmittingPatches?\n> \n> I think it might make more sense as comments in the Makefile, which is\n> not very well commented for people tweaking non-config bits. Patches\n> welcome.\n\nI meant here describing that sourced scripts should not have an executable\nbit in CodingGuidelines, ensure that it didn't acquire executable bit in\nSubmittingPatches, the fact that added new scripts got to SCRIPT_SH and\nnew sourced scripts to SCRIPT_LIB in CodingGuidelines / SubmittingPatches.\n\nDescription of SCRIPT_SH and SCRIPT_LIB in Makefile comments would be\nalso nice, and perhaps replace some of proposed additions to \nCodingGuidelines and SubmittingPatches documents.\n\n-- \nJakub Narebski\nPoland\n"},{"id":"170735","messageId":"20110701035503.GA9818@elie","threadId":"26148","inReplyTo":"1297017841-20678-8-git-send-email-martin.von.zweigbergk@gmail.com","subject":"Re: [PATCH v2 07/31] rebase: stricter check of standalone sub command","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-07-01T03:55:03Z","receivedAt":"2011-07-01T03:55:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Martin,\n\nMartin von Zweigbergk wrote:\n\n> The sub commands '--continue', '--skip' or '--abort' may only be used\n> standalone according to the documentation.\n[...]\n> Is this too simplistic? Do we forsee that we want to support passing\n> options when resuming a rebase? Is it better to check for each other\n> option that it is not passed (i.e. no '-v', no '-s' etc.)?\n>\n> Might some users be depending on the current behavior, even though it\n> is undocumented?\n\nYes.\n\nI have no clue why, but my fingers are wired to do\n\n\tgit rebase -i --continue\n\nwhen resuming an interactive rebase.  So with v1.7.6, I use two commands\ninstead of one.\n\nIt's possible that I was crazy, and we should just mention this in the\nrelease notes and move on.  Another possibility would be to make \"git\nrebase -i --continue\" mean \"check if in the middle of an interactive\nrebase, and if so, continue\".  Yet another possibility would be to\nallow transforming a non-interactive rebase into an interactive one\nafter a conflict with that command (though I can't imagine why someone\nwould want to).  I'm tempted to say the first way (keeping the command\nbroken and documenting the change) is the way to go, since it means it\nwould be possible to make commands like this mean something else in\nthe future.\n\nWhat do you think?\n\n*searches*\n\nAh, it seems you already wrote a patch at [1].  The commit message\nsays it fails for \"-i --continue\" but I don't any code doing that;\nwhat am I missing?\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/164241/focus=166684\n"},{"id":"170741","messageId":"alpine.DEB.2.00.1107010833310.580@debian","threadId":"26148","inReplyTo":"20110701035503.GA9818@elie","subject":"Re: [PATCH v2 07/31] rebase: stricter check of standalone sub command","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-07-01T13:16:49Z","receivedAt":"2011-07-01T13:16:49Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"Hi Jonathan,\n\nOn Thu, 30 Jun 2011, Jonathan Nieder wrote:\n\n> Hi Martin,\n> \n> Martin von Zweigbergk wrote:\n> \n> > The sub commands '--continue', '--skip' or '--abort' may only be used\n> > standalone according to the documentation.\n> [...]\n> > Is this too simplistic? Do we forsee that we want to support passing\n> > options when resuming a rebase? Is it better to check for each other\n> > option that it is not passed (i.e. no '-v', no '-s' etc.)?\n> >\n> > Might some users be depending on the current behavior, even though it\n> > is undocumented?\n> \n> Yes.\n> \n> I have no clue why, but my fingers are wired to do\n> \n> \tgit rebase -i --continue\n> \n> when resuming an interactive rebase.  So with v1.7.6, I use two commands\n> instead of one.\n> \n> It's possible that I was crazy, and we should just mention this in the\n> release notes and move on.  Another possibility would be to make \"git\n> rebase -i --continue\" mean \"check if in the middle of an interactive\n> rebase, and if so, continue\".  Yet another possibility would be to\n> allow transforming a non-interactive rebase into an interactive one\n> after a conflict with that command (though I can't imagine why someone\n> would want to).  I'm tempted to say the first way (keeping the command\n> broken and documenting the change) is the way to go, since it means it\n> would be possible to make commands like this mean something else in\n> the future.\n> \n> What do you think?\n\nI think it feels like 'git rebase -i --continue' to resume a\nnon-interactive rebase should be an error until we actually support\ntransforming it into an interactive rebase (if ever). I agree that if\nthe rebase was already interactive, it would not harm to accept\nit. OTOH, since the -i means nothing in this context, I don't see much\nneed to accept it either. In short, I agree with you that documenting\nit is enough. Is the below patch what you had in mind?\n\n\n> *searches*\n> \n> Ah, it seems you already wrote a patch at [1].  The commit message\n> says it fails for \"-i --continue\" but I don't any code doing that;\n> what am I missing?\n\nThat patch was never accepted, but 95135b0 (rebase: stricter check of\nstandalone sub command, 2011-02-06) was.\n\n> [1] http://thread.gmane.org/gmane.comp.version-control.git/164241/focus=166684\n> \n\n\n-- >8 --\nSubject: [PATCH] rebase usage: subcommands can not be combined with -i\n\nSince 95135b0 (rebase: stricter check of standalone sub command,\n2011-02-06), git-rebase has not allowed to use -i together with\ne.g. --continue. Yet, when rebase started using OPTIONS_SPEC in\n45e2acf (rebase: define options in OPTIONS_SPEC, 2011-02-28), the\nusage message included\n\n  git-rebase [-i] --continue | --abort | --skip\n\nRemove the \"[-i]\" from this line.\n\nSigned-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>\n---\n git-rebase.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d7855ea..6afc596 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -32,7 +32,7 @@ OPTIONS_KEEPDASHDASH=\n OPTIONS_SPEC=\"\\\n git rebase [-i] [options] [--onto <newbase>] [<upstream>] [<branch>]\n git rebase [-i] [options] --onto <newbase> --root [<branch>]\n-git-rebase [-i] --continue | --abort | --skip\n+git-rebase --continue | --abort | --skip\n --\n  Available options are\n v,verbose!         display a diffstat of what changed upstream\n-- \n1.7.5.3.640.gd1066\n"},{"id":"170757","messageId":"20110701222919.GA11258@elie","threadId":"26148","inReplyTo":"alpine.DEB.2.00.1107010833310.580@debian","subject":"Re: [PATCH v2 07/31] rebase: stricter check of standalone sub command","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-07-01T22:29:19Z","receivedAt":"2011-07-01T22:29:19Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Martin von Zweigbergk wrote:\n\n> Is the below patch what you had in mind?\n\nNo, but it looks good to me (\"rebase usage: subcommands can not be\ncombined with -i\").\n\n>> Ah, it seems you already wrote a patch at [1].  The commit message\n>> says it fails for \"-i --continue\" but I don't any code doing that;\n>> what am I missing?\n>\n> That patch was never accepted, but 95135b0 (rebase: stricter check of\n> standalone sub command, 2011-02-06) was.\n>\n>> [1] http://thread.gmane.org/gmane.comp.version-control.git/164241/focus=166684\n\nI'll play around with [1] and try to revive it.  Thanks.\n"},{"id":"170850","messageId":"alpine.DEB.2.00.1107052131410.7799@debian","threadId":"26148","inReplyTo":"20110701222919.GA11258@elie","subject":"Re: [PATCH v2 07/31] rebase: stricter check of standalone sub command","fromName":"Martin von Zweigbergk","fromEmail":"martin.von.zweigbergk@gmail.com","sentAt":"2011-07-06T01:48:16Z","receivedAt":"2011-07-06T01:48:16Z","isPatch":true,"sender":{"key":"martinvonz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/891642?v=4"},"body":"On Fri, 1 Jul 2011, Jonathan Nieder wrote:\n\n> Martin von Zweigbergk wrote:\n> \n> > Is the below patch what you had in mind?\n> \n> No, but it looks good to me (\"rebase usage: subcommands can not be\n> combined with -i\").\n> \n> >> Ah, it seems you already wrote a patch at [1].  The commit message\n> >> says it fails for \"-i --continue\" but I don't any code doing that;\n> >> what am I missing?\n> >\n> > That patch was never accepted, but 95135b0 (rebase: stricter check of\n> > standalone sub command, 2011-02-06) was.\n> >\n> >> [1] http://thread.gmane.org/gmane.comp.version-control.git/164241/focus=166684\n> \n> I'll play around with [1] and try to revive it.  Thanks.\n\nI'm not sure I understand what you want to achieve. Do you want to\nrevive [1] but also make it allow \"-i --continue\"? If so, is one of\nthe following your goal when used with \"--continue\"?\n\n 1. Always accept \"-i\", but ignore it (the behavior before 1.7.6)\n\n 2. Only accept \"-i\" if the rebase was already interactive\n\n 3. Always accept \"-i\" and transform a non-interactive rebase to an\n interative one\n\nJust curious. Thanks for working on it.\n\n\nMartin\n"}]}