Code

Merge branch 'maint-1.5.4' into maint
[git.git] / t / t3200-branch.sh
index d21081d0f19bc52e1f1da54c220bc30a026f1093..cb5f7a444175938c8a9cc4c029b41b7325b91618 100755 (executable)
@@ -15,6 +15,9 @@ test_expect_success \
     'echo Hello > A &&
      git update-index --add A &&
      git-commit -m "Initial commit." &&
+     echo World >> A &&
+     git update-index --add A &&
+     git-commit -m "Second commit." &&
      HEAD=$(git rev-parse --verify HEAD)'
 
 test_expect_success \
@@ -150,16 +153,6 @@ test_expect_success 'test tracking setup via config' \
      test $(git config branch.my3.remote) = local &&
      test $(git config branch.my3.merge) = refs/heads/master'
 
-test_expect_success 'avoid ambiguous track' '
-       git config branch.autosetupmerge true &&
-       git config remote.ambi1.url = lalala &&
-       git config remote.ambi1.fetch = refs/heads/lalala:refs/heads/master &&
-       git config remote.ambi2.url = lilili &&
-       git config remote.ambi2.fetch = refs/heads/lilili:refs/heads/master &&
-       git branch all1 master &&
-       test -z "$(git config branch.all1.merge)"
-'
-
 test_expect_success 'test overriding tracking setup via --no-track' \
     'git config branch.autosetupmerge true &&
      git config remote.local.url . &&
@@ -171,7 +164,9 @@ test_expect_success 'test overriding tracking setup via --no-track' \
      ! test "$(git config branch.my2.merge)" = refs/heads/master'
 
 test_expect_success 'no tracking without .fetch entries' \
-    'git branch --track my6 s &&
+    'git config branch.autosetupmerge true &&
+     git branch my6 s &&
+     git config branch.automsetupmerge false &&
      test -z "$(git config branch.my6.remote)" &&
      test -z "$(git config branch.my6.merge)"'
 
@@ -192,6 +187,21 @@ test_expect_success 'test deleting branch without config' \
     'git branch my7 s &&
      test "$(git branch -d my7 2>&1)" = "Deleted branch my7."'
 
+test_expect_success 'test --track without .fetch entries' \
+    'git branch --track my8 &&
+     test "$(git config branch.my8.remote)" &&
+     test "$(git config branch.my8.merge)"'
+
+test_expect_success \
+    'branch from non-branch HEAD w/autosetupmerge=always' \
+    'git config branch.autosetupmerge always &&
+     git branch my9 HEAD^ &&
+     git config branch.autosetupmerge false'
+
+test_expect_success \
+    'branch from non-branch HEAD w/--track causes failure' \
+    '!(git branch --track my10 HEAD^)'
+
 # Keep this test last, as it changes the current branch
 cat >expect <<EOF
 0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000     branch: Created from master
@@ -204,4 +214,14 @@ test_expect_success \
         test -f .git/logs/refs/heads/g/h/i &&
         diff expect .git/logs/refs/heads/g/h/i'
 
+test_expect_success 'avoid ambiguous track' '
+       git config branch.autosetupmerge true &&
+       git config remote.ambi1.url lalala &&
+       git config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&
+       git config remote.ambi2.url lilili &&
+       git config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&
+       git branch all1 master &&
+       test -z "$(git config branch.all1.merge)"
+'
+
 test_done