{"thread":{"id":"23956","subject":"[PATCH] rebase: improve error message when upstream argument is missing","startedAt":"2010-05-31T22:51:32Z","lastAt":"2010-05-31T22:51:32Z","messageCount":1,"participants":["Jonathan Nieder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"142625","messageId":"20100531225132.GA6066@progeny.tock","threadId":"23956","inReplyTo":"20100531213525.GA3826@tchicaya.lan","subject":"[PATCH] rebase: improve error message when upstream argument is missing","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-05-31T22:51:32Z","receivedAt":"2010-05-31T22:51:32Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Strip out options before checking for a missing upstream argument.\nBefore:\n\n $ git rebase -m\n shift: 426: can't shift that many\n\nAfter:\n\n $ git rebase -m\n Usage: git rebase ...\n\nWhile at it, fix the usage message to explain that the upstream\nargument is mandatory.\n\nReported-by: Jon Dowland <jmtd@debian.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJon Dowland wrote:\n\n> jon@tchicaya:~/wd/web/crm114-spamd$ git rebase --onto origin/master\n> shift: 426: can't shift that many\n\nHow about this patch?\n\n git-rebase.sh     |   17 ++++++++---------\n t/t3400-rebase.sh |   13 ++++++++++++-\n 2 files changed, 20 insertions(+), 10 deletions(-)\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex 44f5c65..ab4afa7 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -3,7 +3,7 @@\n # Copyright (c) 2005 Junio C Hamano.\n #\n \n-USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'\n+USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--no-ff] [--onto <newbase>] (<upstream>|--root) [<branch>] [--quiet | -q]'\n LONG_USAGE='git-rebase replaces <branch> with a new branch of the\n same name.  When the --onto option is provided the new branch starts\n out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>\n@@ -198,14 +198,6 @@ test -f \"$GIT_DIR\"/rebase-apply/applying &&\n \n is_interactive \"$@\" && exec git-rebase--interactive \"$@\"\n \n-if test $# -eq 0\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-\t\tdie 'A rebase is in progress, try --continue, --skip or --abort.'\n-\tdie \"No arguments given and $GIT_DIR/rebase-apply already exists.\"\n-fi\n-\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -370,6 +362,13 @@ do\n done\n 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+\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 if test -z \"$do_merge\"\n then\ndiff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh\nindex dbf7dfb..e5691bc 100755\n--- a/t/t3400-rebase.sh\n+++ b/t/t3400-rebase.sh\n@@ -126,9 +126,20 @@ test_expect_success 'Show verbose error when HEAD could not be detached' '\n      test_must_fail git rebase topic 2> output.err > output.out &&\n      grep \"Untracked working tree file .B. would be overwritten\" output.err\n '\n+rm -f B\n+\n+test_expect_success 'dump usage when upstream arg is missing' '\n+     git checkout -b usage topic &&\n+     test_must_fail git rebase 2>error1 &&\n+     grep \"[Uu]sage\" error1 &&\n+     test_must_fail git rebase --abort 2>error2 &&\n+     grep \"No rebase in progress\" error2 &&\n+     test_must_fail git rebase --onto master 2>error3 &&\n+     grep \"[Uu]sage\" error3 &&\n+     ! grep \"can.t shift\" error3\n+'\n \n test_expect_success 'rebase -q is quiet' '\n-     rm B &&\n      git checkout -b quiet topic &&\n      git rebase -q master > output.out 2>&1 &&\n      test ! -s output.out\n-- \n1.7.1.349.g784ce.dirty\n"}]}