aboutsummaryrefslogtreecommitdiff
path: root/t/t3200-branch.sh
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2012-08-20 15:47:38 +0200
committerJunio C Hamano <gitster@pobox.com>2012-08-23 14:18:02 -0700
commit6183d826ba62ec94ccfcb8f6e3b8d43e3e338703 (patch)
tree6f951b43796c4d0a2b21a11b74132c81b4915c25 /t/t3200-branch.sh
parent889d35899ba64640e47798681ecb34a4be043bad (diff)
downloadgit-6183d826ba62ec94ccfcb8f6e3b8d43e3e338703.tar.gz
git-6183d826ba62ec94ccfcb8f6e3b8d43e3e338703.tar.xz
branch: introduce --set-upstream-to
The existing --set-uptream option can cause confusion, as it uses the usual branch convention of assuming a starting point of HEAD if none is specified, causing git branch --set-upstream origin/master to create a new local branch 'origin/master' that tracks the current branch. As --set-upstream already exists, we can't simply change its behaviour. To work around this, introduce --set-upstream-to which accepts a compulsory argument indicating what the new upstream branch should be and one optinal argument indicating which branch to change, defaulting to HEAD. The new options allows us to type git branch --set-upstream-to origin/master to set the current branch's upstream to be origin's master. Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3200-branch.sh')
-rwxr-xr-xt/t3200-branch.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index a17f8b2a4..e9019ac94 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -369,6 +369,20 @@ test_expect_success \
'git tag foobar &&
test_must_fail git branch --track my11 foobar'
+test_expect_success 'use --set-upstream-to modify HEAD' \
+ 'test_config branch.master.remote foo &&
+ test_config branch.master.merge foo &&
+ git branch my12
+ git branch --set-upstream-to my12 &&
+ test "$(git config branch.master.remote)" = "." &&
+ test "$(git config branch.master.merge)" = "refs/heads/my12"'
+
+test_expect_success 'use --set-upstream-to modify a particular branch' \
+ 'git branch my13
+ git branch --set-upstream-to master my13 &&
+ test "$(git config branch.my13.remote)" = "." &&
+ test "$(git config branch.my13.merge)" = "refs/heads/master"'
+
# Keep this test last, as it changes the current branch
cat >expect <<EOF
$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master