Ignore:
Timestamp:
Jun 23, 2014, 9:45:51 PM (11 years ago)
Author:
dmik
Message:

git: Merge version 2.0.0 from vendor to dmik branch.

Location:
git/branches/dmik
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • git/branches/dmik

  • TabularUnified git/branches/dmik/t/t5601-clone.sh

    r626 r782  
    1010        test_create_repo src &&
    1111        (
    12                 cd src
    13                 >file
    14                 git add file
    15                 git commit -m initial
     12                cd src &&
     13                >file &&
     14                git add file &&
     15                git commit -m initial &&
     16                echo 1 >file &&
     17                git add file &&
     18                git commit -m updated
    1619        )
    1720
     
    3437test_expect_success C_LOCALE_OUTPUT 'output from clone' '
    3538        rm -fr dst &&
    36         git clone -n "file://$(pwd)/src" dst >output &&
     39        git clone -n "file://$(pwd)/src" dst >output 2>&1 &&
    3740        test $(grep Clon output | wc -l) = 1
    3841'
     
    8689        MIRROR="$(cd mirror && git config --bool remote.origin.mirror)" &&
    8790        test "$MIRROR" = true
     91
     92'
     93
     94test_expect_success 'clone --mirror with detached HEAD' '
     95
     96        ( cd src && git checkout HEAD^ && git rev-parse HEAD >../expected ) &&
     97        git clone --mirror src mirror.detached &&
     98        ( cd src && git checkout - ) &&
     99        GIT_DIR=mirror.detached git rev-parse HEAD >actual &&
     100        test_cmp expected actual
     101
     102'
     103
     104test_expect_success 'clone --bare with detached HEAD' '
     105
     106        ( cd src && git checkout HEAD^ && git rev-parse HEAD >../expected ) &&
     107        git clone --bare src bare.detached &&
     108        ( cd src && git checkout - ) &&
     109        GIT_DIR=bare.detached git rev-parse HEAD >actual &&
     110        test_cmp expected actual
    88111
    89112'
     
    249272'
    250273
     274test_expect_success 'clone checking out a tag' '
     275        git clone --branch=some-tag src dst.tag &&
     276        GIT_DIR=src/.git git rev-parse some-tag >expected &&
     277        test_cmp expected dst.tag/.git/HEAD &&
     278        GIT_DIR=dst.tag/.git git config remote.origin.fetch >fetch.actual &&
     279        echo "+refs/heads/*:refs/remotes/origin/*" >fetch.expected &&
     280        test_cmp fetch.expected fetch.actual
     281'
     282
     283setup_ssh_wrapper () {
     284        test_expect_success 'setup ssh wrapper' '
     285                write_script "$TRASH_DIRECTORY/ssh-wrapper" <<-\EOF &&
     286                echo >>"$TRASH_DIRECTORY/ssh-output" "ssh: $*" &&
     287                # throw away all but the last argument, which should be the
     288                # command
     289                while test $# -gt 1; do shift; done
     290                eval "$1"
     291                EOF
     292                GIT_SSH="$TRASH_DIRECTORY/ssh-wrapper" &&
     293                export GIT_SSH &&
     294                export TRASH_DIRECTORY &&
     295                >"$TRASH_DIRECTORY"/ssh-output
     296        '
     297}
     298
     299expect_ssh () {
     300        test_when_finished '
     301                (cd "$TRASH_DIRECTORY" && rm -f ssh-expect && >ssh-output)
     302        ' &&
     303        {
     304                case "$1" in
     305                none)
     306                        ;;
     307                *)
     308                        echo "ssh: $1 git-upload-pack '$2'"
     309                esac
     310        } >"$TRASH_DIRECTORY/ssh-expect" &&
     311        (cd "$TRASH_DIRECTORY" && test_cmp ssh-expect ssh-output)
     312}
     313
     314setup_ssh_wrapper
     315
     316test_expect_success 'clone myhost:src uses ssh' '
     317        git clone myhost:src ssh-clone &&
     318        expect_ssh myhost src
     319'
     320
     321test_expect_success NOT_MINGW,NOT_CYGWIN 'clone local path foo:bar' '
     322        cp -R src "foo:bar" &&
     323        git clone "foo:bar" foobar &&
     324        expect_ssh none
     325'
     326
     327test_expect_success 'bracketed hostnames are still ssh' '
     328        git clone "[myhost:123]:src" ssh-bracket-clone &&
     329        expect_ssh myhost:123 src
     330'
     331
     332counter=0
     333# $1 url
     334# $2 none|host
     335# $3 path
     336test_clone_url () {
     337        counter=$(($counter + 1))
     338        test_might_fail git clone "$1" tmp$counter &&
     339        expect_ssh "$2" "$3"
     340}
     341
     342test_expect_success NOT_MINGW 'clone c:temp is ssl' '
     343        test_clone_url c:temp c temp
     344'
     345
     346test_expect_success MINGW 'clone c:temp is dos drive' '
     347        test_clone_url c:temp none
     348'
     349
     350#ip v4
     351for repo in rep rep/home/project 123
     352do
     353        test_expect_success "clone host:$repo" '
     354                test_clone_url host:$repo host $repo
     355        '
     356done
     357
     358#ipv6
     359for repo in rep rep/home/project 123
     360do
     361        test_expect_success "clone [::1]:$repo" '
     362                test_clone_url [::1]:$repo ::1 $repo
     363        '
     364done
     365#home directory
     366test_expect_success "clone host:/~repo" '
     367        test_clone_url host:/~repo host "~repo"
     368'
     369
     370test_expect_success "clone [::1]:/~repo" '
     371        test_clone_url [::1]:/~repo ::1 "~repo"
     372'
     373
     374# Corner cases
     375for url in foo/bar:baz [foo]bar/baz:qux [foo/bar]:baz
     376do
     377        test_expect_success "clone $url is not ssh" '
     378                test_clone_url $url none
     379        '
     380done
     381
     382#with ssh:// scheme
     383test_expect_success 'clone ssh://host.xz/home/user/repo' '
     384        test_clone_url "ssh://host.xz/home/user/repo" host.xz "/home/user/repo"
     385'
     386
     387# from home directory
     388test_expect_success 'clone ssh://host.xz/~repo' '
     389        test_clone_url "ssh://host.xz/~repo" host.xz "~repo"
     390'
     391
     392# with port number
     393test_expect_success 'clone ssh://host.xz:22/home/user/repo' '
     394        test_clone_url "ssh://host.xz:22/home/user/repo" "-p 22 host.xz" "/home/user/repo"
     395'
     396
     397# from home directory with port number
     398test_expect_success 'clone ssh://host.xz:22/~repo' '
     399        test_clone_url "ssh://host.xz:22/~repo" "-p 22 host.xz" "~repo"
     400'
     401
     402#IPv6
     403test_expect_success 'clone ssh://[::1]/home/user/repo' '
     404        test_clone_url "ssh://[::1]/home/user/repo" "::1" "/home/user/repo"
     405'
     406
     407#IPv6 from home directory
     408test_expect_success 'clone ssh://[::1]/~repo' '
     409        test_clone_url "ssh://[::1]/~repo" "::1" "~repo"
     410'
     411
     412#IPv6 with port number
     413test_expect_success 'clone ssh://[::1]:22/home/user/repo' '
     414        test_clone_url "ssh://[::1]:22/home/user/repo" "-p 22 ::1" "/home/user/repo"
     415'
     416
     417#IPv6 from home directory with port number
     418test_expect_success 'clone ssh://[::1]:22/~repo' '
     419        test_clone_url "ssh://[::1]:22/~repo" "-p 22 ::1" "~repo"
     420'
     421
     422test_expect_success 'clone from a repository with two identical branches' '
     423
     424        (
     425                cd src &&
     426                git checkout -b another master
     427        ) &&
     428        git clone src target-11 &&
     429        test "z$( cd target-11 && git symbolic-ref HEAD )" = zrefs/heads/another
     430
     431'
     432
     433test_expect_success 'shallow clone locally' '
     434        git clone --depth=1 --no-local src ssrrcc &&
     435        git clone ssrrcc ddsstt &&
     436        test_cmp ssrrcc/.git/shallow ddsstt/.git/shallow &&
     437        ( cd ddsstt && git fsck )
     438'
     439
    251440test_done
Note: See TracChangeset for help on using the changeset viewer.