t: use test_expect_code instead of hand-rolled comparison
[gitweb.git] / t / t5510-fetch.sh
index 29d59ef9fa2bf2bffb0075f07e03103387ab718e..0ba9db08847255d28e3e185d18b68703fb0755dc 100755 (executable)
@@ -124,7 +124,7 @@ test_expect_success 'fetch --prune handles overlapping refspecs' '
        git rev-parse origin/master &&
        git rev-parse origin/pr/42 &&
 
-       git config --unset-all remote.origin.fetch
+       git config --unset-all remote.origin.fetch &&
        git config remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* &&
        git config --add remote.origin.fetch refs/heads/*:refs/remotes/origin/* &&
 
@@ -447,6 +447,43 @@ test_expect_success 'explicit pull should update tracking' '
        )
 '
 
+test_expect_success 'explicit --refmap is allowed only with command-line refspec' '
+       cd "$D" &&
+       (
+               cd three &&
+               test_must_fail git fetch --refmap="*:refs/remotes/none/*"
+       )
+'
+
+test_expect_success 'explicit --refmap option overrides remote.*.fetch' '
+       cd "$D" &&
+       git branch -f side &&
+       (
+               cd three &&
+               git update-ref refs/remotes/origin/master base-origin-master &&
+               o=$(git rev-parse --verify refs/remotes/origin/master) &&
+               git fetch --refmap="refs/heads/*:refs/remotes/other/*" origin master &&
+               n=$(git rev-parse --verify refs/remotes/origin/master) &&
+               test "$o" = "$n" &&
+               test_must_fail git rev-parse --verify refs/remotes/origin/side &&
+               git rev-parse --verify refs/remotes/other/master
+       )
+'
+
+test_expect_success 'explicitly empty --refmap option disables remote.*.fetch' '
+       cd "$D" &&
+       git branch -f side &&
+       (
+               cd three &&
+               git update-ref refs/remotes/origin/master base-origin-master &&
+               o=$(git rev-parse --verify refs/remotes/origin/master) &&
+               git fetch --refmap="" origin master &&
+               n=$(git rev-parse --verify refs/remotes/origin/master) &&
+               test "$o" = "$n" &&
+               test_must_fail git rev-parse --verify refs/remotes/origin/side
+       )
+'
+
 test_expect_success 'configured fetch updates tracking' '
 
        cd "$D" &&
@@ -559,7 +596,7 @@ test_configured_prune () {
                        test_unconfig remote.origin.prune &&
                        git fetch &&
                        git rev-parse --verify refs/remotes/origin/newbranch
-               )
+               ) &&
 
                # now remove it
                git branch -d newbranch &&