summaryrefslogtreecommitdiff
path: root/t/t5510-fetch.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t5510-fetch.sh')
-rwxr-xr-xt/t5510-fetch.sh189
1 files changed, 186 insertions, 3 deletions
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 439430f569..bee3424fed 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -37,7 +37,8 @@ test_expect_success "clone and setup child repos" '
echo "Pull: refs/heads/one:refs/heads/one"
} >.git/remotes/two &&
cd .. &&
- git clone . bundle
+ git clone . bundle &&
+ git clone . seven
'
test_expect_success "fetch test" '
@@ -67,6 +68,18 @@ test_expect_success "fetch test for-merge" '
cut -f -2 .git/FETCH_HEAD >actual &&
diff expected actual'
+test_expect_success 'fetch tags when there is no tags' '
+
+ cd "$D" &&
+
+ mkdir notags &&
+ cd notags &&
+ git init &&
+
+ git fetch -t ..
+
+'
+
test_expect_success 'fetch following tags' '
cd "$D" &&
@@ -83,6 +96,31 @@ test_expect_success 'fetch following tags' '
'
+test_expect_success 'fetch must not resolve short tag name' '
+
+ cd "$D" &&
+
+ mkdir five &&
+ cd five &&
+ git init &&
+
+ test_must_fail git fetch .. anno:five
+
+'
+
+test_expect_success 'fetch must not resolve short remote name' '
+
+ cd "$D" &&
+ git update-ref refs/remotes/six/HEAD HEAD
+
+ mkdir six &&
+ cd six &&
+ git init &&
+
+ test_must_fail git fetch .. six:six
+
+'
+
test_expect_success 'create bundle 1' '
cd "$D" &&
echo >file updated again by origin &&
@@ -102,10 +140,10 @@ test_expect_success 'create bundle 2' '
git bundle create bundle2 master~2..master
'
-test_expect_failure 'unbundle 1' '
+test_expect_success 'unbundle 1' '
cd "$D/bundle" &&
git checkout -b some-branch &&
- git fetch "$D/bundle1" master:master
+ test_must_fail git fetch "$D/bundle1" master:master
'
test_expect_success 'bundle 1 has only 3 files ' '
@@ -153,4 +191,149 @@ test_expect_success 'bundle should be able to create a full history' '
'
+! rsync --help > /dev/null 2> /dev/null &&
+say 'Skipping rsync tests because rsync was not found' || {
+test_expect_success 'fetch via rsync' '
+ git pack-refs &&
+ mkdir rsynced &&
+ (cd rsynced &&
+ git init --bare &&
+ git fetch "rsync:$(pwd)/../.git" master:refs/heads/master &&
+ git gc --prune &&
+ test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
+ git fsck --full)
+'
+
+test_expect_success 'push via rsync' '
+ mkdir rsynced2 &&
+ (cd rsynced2 &&
+ git init) &&
+ (cd rsynced &&
+ git push "rsync:$(pwd)/../rsynced2/.git" master) &&
+ (cd rsynced2 &&
+ git gc --prune &&
+ test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
+ git fsck --full)
+'
+
+test_expect_success 'push via rsync' '
+ mkdir rsynced3 &&
+ (cd rsynced3 &&
+ git init) &&
+ git push --all "rsync:$(pwd)/rsynced3/.git" &&
+ (cd rsynced3 &&
+ test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
+ git fsck --full)
+'
+}
+
+test_expect_success 'fetch with a non-applying branch.<name>.merge' '
+ git config branch.master.remote yeti &&
+ git config branch.master.merge refs/heads/bigfoot &&
+ git config remote.blub.url one &&
+ git config remote.blub.fetch "refs/heads/*:refs/remotes/one/*" &&
+ git fetch blub
+'
+
+# the strange name is: a\!'b
+test_expect_success 'quoting of a strangely named repo' '
+ test_must_fail git fetch "a\\!'\''b" > result 2>&1 &&
+ cat result &&
+ grep "fatal: '\''a\\\\!'\''b'\''" result
+'
+
+test_expect_success 'bundle should record HEAD correctly' '
+
+ cd "$D" &&
+ git bundle create bundle5 HEAD master &&
+ git bundle list-heads bundle5 >actual &&
+ for h in HEAD refs/heads/master
+ do
+ echo "$(git rev-parse --verify $h) $h"
+ done >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'explicit fetch should not update tracking' '
+
+ cd "$D" &&
+ git branch -f side &&
+ (
+ cd three &&
+ o=$(git rev-parse --verify refs/remotes/origin/master) &&
+ git fetch 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 'explicit pull should not update tracking' '
+
+ cd "$D" &&
+ git branch -f side &&
+ (
+ cd three &&
+ o=$(git rev-parse --verify refs/remotes/origin/master) &&
+ git pull 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" &&
+ git branch -f side &&
+ (
+ cd three &&
+ o=$(git rev-parse --verify refs/remotes/origin/master) &&
+ git fetch origin &&
+ n=$(git rev-parse --verify refs/remotes/origin/master) &&
+ test "$o" != "$n" &&
+ git rev-parse --verify refs/remotes/origin/side
+ )
+'
+
+test_expect_success 'pushing nonexistent branch by mistake should not segv' '
+
+ cd "$D" &&
+ test_must_fail git push seven no:no
+
+'
+
+test_expect_success 'auto tag following fetches minimum' '
+
+ cd "$D" &&
+ git clone .git follow &&
+ git checkout HEAD^0 &&
+ (
+ for i in 1 2 3 4 5 6 7
+ do
+ echo $i >>file &&
+ git commit -m $i -a &&
+ git tag -a -m $i excess-$i || exit 1
+ done
+ ) &&
+ git checkout master &&
+ (
+ cd follow &&
+ git fetch
+ )
+'
+
+test_expect_success 'refuse to fetch into the current branch' '
+
+ test_must_fail git fetch . side:master
+
+'
+
+test_expect_success 'fetch into the current branch with --update-head-ok' '
+
+ git fetch --update-head-ok . side:master
+
+'
+
test_done