{"thread":{"id":"17869","subject":"[PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","startedAt":"2009-02-18T04:44:22Z","lastAt":"2009-02-18T13:36:58Z","messageCount":6,"participants":["Jay Soffian","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"105269","messageId":"1234932262-63469-1-git-send-email-jaysoffian@gmail.com","threadId":"17869","inReplyTo":null,"subject":"[PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-18T04:44:22Z","receivedAt":"2009-02-18T04:44:22Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"It does not make sense to provide multiple upstream branches to either\ngit pull --rebase, or to git rebase, so disallow both.\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\n git-pull.sh   |    5 +++++\n git-rebase.sh |    1 +\n 2 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/git-pull.sh b/git-pull.sh\nindex 2c7f432..25adddf 100755\n--- a/git-pull.sh\n+++ b/git-pull.sh\n@@ -171,6 +171,11 @@ case \"$merge_head\" in\n \t\techo >&2 \"Cannot merge multiple branches into empty head\"\n \t\texit 1\n \tfi\n+\tif test true = \"$rebase\"\n+\tthen\n+\t\techo >&2 \"Cannot rebase onto multiple branches\"\n+\t\texit 1\n+\tfi\n \t;;\n esac\n \ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 5d9a393..ffb6027 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -319,6 +319,7 @@ do\n \tesac\n \tshift\n done\n+test $# -gt 1 && usage\n \n # Make sure we do not have $GIT_DIR/rebase-apply\n if test -z \"$do_merge\"\n-- \n1.6.2.rc1.210.g159a\n"},{"id":"105287","messageId":"alpine.DEB.1.00.0902181118160.6274@intel-tinevez-2-302","threadId":"17869","inReplyTo":"1234932262-63469-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-18T10:18:58Z","receivedAt":"2009-02-18T10:18:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 17 Feb 2009, Jay Soffian wrote:\n\n> It does not make sense to provide multiple upstream branches to either\n> git pull --rebase, or to git rebase, so disallow both.\n> \n> Signed-off-by: Jay Soffian <jaysoffian@gmail.com>\n> ---\n>  git-pull.sh   |    5 +++++\n>  git-rebase.sh |    1 +\n>  2 files changed, 6 insertions(+), 0 deletions(-)\n> \n> diff --git a/git-pull.sh b/git-pull.sh\n> index 2c7f432..25adddf 100755\n> --- a/git-pull.sh\n> +++ b/git-pull.sh\n> @@ -171,6 +171,11 @@ case \"$merge_head\" in\n>  \t\techo >&2 \"Cannot merge multiple branches into empty head\"\n>  \t\texit 1\n>  \tfi\n> +\tif test true = \"$rebase\"\n> +\tthen\n> +\t\techo >&2 \"Cannot rebase onto multiple branches\"\n> +\t\texit 1\n> +\tfi\n>  \t;;\n>  esac\n>  \n\nGood catch!\n\n> diff --git a/git-rebase.sh b/git-rebase.sh\n> index 5d9a393..ffb6027 100755\n> --- a/git-rebase.sh\n> +++ b/git-rebase.sh\n> @@ -319,6 +319,7 @@ do\n>  \tesac\n>  \tshift\n>  done\n> +test $# -gt 1 && usage\n\nDid you just break\n\n\t$ git rebase $UPSTREAM $BRANCH_TO_SWITCH_TO\n\n?\n\nCiao,\nDscho\n"},{"id":"105298","messageId":"76718490902180523l6df2067bxc1274a105756d16b@mail.gmail.com","threadId":"17869","inReplyTo":"alpine.DEB.1.00.0902181118160.6274@intel-tinevez-2-302","subject":"Re: [PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-18T13:23:15Z","receivedAt":"2009-02-18T13:23:15Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 18, 2009 at 5:18 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>> diff --git a/git-rebase.sh b/git-rebase.sh\n>> index 5d9a393..ffb6027 100755\n>> --- a/git-rebase.sh\n>> +++ b/git-rebase.sh\n>> @@ -319,6 +319,7 @@ do\n>>       esac\n>>       shift\n>>  done\n>> +test $# -gt 1 && usage\n>\n> Did you just break\n>\n>        $ git rebase $UPSTREAM $BRANCH_TO_SWITCH_TO\n\nCrap, I missed that usage somehow (and I guess the test suite doesn't\nrely on it either...). I think moving the \"test $# -gt 1 && usage\"\nbelow:\n\nif test -z \"$rebase_root\"\nthen\n\t# The upstream head must be given.  Make sure it is valid.\n\tupstream_name=\"$1\"\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\"\nelse\n\ttest -z \"$newbase\" && die \"--root must be used with --onto\"\n\tunset upstream_name\n\tunset upstream\n\troot_flag=\"--root\"\n\tupstream_arg=\"$root_flag\"\nfi\n\nwill do the trick, yes?\n\nj.\n"},{"id":"105300","messageId":"alpine.DEB.1.00.0902181427030.6274@intel-tinevez-2-302","threadId":"17869","inReplyTo":"76718490902180523l6df2067bxc1274a105756d16b@mail.gmail.com","subject":"Re: [PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-18T13:28:11Z","receivedAt":"2009-02-18T13:28:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Feb 2009, Jay Soffian wrote:\n\n> On Wed, Feb 18, 2009 at 5:18 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> >> diff --git a/git-rebase.sh b/git-rebase.sh\n> >> index 5d9a393..ffb6027 100755\n> >> --- a/git-rebase.sh\n> >> +++ b/git-rebase.sh\n> >> @@ -319,6 +319,7 @@ do\n> >>       esac\n> >>       shift\n> >>  done\n> >> +test $# -gt 1 && usage\n> >\n> > Did you just break\n> >\n> >        $ git rebase $UPSTREAM $BRANCH_TO_SWITCH_TO\n> \n> Crap, I missed that usage somehow (and I guess the test suite doesn't\n> rely on it either...). I think moving the \"test $# -gt 1 && usage\"\n> below:\n> \n> if test -z \"$rebase_root\"\n> then\n> \t# The upstream head must be given.  Make sure it is valid.\n> \tupstream_name=\"$1\"\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 \"$newbase\" && die \"--root must be used with --onto\"\n> \tunset upstream_name\n> \tunset upstream\n> \troot_flag=\"--root\"\n> \tupstream_arg=\"$root_flag\"\n> fi\n> \n> will do the trick, yes?\n\nNope.  Note the \"shift\" in the first arm?  It is so that the code below \ncan check for $#, and it indeed does, in a 'case' statement.\n\n(Note: I am writing all this from memory, it could be slightly different, \nbut the essence is still valid.)\n\nCiao,\nDscho\n"},{"id":"105302","messageId":"76718490902180532l1de135ccyd4e58c713e6af2c@mail.gmail.com","threadId":"17869","inReplyTo":"alpine.DEB.1.00.0902181427030.6274@intel-tinevez-2-302","subject":"Re: [PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-18T13:32:43Z","receivedAt":"2009-02-18T13:32:43Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Feb 18, 2009 at 8:28 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>> if test -z \"$rebase_root\"\n>> then\n>>       # The upstream head must be given.  Make sure it is valid.\n>>       upstream_name=\"$1\"\n>>       shift\n>>       upstream=`git rev-parse --verify \"${upstream_name}^0\"` ||\n>>       die \"invalid upstream $upstream_name\"\n>>       unset root_flag\n>>       upstream_arg=\"$upstream_name\"\n>> else\n>>       test -z \"$newbase\" && die \"--root must be used with --onto\"\n>>       unset upstream_name\n>>       unset upstream\n>>       root_flag=\"--root\"\n>>       upstream_arg=\"$root_flag\"\n>> fi\n>>\n>> will do the trick, yes?\n>\n> Nope.  Note the \"shift\" in the first arm?  It is so that the code below\n> can check for $#, and it indeed does, in a 'case' statement.\n\nThe case statement checks $# against 1 and *, not 1 and 0. And I don't\nsee how > 1 is valid at that point. So I can modify the case statement\nto check against 1, 0, and have * emit usage, or I think moving the\n\"test $# -gt 1 && usage\" to where I suggested in the last message\nwould do the trick. The only difference would be whether a pre-rebase\nhook runs in the case of invalid arguments (the case statement is\nafter that hook runs).\n\nj.\n"},{"id":"105306","messageId":"alpine.DEB.1.00.0902181436380.6274@intel-tinevez-2-302","threadId":"17869","inReplyTo":"76718490902180532l1de135ccyd4e58c713e6af2c@mail.gmail.com","subject":"Re: [PATCH] disallow providing multiple upstream branches to rebase, pull --rebase","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-18T13:36:58Z","receivedAt":"2009-02-18T13:36:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 18 Feb 2009, Jay Soffian wrote:\n\n> On Wed, Feb 18, 2009 at 8:28 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> >> if test -z \"$rebase_root\"\n> >> then\n> >>       # The upstream head must be given.  Make sure it is valid.\n> >>       upstream_name=\"$1\"\n> >>       shift\n> >>       upstream=`git rev-parse --verify \"${upstream_name}^0\"` ||\n> >>       die \"invalid upstream $upstream_name\"\n> >>       unset root_flag\n> >>       upstream_arg=\"$upstream_name\"\n> >> else\n> >>       test -z \"$newbase\" && die \"--root must be used with --onto\"\n> >>       unset upstream_name\n> >>       unset upstream\n> >>       root_flag=\"--root\"\n> >>       upstream_arg=\"$root_flag\"\n> >> fi\n> >>\n> >> will do the trick, yes?\n> >\n> > Nope.  Note the \"shift\" in the first arm?  It is so that the code below\n> > can check for $#, and it indeed does, in a 'case' statement.\n> \n> The case statement checks $# against 1 and *, not 1 and 0. And I don't\n> see how > 1 is valid at that point. So I can modify the case statement\n> to check against 1, 0, and have * emit usage, or I think moving the\n> \"test $# -gt 1 && usage\" to where I suggested in the last message\n> would do the trick. The only difference would be whether a pre-rebase\n> hook runs in the case of invalid arguments (the case statement is\n> after that hook runs).\n\nOf course, you could also leave the test where it was, and just replace \nthe 1 by a 2.\n\nCiao,\nDscho\n"}]}