--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
+#
+
+test_description='test clone --reference'
+. ./test-lib.sh
+
+base_dir=`pwd`
+
+U=$base_dir/UPLOAD_LOG
+
+# create a commit in repo $1 with name $2
+commit_in () {
+ (
+ cd "$1" &&
+ echo "$2" >"$2" &&
+ git add "$2" &&
+ git commit -m "$2"
+ )
+}
+
+# check that there are $2 loose objects in repo $1
+test_objcount () {
+ echo "$2" >expect &&
+ git -C "$1" count-objects >actual.raw &&
+ cut -d' ' -f1 <actual.raw >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success 'preparing first repository' '
+ test_create_repo A &&
+ commit_in A file1
+'
+
+test_expect_success 'preparing second repository' '
+ git clone A B &&
+ commit_in B file2 &&
+ git -C B repack -ad &&
+ git -C B prune
+'
+
+test_expect_success 'cloning with reference (-l -s)' '
+ git clone -l -s --reference B A C
+'
+
+test_expect_success 'existence of info/alternates' '
+ test_line_count = 2 C/.git/objects/info/alternates
+'
+
+test_expect_success 'pulling from reference' '
+ git -C C pull ../B master
+'
+
+test_expect_success 'that reference gets used' '
+ test_objcount C 0
+'
+
+test_expect_success 'cloning with reference (no -l -s)' '
+ GIT_TRACE_PACKET=$U.D git clone --reference B "file://$(pwd)/A" D
+'
+
+test_expect_success 'fetched no objects' '
+ test -s "$U.D" &&
+ ! grep " want" "$U.D"
+'
+
+test_expect_success 'existence of info/alternates' '
+ test_line_count = 1 D/.git/objects/info/alternates
+'
+
+test_expect_success 'pulling from reference' '
+ git -C D pull ../B master
+'
+
+test_expect_success 'that reference gets used' '
+ test_objcount D 0
+'
+
+test_expect_success 'updating origin' '
+ commit_in A file3 &&
+ git -C A repack -ad &&
+ git -C A prune
+'
+
+test_expect_success 'pulling changes from origin' '
+ git -C C pull origin
+'
+
+# the 2 local objects are commit and tree from the merge
+test_expect_success 'that alternate to origin gets used' '
+ test_objcount C 2
+'
+
+test_expect_success 'pulling changes from origin' '
+ git -C D pull origin
+'
+
+# the 5 local objects are expected; file3 blob, commit in A to add it
+# and its tree, and 2 are our tree and the merge commit.
+test_expect_success 'check objects expected to exist locally' '
+ test_objcount D 5
+'
+
+test_expect_success 'preparing alternate repository #1' '
+ test_create_repo F &&
+ commit_in F file1
+'
+
+test_expect_success 'cloning alternate repo #2 and adding changes to repo #1' '
+ git clone F G &&
+ commit_in F file2
+'
+
+test_expect_success 'cloning alternate repo #1, using #2 as reference' '
+ git clone --reference G F H
+'
+
+test_expect_success 'cloning with reference being subset of source (-l -s)' '
+ git clone -l -s --reference A B E
+'
+
+test_expect_success 'cloning with multiple references drops duplicates' '
+ git clone -s --reference B --reference A --reference B A dups &&
+ test_line_count = 2 dups/.git/objects/info/alternates
+'
+
+test_expect_success 'clone with reference from a tagged repository' '
+ (
+ cd A && git tag -a -m tagged HEAD
+ ) &&
+ git clone --reference=A A I
+'
+
+test_expect_success 'prepare branched repository' '
+ git clone A J &&
+ (
+ cd J &&
+ git checkout -b other master^ &&
+ echo other >otherfile &&
+ git add otherfile &&
+ git commit -m other &&
+ git checkout master
+ )
+'
+
+test_expect_success 'fetch with incomplete alternates' '
+ git init K &&
+ echo "$base_dir/A/.git/objects" >K/.git/objects/info/alternates &&
+ (
+ cd K &&
+ git remote add J "file://$base_dir/J" &&
+ GIT_TRACE_PACKET=$U.K git fetch J
+ ) &&
+ master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
+ test -s "$U.K" &&
+ ! grep " want $master_object" "$U.K" &&
+ tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
+ ! grep " want $tag_object" "$U.K"
+'
+
+test_expect_success 'clone using repo with gitfile as a reference' '
+ git clone --separate-git-dir=L A M &&
+ git clone --reference=M A N &&
+ echo "$base_dir/L/objects" >expected &&
+ test_cmp expected "$base_dir/N/.git/objects/info/alternates"
+'
+
+test_expect_success 'clone using repo pointed at by gitfile as reference' '
+ git clone --reference=M/.git A O &&
+ echo "$base_dir/L/objects" >expected &&
+ test_cmp expected "$base_dir/O/.git/objects/info/alternates"
+'
+
+test_expect_success 'clone and dissociate from reference' '
+ git init P &&
+ (
+ cd P && test_commit one
+ ) &&
+ git clone P Q &&
+ (
+ cd Q && test_commit two
+ ) &&
+ git clone --no-local --reference=P Q R &&
+ git clone --no-local --reference=P --dissociate Q S &&
+ # removing the reference P would corrupt R but not S
+ rm -fr P &&
+ test_must_fail git -C R fsck &&
+ git -C S fsck
+'
+test_expect_success 'clone, dissociate from partial reference and repack' '
+ rm -fr P Q R &&
+ git init P &&
+ (
+ cd P &&
+ test_commit one &&
+ git repack &&
+ test_commit two &&
+ git repack
+ ) &&
+ git clone --bare P Q &&
+ (
+ cd P &&
+ git checkout -b second &&
+ test_commit three &&
+ git repack
+ ) &&
+ git clone --bare --dissociate --reference=P Q R &&
+ ls R/objects/pack/*.pack >packs.txt &&
+ test_line_count = 1 packs.txt
+'
+
+test_expect_success 'clone, dissociate from alternates' '
+ rm -fr A B C &&
+ test_create_repo A &&
+ commit_in A file1 &&
+ git clone --reference=A A B &&
+ test_line_count = 1 B/.git/objects/info/alternates &&
+ git clone --local --dissociate B C &&
+ ! test -f C/.git/objects/info/alternates &&
+ ( cd C && git fsck )
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='test local clone'
+. ./test-lib.sh
+
+repo_is_hardlinked() {
+ find "$1/objects" -type f -links 1 >output &&
+ test_line_count = 0 output
+}
+
+test_expect_success 'preparing origin repository' '
+ : >file && git add . && git commit -m1 &&
+ git clone --bare . a.git &&
+ git clone --bare . x &&
+ test "$(cd a.git && git config --bool core.bare)" = true &&
+ test "$(cd x && git config --bool core.bare)" = true &&
+ git bundle create b1.bundle --all &&
+ git bundle create b2.bundle master &&
+ mkdir dir &&
+ cp b1.bundle dir/b3 &&
+ cp b1.bundle b4
+'
+
+test_expect_success 'local clone without .git suffix' '
+ git clone -l -s a b &&
+ (cd b &&
+ test "$(git config --bool core.bare)" = false &&
+ git fetch)
+'
+
+test_expect_success 'local clone with .git suffix' '
+ git clone -l -s a.git c &&
+ (cd c && git fetch)
+'
+
+test_expect_success 'local clone from x' '
+ git clone -l -s x y &&
+ (cd y && git fetch)
+'
+
+test_expect_success 'local clone from x.git that does not exist' '
+ test_must_fail git clone -l -s x.git z
+'
+
+test_expect_success 'With -no-hardlinks, local will make a copy' '
+ git clone --bare --no-hardlinks x w &&
+ ! repo_is_hardlinked w
+'
+
+test_expect_success 'Even without -l, local will make a hardlink' '
+ rm -fr w &&
+ git clone -l --bare x w &&
+ repo_is_hardlinked w
+'
+
+test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
+ echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
+ git clone a d &&
+ (cd d &&
+ git fetch &&
+ test ! -e .git/refs/remotes/origin/HEAD)
+'
+
+test_expect_success 'bundle clone without .bundle suffix' '
+ git clone dir/b3 &&
+ (cd b3 && git fetch)
+'
+
+test_expect_success 'bundle clone with .bundle suffix' '
+ git clone b1.bundle &&
+ (cd b1 && git fetch)
+'
+
+test_expect_success 'bundle clone from b4' '
+ git clone b4 bdl &&
+ (cd bdl && git fetch)
+'
+
+test_expect_success 'bundle clone from b4.bundle that does not exist' '
+ test_must_fail git clone b4.bundle bb
+'
+
+test_expect_success 'bundle clone with nonexistent HEAD' '
+ git clone b2.bundle b2 &&
+ (cd b2 &&
+ git fetch &&
+ test_must_fail git rev-parse --verify refs/heads/master)
+'
+
+test_expect_success 'clone empty repository' '
+ mkdir empty &&
+ (cd empty &&
+ git init &&
+ git config receive.denyCurrentBranch warn) &&
+ git clone empty empty-clone &&
+ test_tick &&
+ (cd empty-clone
+ echo "content" >> foo &&
+ git add foo &&
+ git commit -m "Initial commit" &&
+ git push origin master &&
+ expected=$(git rev-parse master) &&
+ actual=$(git --git-dir=../empty/.git rev-parse master) &&
+ test $actual = $expected)
+'
+
+test_expect_success 'clone empty repository, and then push should not segfault.' '
+ rm -fr empty/ empty-clone/ &&
+ mkdir empty &&
+ (cd empty && git init) &&
+ git clone empty empty-clone &&
+ (cd empty-clone &&
+ test_must_fail git push)
+'
+
+test_expect_success 'cloning non-existent directory fails' '
+ rm -rf does-not-exist &&
+ test_must_fail git clone does-not-exist
+'
+
+test_expect_success 'cloning non-git directory fails' '
+ rm -rf not-a-git-repo not-a-git-repo-clone &&
+ mkdir not-a-git-repo &&
+ test_must_fail git clone not-a-git-repo not-a-git-repo-clone
+'
+
+test_expect_success 'cloning file:// does not hardlink' '
+ git clone --bare file://"$(pwd)"/a non-local &&
+ ! repo_is_hardlinked non-local
+'
+
+test_expect_success 'cloning a local path with --no-local does not hardlink' '
+ git clone --bare --no-local a force-nonlocal &&
+ ! repo_is_hardlinked force-nonlocal
+'
+
+test_expect_success 'cloning locally respects "-u" for fetching refs' '
+ test_must_fail git clone --bare -u false a should_not_work.git
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='basic clone options'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ mkdir parent &&
+ (cd parent && git init &&
+ echo one >file && git add file &&
+ git commit -m one)
+
+'
+
+test_expect_success 'clone -o' '
+
+ git clone -o foo parent clone-o &&
+ (cd clone-o && git rev-parse --verify refs/remotes/foo/master)
+
+'
+
+test_expect_success 'redirected clone does not show progress' '
+
+ git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
+ ! grep % err &&
+ test_i18ngrep ! "Checking connectivity" err
+
+'
+
+test_expect_success 'redirected clone -v does show progress' '
+
+ git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
+ >out 2>err &&
+ grep % err
+
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='some bundle related tests'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ test_commit initial &&
+ test_tick &&
+ git tag -m tag tag &&
+ test_commit second &&
+ test_commit third &&
+ git tag -d initial &&
+ git tag -d second &&
+ git tag -d third
+'
+
+test_expect_success 'annotated tags can be excluded by rev-list options' '
+ git bundle create bundle --all --since=7.Apr.2005.15:14:00.-0700 &&
+ git ls-remote bundle > output &&
+ grep tag output &&
+ git bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 &&
+ git ls-remote bundle > output &&
+ ! grep tag output
+'
+
+test_expect_success 'die if bundle file cannot be created' '
+ mkdir adir &&
+ test_must_fail git bundle create adir --all
+'
+
+test_expect_failure 'bundle --stdin' '
+ echo master | git bundle create stdin-bundle.bdl --stdin &&
+ git ls-remote stdin-bundle.bdl >output &&
+ grep master output
+'
+
+test_expect_failure 'bundle --stdin <rev-list options>' '
+ echo master | git bundle create hybrid-bundle.bdl --stdin tag &&
+ git ls-remote hybrid-bundle.bdl >output &&
+ grep master output
+'
+
+test_expect_success 'empty bundle file is rejected' '
+ : >empty-bundle &&
+ test_must_fail git fetch empty-bundle
+'
+
+# This triggers a bug in older versions where the resulting line (with
+# --pretty=oneline) was longer than a 1024-char buffer.
+test_expect_success 'ridiculously long subject in boundary' '
+ : >file4 &&
+ test_tick &&
+ git add file4 &&
+ printf "%01200d\n" 0 | git commit -F - &&
+ test_commit fifth &&
+ git bundle create long-subject-bundle.bdl HEAD^..HEAD &&
+ git bundle list-heads long-subject-bundle.bdl >heads &&
+ test -s heads &&
+ git fetch long-subject-bundle.bdl &&
+ sed -n "/^-/{p;q;}" long-subject-bundle.bdl >boundary &&
+ grep "^-[0-9a-f]\\{40\\} " boundary
+'
+
+test_expect_success 'prerequisites with an empty commit message' '
+ : >file1 &&
+ git add file1 &&
+ test_tick &&
+ git commit --allow-empty-message -m "" &&
+ test_commit file2 &&
+ git bundle create bundle HEAD^.. &&
+ git bundle verify bundle
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='Test cloning a repository larger than 2 gigabyte'
+. ./test-lib.sh
+
+if test -z "$GIT_TEST_CLONE_2GB"
+then
+ say 'Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t'
+else
+ test_set_prereq CLONE_2GB
+fi
+
+test_expect_success CLONE_2GB 'setup' '
+
+ git config pack.compression 0 &&
+ git config pack.depth 0 &&
+ blobsize=$((100*1024*1024)) &&
+ blobcount=$((2*1024*1024*1024/$blobsize+1)) &&
+ i=1 &&
+ (while test $i -le $blobcount
+ do
+ printf "Generating blob $i/$blobcount\r" >&2 &&
+ printf "blob\nmark :$i\ndata $blobsize\n" &&
+ #test-genrandom $i $blobsize &&
+ printf "%-${blobsize}s" $i &&
+ echo "M 100644 :$i $i" >> commit
+ i=$(($i+1)) ||
+ echo $? > exit-status
+ done &&
+ echo "commit refs/heads/master" &&
+ echo "author A U Thor <author@email.com> 123456789 +0000" &&
+ echo "committer C O Mitter <committer@email.com> 123456789 +0000" &&
+ echo "data 5" &&
+ echo ">2gb" &&
+ cat commit) |
+ git fast-import --big-file-threshold=2 &&
+ test ! -f exit-status
+
+'
+
+test_expect_success CLONE_2GB 'clone - bare' '
+
+ git clone --bare --no-hardlinks . clone-bare
+
+'
+
+test_expect_success CLONE_2GB 'clone - with worktree, file:// protocol' '
+
+ git clone "file://$(pwd)" clone-wt
+
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='clone --branch option'
+. ./test-lib.sh
+
+check_HEAD() {
+ echo refs/heads/"$1" >expect &&
+ git symbolic-ref HEAD >actual &&
+ test_cmp expect actual
+}
+
+check_file() {
+ echo "$1" >expect &&
+ test_cmp expect file
+}
+
+test_expect_success 'setup' '
+ mkdir parent &&
+ (cd parent && git init &&
+ echo one >file && git add file && git commit -m one &&
+ git checkout -b two &&
+ echo two >file && git add file && git commit -m two &&
+ git checkout master) &&
+ mkdir empty &&
+ (cd empty && git init)
+'
+
+test_expect_success 'vanilla clone chooses HEAD' '
+ git clone parent clone &&
+ (cd clone &&
+ check_HEAD master &&
+ check_file one
+ )
+'
+
+test_expect_success 'clone -b chooses specified branch' '
+ git clone -b two parent clone-two &&
+ (cd clone-two &&
+ check_HEAD two &&
+ check_file two
+ )
+'
+
+test_expect_success 'clone -b sets up tracking' '
+ (cd clone-two &&
+ echo origin >expect &&
+ git config branch.two.remote >actual &&
+ echo refs/heads/two >>expect &&
+ git config branch.two.merge >>actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'clone -b does not munge remotes/origin/HEAD' '
+ (cd clone-two &&
+ echo refs/remotes/origin/master >expect &&
+ git symbolic-ref refs/remotes/origin/HEAD >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'clone -b with bogus branch' '
+ test_must_fail git clone -b bogus parent clone-bogus
+'
+
+test_expect_success 'clone -b not allowed with empty repos' '
+ test_must_fail git clone -b branch empty clone-branch-empty
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='test cloning a repository with detached HEAD'
+. ./test-lib.sh
+
+head_is_detached() {
+ git --git-dir=$1/.git rev-parse --verify HEAD &&
+ test_must_fail git --git-dir=$1/.git symbolic-ref HEAD
+}
+
+test_expect_success 'setup' '
+ echo one >file &&
+ git add file &&
+ git commit -m one &&
+ echo two >file &&
+ git commit -a -m two &&
+ git tag two &&
+ echo three >file &&
+ git commit -a -m three
+'
+
+test_expect_success 'clone repo (detached HEAD points to branch)' '
+ git checkout master^0 &&
+ git clone "file://$PWD" detached-branch
+'
+test_expect_success 'cloned HEAD matches' '
+ echo three >expect &&
+ git --git-dir=detached-branch/.git log -1 --format=%s >actual &&
+ test_cmp expect actual
+'
+test_expect_failure 'cloned HEAD is detached' '
+ head_is_detached detached-branch
+'
+
+test_expect_success 'clone repo (detached HEAD points to tag)' '
+ git checkout two^0 &&
+ git clone "file://$PWD" detached-tag
+'
+test_expect_success 'cloned HEAD matches' '
+ echo two >expect &&
+ git --git-dir=detached-tag/.git log -1 --format=%s >actual &&
+ test_cmp expect actual
+'
+test_expect_success 'cloned HEAD is detached' '
+ head_is_detached detached-tag
+'
+
+test_expect_success 'clone repo (detached HEAD points to history)' '
+ git checkout two^ &&
+ git clone "file://$PWD" detached-history
+'
+test_expect_success 'cloned HEAD matches' '
+ echo one >expect &&
+ git --git-dir=detached-history/.git log -1 --format=%s >actual &&
+ test_cmp expect actual
+'
+test_expect_success 'cloned HEAD is detached' '
+ head_is_detached detached-history
+'
+
+test_expect_success 'clone repo (orphan detached HEAD)' '
+ git checkout master^0 &&
+ echo four >file &&
+ git commit -a -m four &&
+ git clone "file://$PWD" detached-orphan
+'
+test_expect_success 'cloned HEAD matches' '
+ echo four >expect &&
+ git --git-dir=detached-orphan/.git log -1 --format=%s >actual &&
+ test_cmp expect actual
+'
+test_expect_success 'cloned HEAD is detached' '
+ head_is_detached detached-orphan
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='tests for git clone -c key=value'
+. ./test-lib.sh
+
+test_expect_success 'clone -c sets config in cloned repo' '
+ rm -rf child &&
+ git clone -c core.foo=bar . child &&
+ echo bar >expect &&
+ git --git-dir=child/.git config core.foo >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'clone -c can set multi-keys' '
+ rm -rf child &&
+ git clone -c core.foo=bar -c core.foo=baz . child &&
+ { echo bar; echo baz; } >expect &&
+ git --git-dir=child/.git config --get-all core.foo >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'clone -c without a value is boolean true' '
+ rm -rf child &&
+ git clone -c core.foo . child &&
+ echo true >expect &&
+ git --git-dir=child/.git config --bool core.foo >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'clone -c config is available during clone' '
+ echo content >file &&
+ git add file &&
+ git commit -m one &&
+ rm -rf child &&
+ git clone -c core.autocrlf . child &&
+ printf "content\\r\\n" >expect &&
+ test_cmp expect child/file
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+
+test_description='test refspec written by clone-command'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ # Make two branches, "master" and "side"
+ echo one >file &&
+ git add file &&
+ git commit -m one &&
+ echo two >file &&
+ git commit -a -m two &&
+ git tag two &&
+ echo three >file &&
+ git commit -a -m three &&
+ git checkout -b side &&
+ echo four >file &&
+ git commit -a -m four &&
+ git checkout master &&
+
+ # default clone
+ git clone . dir_all &&
+
+ # default --single that follows HEAD=master
+ git clone --single-branch . dir_master &&
+
+ # default --single that follows HEAD=side
+ git checkout side &&
+ git clone --single-branch . dir_side &&
+
+ # explicit --single that follows side
+ git checkout master &&
+ git clone --single-branch --branch side . dir_side2 &&
+
+ # default --single with --mirror
+ git clone --single-branch --mirror . dir_mirror &&
+
+ # default --single with --branch and --mirror
+ git clone --single-branch --mirror --branch side . dir_mirror_side &&
+
+ # --single that does not know what branch to follow
+ git checkout two^ &&
+ git clone --single-branch . dir_detached &&
+
+ # explicit --single with tag
+ git clone --single-branch --branch two . dir_tag &&
+
+ # advance both "master" and "side" branches
+ git checkout side &&
+ echo five >file &&
+ git commit -a -m five &&
+ git checkout master &&
+ echo six >file &&
+ git commit -a -m six &&
+
+ # update tag
+ git tag -d two && git tag two
+'
+
+test_expect_success 'by default all branches will be kept updated' '
+ (
+ cd dir_all && git fetch &&
+ git for-each-ref refs/remotes/origin |
+ sed -e "/HEAD$/d" \
+ -e "s|/remotes/origin/|/heads/|" >../actual
+ ) &&
+ # follow both master and side
+ git for-each-ref refs/heads >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'by default no tags will be kept updated' '
+ (
+ cd dir_all && git fetch &&
+ git for-each-ref refs/tags >../actual
+ ) &&
+ git for-each-ref refs/tags >expect &&
+ test_must_fail test_cmp expect actual
+'
+
+test_expect_success '--single-branch while HEAD pointing at master' '
+ (
+ cd dir_master && git fetch &&
+ git for-each-ref refs/remotes/origin |
+ sed -e "/HEAD$/d" \
+ -e "s|/remotes/origin/|/heads/|" >../actual
+ ) &&
+ # only follow master
+ git for-each-ref refs/heads/master >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--single-branch while HEAD pointing at side' '
+ (
+ cd dir_side && git fetch &&
+ git for-each-ref refs/remotes/origin |
+ sed -e "/HEAD$/d" \
+ -e "s|/remotes/origin/|/heads/|" >../actual
+ ) &&
+ # only follow side
+ git for-each-ref refs/heads/side >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--single-branch with explicit --branch side' '
+ (
+ cd dir_side2 && git fetch &&
+ git for-each-ref refs/remotes/origin |
+ sed -e "/HEAD$/d" \
+ -e "s|/remotes/origin/|/heads/|" >../actual
+ ) &&
+ # only follow side
+ git for-each-ref refs/heads/side >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '
+ (
+ cd dir_tag && git fetch &&
+ git for-each-ref refs/tags >../actual
+ ) &&
+ git for-each-ref refs/tags >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--single-branch with --mirror' '
+ (
+ cd dir_mirror && git fetch &&
+ git for-each-ref refs > ../actual
+ ) &&
+ git for-each-ref refs >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--single-branch with explicit --branch and --mirror' '
+ (
+ cd dir_mirror_side && git fetch &&
+ git for-each-ref refs > ../actual
+ ) &&
+ git for-each-ref refs >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success '--single-branch with detached' '
+ (
+ cd dir_detached && git fetch &&
+ git for-each-ref refs/remotes/origin |
+ sed -e "/HEAD$/d" \
+ -e "s|/remotes/origin/|/heads/|" >../actual
+ ) &&
+ # nothing
+ >expect &&
+ test_cmp expect actual
+'
+
+test_done
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
+#
+
+test_description='test transitive info/alternate entries'
+. ./test-lib.sh
+
+# test that a file is not reachable in the current repository
+# but that it is after creating a info/alternate entry
+reachable_via() {
+ alternate="$1"
+ file="$2"
+ if git cat-file -e "HEAD:$file"; then return 1; fi
+ echo "$alternate" >> .git/objects/info/alternate
+ git cat-file -e "HEAD:$file"
+}
+
+test_valid_repo() {
+ git fsck --full > fsck.log &&
+ test_line_count = 0 fsck.log
+}
+
+base_dir=`pwd`
+
+test_expect_success 'preparing first repository' \
+'test_create_repo A && cd A &&
+echo "Hello World" > file1 &&
+git add file1 &&
+git commit -m "Initial commit" file1 &&
+git repack -a -d &&
+git prune'
+
+cd "$base_dir"
+
+test_expect_success 'preparing second repository' \
+'git clone -l -s A B && cd B &&
+echo "foo bar" > file2 &&
+git add file2 &&
+git commit -m "next commit" file2 &&
+git repack -a -d -l &&
+git prune'
+
+cd "$base_dir"
+
+test_expect_success 'preparing third repository' \
+'git clone -l -s B C && cd C &&
+echo "Goodbye, cruel world" > file3 &&
+git add file3 &&
+git commit -m "one more" file3 &&
+git repack -a -d -l &&
+git prune'
+
+cd "$base_dir"
+
+test_expect_success 'creating too deep nesting' \
+'git clone -l -s C D &&
+git clone -l -s D E &&
+git clone -l -s E F &&
+git clone -l -s F G &&
+git clone --bare -l -s G H'
+
+test_expect_success 'invalidity of deepest repository' \
+'cd H && {
+ test_valid_repo
+ test $? -ne 0
+}'
+
+cd "$base_dir"
+
+test_expect_success 'validity of third repository' \
+'cd C &&
+test_valid_repo'
+
+cd "$base_dir"
+
+test_expect_success 'validity of fourth repository' \
+'cd D &&
+test_valid_repo'
+
+cd "$base_dir"
+
+test_expect_success 'breaking of loops' \
+'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
+cd C &&
+test_valid_repo'
+
+cd "$base_dir"
+
+test_expect_success 'that info/alternates is necessary' \
+'cd C &&
+rm -f .git/objects/info/alternates &&
+! (test_valid_repo)'
+
+cd "$base_dir"
+
+test_expect_success 'that relative alternate is possible for current dir' \
+'cd C &&
+echo "../../../B/.git/objects" > .git/objects/info/alternates &&
+test_valid_repo'
+
+cd "$base_dir"
+
+test_expect_success \
+ 'that relative alternate is only possible for current dir' '
+ cd D &&
+ ! (test_valid_repo)
+'
+
+cd "$base_dir"
+
+test_done
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
-#
-
-test_description='test clone --reference'
-. ./test-lib.sh
-
-base_dir=`pwd`
-
-U=$base_dir/UPLOAD_LOG
-
-# create a commit in repo $1 with name $2
-commit_in () {
- (
- cd "$1" &&
- echo "$2" >"$2" &&
- git add "$2" &&
- git commit -m "$2"
- )
-}
-
-# check that there are $2 loose objects in repo $1
-test_objcount () {
- echo "$2" >expect &&
- git -C "$1" count-objects >actual.raw &&
- cut -d' ' -f1 <actual.raw >actual &&
- test_cmp expect actual
-}
-
-test_expect_success 'preparing first repository' '
- test_create_repo A &&
- commit_in A file1
-'
-
-test_expect_success 'preparing second repository' '
- git clone A B &&
- commit_in B file2 &&
- git -C B repack -ad &&
- git -C B prune
-'
-
-test_expect_success 'cloning with reference (-l -s)' '
- git clone -l -s --reference B A C
-'
-
-test_expect_success 'existence of info/alternates' '
- test_line_count = 2 C/.git/objects/info/alternates
-'
-
-test_expect_success 'pulling from reference' '
- git -C C pull ../B master
-'
-
-test_expect_success 'that reference gets used' '
- test_objcount C 0
-'
-
-test_expect_success 'cloning with reference (no -l -s)' '
- GIT_TRACE_PACKET=$U.D git clone --reference B "file://$(pwd)/A" D
-'
-
-test_expect_success 'fetched no objects' '
- test -s "$U.D" &&
- ! grep " want" "$U.D"
-'
-
-test_expect_success 'existence of info/alternates' '
- test_line_count = 1 D/.git/objects/info/alternates
-'
-
-test_expect_success 'pulling from reference' '
- git -C D pull ../B master
-'
-
-test_expect_success 'that reference gets used' '
- test_objcount D 0
-'
-
-test_expect_success 'updating origin' '
- commit_in A file3 &&
- git -C A repack -ad &&
- git -C A prune
-'
-
-test_expect_success 'pulling changes from origin' '
- git -C C pull origin
-'
-
-# the 2 local objects are commit and tree from the merge
-test_expect_success 'that alternate to origin gets used' '
- test_objcount C 2
-'
-
-test_expect_success 'pulling changes from origin' '
- git -C D pull origin
-'
-
-# the 5 local objects are expected; file3 blob, commit in A to add it
-# and its tree, and 2 are our tree and the merge commit.
-test_expect_success 'check objects expected to exist locally' '
- test_objcount D 5
-'
-
-test_expect_success 'preparing alternate repository #1' '
- test_create_repo F &&
- commit_in F file1
-'
-
-test_expect_success 'cloning alternate repo #2 and adding changes to repo #1' '
- git clone F G &&
- commit_in F file2
-'
-
-test_expect_success 'cloning alternate repo #1, using #2 as reference' '
- git clone --reference G F H
-'
-
-test_expect_success 'cloning with reference being subset of source (-l -s)' '
- git clone -l -s --reference A B E
-'
-
-test_expect_success 'cloning with multiple references drops duplicates' '
- git clone -s --reference B --reference A --reference B A dups &&
- test_line_count = 2 dups/.git/objects/info/alternates
-'
-
-test_expect_success 'clone with reference from a tagged repository' '
- (
- cd A && git tag -a -m tagged HEAD
- ) &&
- git clone --reference=A A I
-'
-
-test_expect_success 'prepare branched repository' '
- git clone A J &&
- (
- cd J &&
- git checkout -b other master^ &&
- echo other >otherfile &&
- git add otherfile &&
- git commit -m other &&
- git checkout master
- )
-'
-
-test_expect_success 'fetch with incomplete alternates' '
- git init K &&
- echo "$base_dir/A/.git/objects" >K/.git/objects/info/alternates &&
- (
- cd K &&
- git remote add J "file://$base_dir/J" &&
- GIT_TRACE_PACKET=$U.K git fetch J
- ) &&
- master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
- test -s "$U.K" &&
- ! grep " want $master_object" "$U.K" &&
- tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
- ! grep " want $tag_object" "$U.K"
-'
-
-test_expect_success 'clone using repo with gitfile as a reference' '
- git clone --separate-git-dir=L A M &&
- git clone --reference=M A N &&
- echo "$base_dir/L/objects" >expected &&
- test_cmp expected "$base_dir/N/.git/objects/info/alternates"
-'
-
-test_expect_success 'clone using repo pointed at by gitfile as reference' '
- git clone --reference=M/.git A O &&
- echo "$base_dir/L/objects" >expected &&
- test_cmp expected "$base_dir/O/.git/objects/info/alternates"
-'
-
-test_expect_success 'clone and dissociate from reference' '
- git init P &&
- (
- cd P && test_commit one
- ) &&
- git clone P Q &&
- (
- cd Q && test_commit two
- ) &&
- git clone --no-local --reference=P Q R &&
- git clone --no-local --reference=P --dissociate Q S &&
- # removing the reference P would corrupt R but not S
- rm -fr P &&
- test_must_fail git -C R fsck &&
- git -C S fsck
-'
-test_expect_success 'clone, dissociate from partial reference and repack' '
- rm -fr P Q R &&
- git init P &&
- (
- cd P &&
- test_commit one &&
- git repack &&
- test_commit two &&
- git repack
- ) &&
- git clone --bare P Q &&
- (
- cd P &&
- git checkout -b second &&
- test_commit three &&
- git repack
- ) &&
- git clone --bare --dissociate --reference=P Q R &&
- ls R/objects/pack/*.pack >packs.txt &&
- test_line_count = 1 packs.txt
-'
-
-test_expect_success 'clone, dissociate from alternates' '
- rm -fr A B C &&
- test_create_repo A &&
- commit_in A file1 &&
- git clone --reference=A A B &&
- test_line_count = 1 B/.git/objects/info/alternates &&
- git clone --local --dissociate B C &&
- ! test -f C/.git/objects/info/alternates &&
- ( cd C && git fsck )
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='test local clone'
-. ./test-lib.sh
-
-repo_is_hardlinked() {
- find "$1/objects" -type f -links 1 >output &&
- test_line_count = 0 output
-}
-
-test_expect_success 'preparing origin repository' '
- : >file && git add . && git commit -m1 &&
- git clone --bare . a.git &&
- git clone --bare . x &&
- test "$(cd a.git && git config --bool core.bare)" = true &&
- test "$(cd x && git config --bool core.bare)" = true &&
- git bundle create b1.bundle --all &&
- git bundle create b2.bundle master &&
- mkdir dir &&
- cp b1.bundle dir/b3 &&
- cp b1.bundle b4
-'
-
-test_expect_success 'local clone without .git suffix' '
- git clone -l -s a b &&
- (cd b &&
- test "$(git config --bool core.bare)" = false &&
- git fetch)
-'
-
-test_expect_success 'local clone with .git suffix' '
- git clone -l -s a.git c &&
- (cd c && git fetch)
-'
-
-test_expect_success 'local clone from x' '
- git clone -l -s x y &&
- (cd y && git fetch)
-'
-
-test_expect_success 'local clone from x.git that does not exist' '
- test_must_fail git clone -l -s x.git z
-'
-
-test_expect_success 'With -no-hardlinks, local will make a copy' '
- git clone --bare --no-hardlinks x w &&
- ! repo_is_hardlinked w
-'
-
-test_expect_success 'Even without -l, local will make a hardlink' '
- rm -fr w &&
- git clone -l --bare x w &&
- repo_is_hardlinked w
-'
-
-test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
- echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
- git clone a d &&
- (cd d &&
- git fetch &&
- test ! -e .git/refs/remotes/origin/HEAD)
-'
-
-test_expect_success 'bundle clone without .bundle suffix' '
- git clone dir/b3 &&
- (cd b3 && git fetch)
-'
-
-test_expect_success 'bundle clone with .bundle suffix' '
- git clone b1.bundle &&
- (cd b1 && git fetch)
-'
-
-test_expect_success 'bundle clone from b4' '
- git clone b4 bdl &&
- (cd bdl && git fetch)
-'
-
-test_expect_success 'bundle clone from b4.bundle that does not exist' '
- test_must_fail git clone b4.bundle bb
-'
-
-test_expect_success 'bundle clone with nonexistent HEAD' '
- git clone b2.bundle b2 &&
- (cd b2 &&
- git fetch &&
- test_must_fail git rev-parse --verify refs/heads/master)
-'
-
-test_expect_success 'clone empty repository' '
- mkdir empty &&
- (cd empty &&
- git init &&
- git config receive.denyCurrentBranch warn) &&
- git clone empty empty-clone &&
- test_tick &&
- (cd empty-clone
- echo "content" >> foo &&
- git add foo &&
- git commit -m "Initial commit" &&
- git push origin master &&
- expected=$(git rev-parse master) &&
- actual=$(git --git-dir=../empty/.git rev-parse master) &&
- test $actual = $expected)
-'
-
-test_expect_success 'clone empty repository, and then push should not segfault.' '
- rm -fr empty/ empty-clone/ &&
- mkdir empty &&
- (cd empty && git init) &&
- git clone empty empty-clone &&
- (cd empty-clone &&
- test_must_fail git push)
-'
-
-test_expect_success 'cloning non-existent directory fails' '
- rm -rf does-not-exist &&
- test_must_fail git clone does-not-exist
-'
-
-test_expect_success 'cloning non-git directory fails' '
- rm -rf not-a-git-repo not-a-git-repo-clone &&
- mkdir not-a-git-repo &&
- test_must_fail git clone not-a-git-repo not-a-git-repo-clone
-'
-
-test_expect_success 'cloning file:// does not hardlink' '
- git clone --bare file://"$(pwd)"/a non-local &&
- ! repo_is_hardlinked non-local
-'
-
-test_expect_success 'cloning a local path with --no-local does not hardlink' '
- git clone --bare --no-local a force-nonlocal &&
- ! repo_is_hardlinked force-nonlocal
-'
-
-test_expect_success 'cloning locally respects "-u" for fetching refs' '
- test_must_fail git clone --bare -u false a should_not_work.git
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='basic clone options'
-. ./test-lib.sh
-
-test_expect_success 'setup' '
-
- mkdir parent &&
- (cd parent && git init &&
- echo one >file && git add file &&
- git commit -m one)
-
-'
-
-test_expect_success 'clone -o' '
-
- git clone -o foo parent clone-o &&
- (cd clone-o && git rev-parse --verify refs/remotes/foo/master)
-
-'
-
-test_expect_success 'redirected clone does not show progress' '
-
- git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
- ! grep % err &&
- test_i18ngrep ! "Checking connectivity" err
-
-'
-
-test_expect_success 'redirected clone -v does show progress' '
-
- git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
- >out 2>err &&
- grep % err
-
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='some bundle related tests'
-. ./test-lib.sh
-
-test_expect_success 'setup' '
- test_commit initial &&
- test_tick &&
- git tag -m tag tag &&
- test_commit second &&
- test_commit third &&
- git tag -d initial &&
- git tag -d second &&
- git tag -d third
-'
-
-test_expect_success 'annotated tags can be excluded by rev-list options' '
- git bundle create bundle --all --since=7.Apr.2005.15:14:00.-0700 &&
- git ls-remote bundle > output &&
- grep tag output &&
- git bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 &&
- git ls-remote bundle > output &&
- ! grep tag output
-'
-
-test_expect_success 'die if bundle file cannot be created' '
- mkdir adir &&
- test_must_fail git bundle create adir --all
-'
-
-test_expect_failure 'bundle --stdin' '
- echo master | git bundle create stdin-bundle.bdl --stdin &&
- git ls-remote stdin-bundle.bdl >output &&
- grep master output
-'
-
-test_expect_failure 'bundle --stdin <rev-list options>' '
- echo master | git bundle create hybrid-bundle.bdl --stdin tag &&
- git ls-remote hybrid-bundle.bdl >output &&
- grep master output
-'
-
-test_expect_success 'empty bundle file is rejected' '
- : >empty-bundle &&
- test_must_fail git fetch empty-bundle
-'
-
-# This triggers a bug in older versions where the resulting line (with
-# --pretty=oneline) was longer than a 1024-char buffer.
-test_expect_success 'ridiculously long subject in boundary' '
- : >file4 &&
- test_tick &&
- git add file4 &&
- printf "%01200d\n" 0 | git commit -F - &&
- test_commit fifth &&
- git bundle create long-subject-bundle.bdl HEAD^..HEAD &&
- git bundle list-heads long-subject-bundle.bdl >heads &&
- test -s heads &&
- git fetch long-subject-bundle.bdl &&
- sed -n "/^-/{p;q;}" long-subject-bundle.bdl >boundary &&
- grep "^-[0-9a-f]\\{40\\} " boundary
-'
-
-test_expect_success 'prerequisites with an empty commit message' '
- : >file1 &&
- git add file1 &&
- test_tick &&
- git commit --allow-empty-message -m "" &&
- test_commit file2 &&
- git bundle create bundle HEAD^.. &&
- git bundle verify bundle
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='Test cloning a repository larger than 2 gigabyte'
-. ./test-lib.sh
-
-if test -z "$GIT_TEST_CLONE_2GB"
-then
- say 'Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t'
-else
- test_set_prereq CLONE_2GB
-fi
-
-test_expect_success CLONE_2GB 'setup' '
-
- git config pack.compression 0 &&
- git config pack.depth 0 &&
- blobsize=$((100*1024*1024)) &&
- blobcount=$((2*1024*1024*1024/$blobsize+1)) &&
- i=1 &&
- (while test $i -le $blobcount
- do
- printf "Generating blob $i/$blobcount\r" >&2 &&
- printf "blob\nmark :$i\ndata $blobsize\n" &&
- #test-genrandom $i $blobsize &&
- printf "%-${blobsize}s" $i &&
- echo "M 100644 :$i $i" >> commit
- i=$(($i+1)) ||
- echo $? > exit-status
- done &&
- echo "commit refs/heads/master" &&
- echo "author A U Thor <author@email.com> 123456789 +0000" &&
- echo "committer C O Mitter <committer@email.com> 123456789 +0000" &&
- echo "data 5" &&
- echo ">2gb" &&
- cat commit) |
- git fast-import --big-file-threshold=2 &&
- test ! -f exit-status
-
-'
-
-test_expect_success CLONE_2GB 'clone - bare' '
-
- git clone --bare --no-hardlinks . clone-bare
-
-'
-
-test_expect_success CLONE_2GB 'clone - with worktree, file:// protocol' '
-
- git clone "file://$(pwd)" clone-wt
-
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='clone --branch option'
-. ./test-lib.sh
-
-check_HEAD() {
- echo refs/heads/"$1" >expect &&
- git symbolic-ref HEAD >actual &&
- test_cmp expect actual
-}
-
-check_file() {
- echo "$1" >expect &&
- test_cmp expect file
-}
-
-test_expect_success 'setup' '
- mkdir parent &&
- (cd parent && git init &&
- echo one >file && git add file && git commit -m one &&
- git checkout -b two &&
- echo two >file && git add file && git commit -m two &&
- git checkout master) &&
- mkdir empty &&
- (cd empty && git init)
-'
-
-test_expect_success 'vanilla clone chooses HEAD' '
- git clone parent clone &&
- (cd clone &&
- check_HEAD master &&
- check_file one
- )
-'
-
-test_expect_success 'clone -b chooses specified branch' '
- git clone -b two parent clone-two &&
- (cd clone-two &&
- check_HEAD two &&
- check_file two
- )
-'
-
-test_expect_success 'clone -b sets up tracking' '
- (cd clone-two &&
- echo origin >expect &&
- git config branch.two.remote >actual &&
- echo refs/heads/two >>expect &&
- git config branch.two.merge >>actual &&
- test_cmp expect actual
- )
-'
-
-test_expect_success 'clone -b does not munge remotes/origin/HEAD' '
- (cd clone-two &&
- echo refs/remotes/origin/master >expect &&
- git symbolic-ref refs/remotes/origin/HEAD >actual &&
- test_cmp expect actual
- )
-'
-
-test_expect_success 'clone -b with bogus branch' '
- test_must_fail git clone -b bogus parent clone-bogus
-'
-
-test_expect_success 'clone -b not allowed with empty repos' '
- test_must_fail git clone -b branch empty clone-branch-empty
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='test cloning a repository with detached HEAD'
-. ./test-lib.sh
-
-head_is_detached() {
- git --git-dir=$1/.git rev-parse --verify HEAD &&
- test_must_fail git --git-dir=$1/.git symbolic-ref HEAD
-}
-
-test_expect_success 'setup' '
- echo one >file &&
- git add file &&
- git commit -m one &&
- echo two >file &&
- git commit -a -m two &&
- git tag two &&
- echo three >file &&
- git commit -a -m three
-'
-
-test_expect_success 'clone repo (detached HEAD points to branch)' '
- git checkout master^0 &&
- git clone "file://$PWD" detached-branch
-'
-test_expect_success 'cloned HEAD matches' '
- echo three >expect &&
- git --git-dir=detached-branch/.git log -1 --format=%s >actual &&
- test_cmp expect actual
-'
-test_expect_failure 'cloned HEAD is detached' '
- head_is_detached detached-branch
-'
-
-test_expect_success 'clone repo (detached HEAD points to tag)' '
- git checkout two^0 &&
- git clone "file://$PWD" detached-tag
-'
-test_expect_success 'cloned HEAD matches' '
- echo two >expect &&
- git --git-dir=detached-tag/.git log -1 --format=%s >actual &&
- test_cmp expect actual
-'
-test_expect_success 'cloned HEAD is detached' '
- head_is_detached detached-tag
-'
-
-test_expect_success 'clone repo (detached HEAD points to history)' '
- git checkout two^ &&
- git clone "file://$PWD" detached-history
-'
-test_expect_success 'cloned HEAD matches' '
- echo one >expect &&
- git --git-dir=detached-history/.git log -1 --format=%s >actual &&
- test_cmp expect actual
-'
-test_expect_success 'cloned HEAD is detached' '
- head_is_detached detached-history
-'
-
-test_expect_success 'clone repo (orphan detached HEAD)' '
- git checkout master^0 &&
- echo four >file &&
- git commit -a -m four &&
- git clone "file://$PWD" detached-orphan
-'
-test_expect_success 'cloned HEAD matches' '
- echo four >expect &&
- git --git-dir=detached-orphan/.git log -1 --format=%s >actual &&
- test_cmp expect actual
-'
-test_expect_success 'cloned HEAD is detached' '
- head_is_detached detached-orphan
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='tests for git clone -c key=value'
-. ./test-lib.sh
-
-test_expect_success 'clone -c sets config in cloned repo' '
- rm -rf child &&
- git clone -c core.foo=bar . child &&
- echo bar >expect &&
- git --git-dir=child/.git config core.foo >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'clone -c can set multi-keys' '
- rm -rf child &&
- git clone -c core.foo=bar -c core.foo=baz . child &&
- { echo bar; echo baz; } >expect &&
- git --git-dir=child/.git config --get-all core.foo >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'clone -c without a value is boolean true' '
- rm -rf child &&
- git clone -c core.foo . child &&
- echo true >expect &&
- git --git-dir=child/.git config --bool core.foo >actual &&
- test_cmp expect actual
-'
-
-test_expect_success 'clone -c config is available during clone' '
- echo content >file &&
- git add file &&
- git commit -m one &&
- rm -rf child &&
- git clone -c core.autocrlf . child &&
- printf "content\\r\\n" >expect &&
- test_cmp expect child/file
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-
-test_description='test refspec written by clone-command'
-. ./test-lib.sh
-
-test_expect_success 'setup' '
- # Make two branches, "master" and "side"
- echo one >file &&
- git add file &&
- git commit -m one &&
- echo two >file &&
- git commit -a -m two &&
- git tag two &&
- echo three >file &&
- git commit -a -m three &&
- git checkout -b side &&
- echo four >file &&
- git commit -a -m four &&
- git checkout master &&
-
- # default clone
- git clone . dir_all &&
-
- # default --single that follows HEAD=master
- git clone --single-branch . dir_master &&
-
- # default --single that follows HEAD=side
- git checkout side &&
- git clone --single-branch . dir_side &&
-
- # explicit --single that follows side
- git checkout master &&
- git clone --single-branch --branch side . dir_side2 &&
-
- # default --single with --mirror
- git clone --single-branch --mirror . dir_mirror &&
-
- # default --single with --branch and --mirror
- git clone --single-branch --mirror --branch side . dir_mirror_side &&
-
- # --single that does not know what branch to follow
- git checkout two^ &&
- git clone --single-branch . dir_detached &&
-
- # explicit --single with tag
- git clone --single-branch --branch two . dir_tag &&
-
- # advance both "master" and "side" branches
- git checkout side &&
- echo five >file &&
- git commit -a -m five &&
- git checkout master &&
- echo six >file &&
- git commit -a -m six &&
-
- # update tag
- git tag -d two && git tag two
-'
-
-test_expect_success 'by default all branches will be kept updated' '
- (
- cd dir_all && git fetch &&
- git for-each-ref refs/remotes/origin |
- sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
- ) &&
- # follow both master and side
- git for-each-ref refs/heads >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'by default no tags will be kept updated' '
- (
- cd dir_all && git fetch &&
- git for-each-ref refs/tags >../actual
- ) &&
- git for-each-ref refs/tags >expect &&
- test_must_fail test_cmp expect actual
-'
-
-test_expect_success '--single-branch while HEAD pointing at master' '
- (
- cd dir_master && git fetch &&
- git for-each-ref refs/remotes/origin |
- sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
- ) &&
- # only follow master
- git for-each-ref refs/heads/master >expect &&
- test_cmp expect actual
-'
-
-test_expect_success '--single-branch while HEAD pointing at side' '
- (
- cd dir_side && git fetch &&
- git for-each-ref refs/remotes/origin |
- sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
- ) &&
- # only follow side
- git for-each-ref refs/heads/side >expect &&
- test_cmp expect actual
-'
-
-test_expect_success '--single-branch with explicit --branch side' '
- (
- cd dir_side2 && git fetch &&
- git for-each-ref refs/remotes/origin |
- sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
- ) &&
- # only follow side
- git for-each-ref refs/heads/side >expect &&
- test_cmp expect actual
-'
-
-test_expect_success '--single-branch with explicit --branch with tag fetches updated tag' '
- (
- cd dir_tag && git fetch &&
- git for-each-ref refs/tags >../actual
- ) &&
- git for-each-ref refs/tags >expect &&
- test_cmp expect actual
-'
-
-test_expect_success '--single-branch with --mirror' '
- (
- cd dir_mirror && git fetch &&
- git for-each-ref refs > ../actual
- ) &&
- git for-each-ref refs >expect &&
- test_cmp expect actual
-'
-
-test_expect_success '--single-branch with explicit --branch and --mirror' '
- (
- cd dir_mirror_side && git fetch &&
- git for-each-ref refs > ../actual
- ) &&
- git for-each-ref refs >expect &&
- test_cmp expect actual
-'
-
-test_expect_success '--single-branch with detached' '
- (
- cd dir_detached && git fetch &&
- git for-each-ref refs/remotes/origin |
- sed -e "/HEAD$/d" \
- -e "s|/remotes/origin/|/heads/|" >../actual
- ) &&
- # nothing
- >expect &&
- test_cmp expect actual
-'
-
-test_done
+++ /dev/null
-#!/bin/sh
-#
-# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
-#
-
-test_description='test transitive info/alternate entries'
-. ./test-lib.sh
-
-# test that a file is not reachable in the current repository
-# but that it is after creating a info/alternate entry
-reachable_via() {
- alternate="$1"
- file="$2"
- if git cat-file -e "HEAD:$file"; then return 1; fi
- echo "$alternate" >> .git/objects/info/alternate
- git cat-file -e "HEAD:$file"
-}
-
-test_valid_repo() {
- git fsck --full > fsck.log &&
- test_line_count = 0 fsck.log
-}
-
-base_dir=`pwd`
-
-test_expect_success 'preparing first repository' \
-'test_create_repo A && cd A &&
-echo "Hello World" > file1 &&
-git add file1 &&
-git commit -m "Initial commit" file1 &&
-git repack -a -d &&
-git prune'
-
-cd "$base_dir"
-
-test_expect_success 'preparing second repository' \
-'git clone -l -s A B && cd B &&
-echo "foo bar" > file2 &&
-git add file2 &&
-git commit -m "next commit" file2 &&
-git repack -a -d -l &&
-git prune'
-
-cd "$base_dir"
-
-test_expect_success 'preparing third repository' \
-'git clone -l -s B C && cd C &&
-echo "Goodbye, cruel world" > file3 &&
-git add file3 &&
-git commit -m "one more" file3 &&
-git repack -a -d -l &&
-git prune'
-
-cd "$base_dir"
-
-test_expect_success 'creating too deep nesting' \
-'git clone -l -s C D &&
-git clone -l -s D E &&
-git clone -l -s E F &&
-git clone -l -s F G &&
-git clone --bare -l -s G H'
-
-test_expect_success 'invalidity of deepest repository' \
-'cd H && {
- test_valid_repo
- test $? -ne 0
-}'
-
-cd "$base_dir"
-
-test_expect_success 'validity of third repository' \
-'cd C &&
-test_valid_repo'
-
-cd "$base_dir"
-
-test_expect_success 'validity of fourth repository' \
-'cd D &&
-test_valid_repo'
-
-cd "$base_dir"
-
-test_expect_success 'breaking of loops' \
-'echo "$base_dir"/B/.git/objects >> "$base_dir"/A/.git/objects/info/alternates&&
-cd C &&
-test_valid_repo'
-
-cd "$base_dir"
-
-test_expect_success 'that info/alternates is necessary' \
-'cd C &&
-rm -f .git/objects/info/alternates &&
-! (test_valid_repo)'
-
-cd "$base_dir"
-
-test_expect_success 'that relative alternate is possible for current dir' \
-'cd C &&
-echo "../../../B/.git/objects" > .git/objects/info/alternates &&
-test_valid_repo'
-
-cd "$base_dir"
-
-test_expect_success \
- 'that relative alternate is only possible for current dir' '
- cd D &&
- ! (test_valid_repo)
-'
-
-cd "$base_dir"
-
-test_done