Code

Turn builtin_exec_path into a function.
[git.git] / t / t5505-remote.sh
index 004a8dc5ed28f57de76935c4f02803fe6496d4d6..1e192a2207a4b56d477e8e3efc382c3a296ba776 100755 (executable)
@@ -77,6 +77,16 @@ test_expect_success 'add another remote' '
 )
 '
 
+test_expect_success 'remote forces tracking branches' '
+(
+       cd test &&
+       case `git config remote.second.fetch` in
+       +*) true ;;
+        *) false ;;
+       esac
+)
+'
+
 test_expect_success 'remove remote' '
 (
        cd test &&
@@ -106,6 +116,8 @@ cat > test/expect << EOF
     master
   Tracked remote branches
     side master
+  Local branches pushed with 'git push'
+    master:upstream +refs/tags/lastbackup
 EOF
 
 test_expect_success 'show' '
@@ -118,8 +130,31 @@ test_expect_success 'show' '
          echo 1 > file &&
          test_tick &&
          git commit -m update file) &&
+        git config remote.origin.push \
+               refs/heads/master:refs/heads/upstream &&
+        git config --add remote.origin.push \
+               +refs/tags/lastbackup &&
         git remote show origin > output &&
-        git diff expect output)
+        test_cmp expect output)
+'
+
+cat > test/expect << EOF
+* remote origin
+  URL: $(pwd)/one/.git
+  Remote branch merged with 'git pull' while on branch master
+    master
+  Tracked remote branches
+    master side
+  Local branches pushed with 'git push'
+    master:upstream +refs/tags/lastbackup
+EOF
+
+test_expect_success 'show -n' '
+       (mv one one.unreachable &&
+        cd test &&
+        git remote show -n origin > output &&
+        mv ../one.unreachable ../one &&
+        test_cmp expect output)
 '
 
 test_expect_success 'prune' '
@@ -132,6 +167,24 @@ test_expect_success 'prune' '
         ! git rev-parse refs/remotes/origin/side)
 '
 
+cat > test/expect << EOF
+Pruning origin
+URL: $(pwd)/one/.git
+ * [would prune] origin/side2
+EOF
+
+test_expect_success 'prune --dry-run' '
+       (cd one &&
+        git branch -m side2 side) &&
+       (cd test &&
+        git remote prune --dry-run origin > output &&
+        git rev-parse refs/remotes/origin/side2 &&
+        ! git rev-parse refs/remotes/origin/side &&
+       (cd ../one &&
+        git branch -m side side2) &&
+        test_cmp expect output)
+'
+
 test_expect_success 'add --mirror && prune' '
        (mkdir mirror &&
         cd mirror &&
@@ -148,6 +201,24 @@ test_expect_success 'add --mirror && prune' '
         git rev-parse --verify refs/heads/side)
 '
 
+test_expect_success 'add alt && prune' '
+       (mkdir alttst &&
+        cd alttst &&
+        git init &&
+        git remote add -f origin ../one &&
+        git config remote.alt.url ../one &&
+        git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
+       (cd one &&
+        git branch -m side side2) &&
+       (cd alttst &&
+        git rev-parse --verify refs/remotes/origin/side &&
+        ! git rev-parse --verify refs/remotes/origin/side2 &&
+        git fetch alt &&
+        git remote prune alt &&
+        ! git rev-parse --verify refs/remotes/origin/side &&
+        git rev-parse --verify refs/remotes/origin/side2)
+'
+
 cat > one/expect << EOF
   apis/master
   apis/side
@@ -163,7 +234,7 @@ test_expect_success 'update' '
         git remote add apis ../mirror &&
         git remote update &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -190,7 +261,7 @@ test_expect_success 'update with arguments' '
         git config remotes.titanus manduca &&
         git remote update phobaeticus titanus &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -213,7 +284,7 @@ test_expect_success 'update default' '
         git config remote.drosophila.skipDefaultUpdate true &&
         git remote update default &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -233,7 +304,7 @@ test_expect_success 'update default (overridden, with funny whitespace)' '
         git config remotes.default "$(printf "\t drosophila  \n")" &&
         git remote update default &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -247,4 +318,10 @@ test_expect_success '"remote show" does not show symbolic refs' '
 
 '
 
+test_expect_success 'reject adding remote with an invalid name' '
+
+       ! git remote add some:url desired-name
+
+'
+
 test_done