t / t5701-clone-local.shon commit Merge branch 'mw/sendemail' (d5c5274)
   1#!/bin/sh
   2
   3test_description='test local clone'
   4. ./test-lib.sh
   5
   6D=`pwd`
   7
   8test_expect_success 'preparing origin repository' '
   9        : >file && git add . && git commit -m1 &&
  10        git clone --bare . a.git &&
  11        git clone --bare . x &&
  12        test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
  13        test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true
  14        git bundle create b1.bundle --all HEAD &&
  15        git bundle create b2.bundle --all &&
  16        mkdir dir &&
  17        cp b1.bundle dir/b3
  18        cp b1.bundle b4
  19'
  20
  21test_expect_success 'local clone without .git suffix' '
  22        cd "$D" &&
  23        git clone -l -s a b &&
  24        cd b &&
  25        test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false &&
  26        git fetch
  27'
  28
  29test_expect_success 'local clone with .git suffix' '
  30        cd "$D" &&
  31        git clone -l -s a.git c &&
  32        cd c &&
  33        git fetch
  34'
  35
  36test_expect_success 'local clone from x' '
  37        cd "$D" &&
  38        git clone -l -s x y &&
  39        cd y &&
  40        git fetch
  41'
  42
  43test_expect_success 'local clone from x.git that does not exist' '
  44        cd "$D" &&
  45        if git clone -l -s x.git z
  46        then
  47                echo "Oops, should have failed"
  48                false
  49        else
  50                echo happy
  51        fi
  52'
  53
  54test_expect_success 'With -no-hardlinks, local will make a copy' '
  55        cd "$D" &&
  56        git clone --bare --no-hardlinks x w &&
  57        cd w &&
  58        linked=$(find objects -type f ! -links 1 | wc -l) &&
  59        test 0 = $linked
  60'
  61
  62test_expect_success 'Even without -l, local will make a hardlink' '
  63        cd "$D" &&
  64        rm -fr w &&
  65        git clone -l --bare x w &&
  66        cd w &&
  67        copied=$(find objects -type f -links 1 | wc -l) &&
  68        test 0 = $copied
  69'
  70
  71test_expect_success 'local clone of repo with nonexistent ref in HEAD' '
  72        cd "$D" &&
  73        echo "ref: refs/heads/nonexistent" > a.git/HEAD &&
  74        git clone a d &&
  75        cd d &&
  76        git fetch &&
  77        test ! -e .git/refs/remotes/origin/HEAD'
  78
  79test_expect_success 'bundle clone without .bundle suffix' '
  80        cd "$D" &&
  81        git clone dir/b3 &&
  82        cd b3 &&
  83        git fetch
  84'
  85
  86test_expect_success 'bundle clone with .bundle suffix' '
  87        cd "$D" &&
  88        git clone b1.bundle &&
  89        cd b1 &&
  90        git fetch
  91'
  92
  93test_expect_success 'bundle clone from b4' '
  94        cd "$D" &&
  95        git clone b4 bdl &&
  96        cd bdl &&
  97        git fetch
  98'
  99
 100test_expect_success 'bundle clone from b4.bundle that does not exist' '
 101        cd "$D" &&
 102        if git clone b4.bundle bb
 103        then
 104                echo "Oops, should have failed"
 105                false
 106        else
 107                echo happy
 108        fi
 109'
 110
 111test_expect_success 'bundle clone with nonexistent HEAD' '
 112        cd "$D" &&
 113        git clone b2.bundle b2 &&
 114        cd b2 &&
 115        git fetch
 116        test ! -e .git/refs/heads/master
 117'
 118
 119test_done