{"thread":{"id":"26344","subject":"[PATCH 1/2] rebase: use explicit \"--\" with checkout","startedAt":"2011-01-27T00:26:59Z","lastAt":"2011-01-27T00:26:59Z","messageCount":1,"participants":["Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"159933","messageId":"20110127002658.GA32711@sigill.intra.peff.net","threadId":"26344","inReplyTo":null,"subject":"[PATCH 1/2] rebase: use explicit \"--\" with checkout","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-01-27T00:26:59Z","receivedAt":"2011-01-27T00:26:59Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"In the case of a ref/pathname conflict, checkout will\nalready do the right thing and checkout the ref. However,\nfor a non-existant ref, this has two advantages:\n\n  1. If a file with that pathname exists, rebase will\n     refresh the file from the index and then rebase the\n     current branch instead of producing an error.\n\n  2. If no such file exists, the error message using an\n     explicit \"--\" is better:\n\n       # before\n       $ git rebase -i origin bogus\n       error: pathspec 'bogus' did not match any file(s) known to git.\n       Could not checkout bogus\n\n       # after\n       $ git rebase -i origin bogus\n       fatal: invalid reference: bogus\n       Could not checkout bogus\n\nThe problems seem to be trigger-able only through \"git\nrebase -i\", as regular git-rebase checks the validity of the\nbranch parameter as a ref very early on. However, it doesn't\nhurt to be defensive.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n git-rebase--interactive.sh |    2 +-\n git-rebase.sh              |    2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex a5ffd9a..7bd5602 100755\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -894,7 +894,7 @@ first and then run 'git rebase --continue' again.\"\n \n \t\tif test ! -z \"$1\"\n \t\tthen\n-\t\t\toutput git checkout \"$1\" ||\n+\t\t\toutput git checkout \"$1\" -- ||\n \t\t\t\tdie \"Could not checkout $1\"\n \t\tfi\n \ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d8e1903..345b18c 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -513,7 +513,7 @@ then\n \tif test -z \"$force_rebase\"\n \tthen\n \t\t# Lazily switch to the target branch if needed...\n-\t\ttest -z \"$switch_to\" || git checkout \"$switch_to\"\n+\t\ttest -z \"$switch_to\" || git checkout \"$switch_to\" --\n \t\tsay \"Current branch $branch_name is up to date.\"\n \t\texit 0\n \telse\n-- \n1.7.4.rc3.5.g8354b\n"}]}