{"thread":{"id":"14426","subject":"[PATCH] Make rebase--interactive use OPTIONS_SPEC","startedAt":"2008-07-12T15:48:20Z","lastAt":"2008-07-12T17:34:42Z","messageCount":5,"participants":["Stephan Beyer","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"83088","messageId":"1215877700-17080-1-git-send-email-s-beyer@gmx.net","threadId":"14426","inReplyTo":null,"subject":"[PATCH] Make rebase--interactive use OPTIONS_SPEC","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-12T15:48:20Z","receivedAt":"2008-07-12T15:48:20Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Also add some checks that --continue/--abort/--skip\nactions are used without --onto, -p, -t, etc.\n\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n\nYes, I've already sent a similar patch, that was dropped because it\ndepended on the js/rebase-i-sequencer patches that are dropped.\n\nNow I picked this out of my sequencer patchset because it is general\nenough.\n\n git-rebase--interactive.sh |   77 +++++++++++++++++++++++++++++---------------\n 1 files changed, 51 insertions(+), 26 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a64d9d5..3d85486 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -10,10 +10,24 @@\n # The original idea comes from Eric W. Biederman, in\n # http://article.gmane.org/gmane.comp.version-control.git/22407\n \n-USAGE='(--continue | --abort | --skip | [--preserve-merges] [--verbose]\n-\t[--onto <branch>] <upstream> [<branch>])'\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+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+\"\n \n-OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n \n@@ -25,10 +39,8 @@ SQUASH_MSG=\"$DOTEST\"/message-squash\n REWRITTEN=\"$DOTEST\"/rewritten\n PRESERVE_MERGES=\n STRATEGY=\n+ONTO=\n VERBOSE=\n-test -d \"$REWRITTEN\" && PRESERVE_MERGES=t\n-test -f \"$DOTEST\"/strategy && STRATEGY=\"$(cat \"$DOTEST\"/strategy)\"\n-test -f \"$DOTEST\"/verbose && VERBOSE=t\n \n GIT_CHERRY_PICK_HELP=\"  After resolving the conflicts,\n mark the corrected paths with 'git add <paths>', and\n@@ -366,10 +378,27 @@ do_rest () {\n \tdone\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+\ttest -f \"$DOTEST\"/verbose && VERBOSE=t\n+}\n+\n while test $# != 0\n do\n \tcase \"$1\" in\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@@ -402,6 +431,8 @@ do\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@@ -419,6 +450,8 @@ do\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 \n \t\tgit rerere clear\n@@ -426,7 +459,7 @@ do\n \n \t\toutput git reset --hard && do_rest\n \t\t;;\n-\t-s|--strategy)\n+\t-s)\n \t\tcase \"$#,$1\" in\n \t\t*,*=*)\n \t\t\tSTRATEGY=\"-s \"$(expr \"z$1\" : 'z-[^=]*=\\(.*\\)') ;;\n@@ -437,25 +470,26 @@ do\n \t\t\tshift ;;\n \t\tesac\n \t\t;;\n-\t-m|--merge)\n+\t-m)\n \t\t# we use merge anyway\n \t\t;;\n-\t-C*)\n-\t\tdie \"Interactive rebase uses merge, so $1 does not make sense\"\n-\t\t;;\n-\t-v|--verbose)\n+\t-v)\n \t\tVERBOSE=t\n \t\t;;\n-\t-p|--preserve-merges)\n+\t-p)\n \t\tPRESERVE_MERGES=t\n \t\t;;\n-\t-i|--interactive)\n+\t-i)\n \t\t# yeah, we know\n \t\t;;\n-\t''|-h)\n-\t\tusage\n+\t--onto)\n+\t\tshift\n+\t\tONTO=$(git rev-parse --verify \"$1\") ||\n+\t\t\tdie \"Does not point to a valid commit: $1\"\n \t\t;;\n-\t*)\n+\t--)\n+\t\tshift\n+\t\ttest $# -eq 1 -o $# -eq 2 || usage\n \t\ttest -d \"$DOTEST\" &&\n \t\t\tdie \"Interactive rebase already started\"\n \n@@ -464,15 +498,6 @@ do\n \n \t\tcomment_for_reflog start\n \n-\t\tONTO=\n-\t\tcase \"$1\" in\n-\t\t--onto)\n-\t\t\tONTO=$(git rev-parse --verify \"$2\") ||\n-\t\t\t\tdie \"Does not point to a valid commit: $2\"\n-\t\t\tshift; shift\n-\t\t\t;;\n-\t\tesac\n-\n \t\trequire_clean_work_tree\n \n \t\tUPSTREAM=$(git rev-parse --verify \"$1\") || die \"Invalid base\"\n-- \n1.5.6.2.303.g79662\n"},{"id":"83093","messageId":"alpine.DEB.1.00.0807121728180.8950@racer","threadId":"14426","inReplyTo":"1215877700-17080-1-git-send-email-s-beyer@gmx.net","subject":"Re: [PATCH] Make rebase--interactive use OPTIONS_SPEC","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-12T16:28:54Z","receivedAt":"2008-07-12T16:28:54Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 12 Jul 2008, Stephan Beyer wrote:\n\n> +\t--onto)\n> +\t\tshift\n> +\t\tONTO=$(git rev-parse --verify \"$1\") ||\n> +\t\t\tdie \"Does not point to a valid commit: $1\"\n\nDidn't you have some check earlier that \"--onto\" can only be used when \nstarting a rebase?\n\nOtherwise: ACK.\n\nCiao,\nDscho\n"},{"id":"83095","messageId":"20080712172729.GE7572@leksak.fem-net","threadId":"14426","inReplyTo":"alpine.DEB.1.00.0807121728180.8950@racer","subject":"Re: [PATCH] Make rebase--interactive use OPTIONS_SPEC","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-12T17:27:29Z","receivedAt":"2008-07-12T17:27:29Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nJohannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > +\t--onto)\n> > +\t\tshift\n> > +\t\tONTO=$(git rev-parse --verify \"$1\") ||\n> > +\t\t\tdie \"Does not point to a valid commit: $1\"\n> \n> Didn't you have some check earlier that \"--onto\" can only be used when \n> starting a rebase?\n\nYes, and I still have. is_standalone does that:\n\n# check if no other options are set\nis_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\nwhich is called on --continue/--abort/--skip before the saved options are\nloaded again.\n\nRegards.\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"},{"id":"83096","messageId":"alpine.DEB.1.00.0807121830270.8950@racer","threadId":"14426","inReplyTo":"20080712172729.GE7572@leksak.fem-net","subject":"Re: [PATCH] Make rebase--interactive use OPTIONS_SPEC","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-12T17:31:24Z","receivedAt":"2008-07-12T17:31:24Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 12 Jul 2008, Stephan Beyer wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > +\t--onto)\n> > > +\t\tshift\n> > > +\t\tONTO=$(git rev-parse --verify \"$1\") ||\n> > > +\t\t\tdie \"Does not point to a valid commit: $1\"\n> > \n> > Didn't you have some check earlier that \"--onto\" can only be used when \n> > starting a rebase?\n> \n> Yes, and I still have. is_standalone does that:\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> which is called on --continue/--abort/--skip before the saved options \n> are loaded again.\n\nAh, sorry.  I managed to misunderstand \"is_standalone\".  Again.  (I had \nthe same problem during the first round, but forgot to mention that, I \nguess).\n\nCiao,\nDscho\n"},{"id":"83097","messageId":"20080712173442.GF7572@leksak.fem-net","threadId":"14426","inReplyTo":"alpine.DEB.1.00.0807121830270.8950@racer","subject":"Re: [PATCH] Make rebase--interactive use OPTIONS_SPEC","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-12T17:34:42Z","receivedAt":"2008-07-12T17:34:42Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nJohannes Schindelin wrote:\n> > which is called on --continue/--abort/--skip before the saved options \n> > are loaded again.\n> \n> Ah, sorry.  I managed to misunderstand \"is_standalone\".  Again.  (I had \n> the same problem during the first round, but forgot to mention that, I \n> guess).\n\nYes, the name is a little ambiguous.\nIt comes from something like \"It is a standalone option\".\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"}]}