From b347d06bf097aca5effd07871adf4d0c8a7c55bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 30 Aug 2012 19:23:13 +0200 Subject: branch: deprecate --set-upstream and show help if we detect possible mistaken use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This interface is error prone, and a better one (--set-upstream-to) exists. Add a message listing the alternatives and suggest how to fix a --set-upstream invocation in case the user only gives one argument which causes a local branch with the same name as a remote-tracking one to be created. The typical case is git branch --set-upstream origin/master when the user meant git branch --set-upstream master origin/master assuming that the current branch is master. Show a message telling the user how to undo their action and get what they wanted. For the command above, the message would be The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to Branch origin/master set up to track local branch master. If you wanted to make 'master' track 'origin/master', do this: git branch -d origin/master git branch --set-upstream-to origin/master Signed-off-by: Carlos Martín Nieto Signed-off-by: Junio C Hamano --- t/t3200-branch.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 't') diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 0bf72d2067..2a54a76abb 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -405,6 +405,40 @@ test_expect_success 'test --unset-upstream on a particular branch' \ test_must_fail git config branch.my14.remote && test_must_fail git config branch.my14.merge' +test_expect_success '--set-upstream shows message when creating a new branch that exists as remote-tracking' \ + 'git update-ref refs/remotes/origin/master HEAD && + git branch --set-upstream origin/master 2>actual && + test_when_finished git update-ref -d refs/remotes/origin/master && + test_when_finished git branch -d origin/master && + cat >expected <actual && + test_when_finished git branch --unset-upstream master && + cat >expected <actual && + test_when_finished git branch --unset-upstream my13 && + cat >expected <expect < 1117150200 +0000 branch: Created from master -- cgit v1.2.3