t / t5701-clone-local.shon commit git-clone: aggressively optimize local clone behaviour. (3d5c418)
   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'
  13
  14test_expect_success 'local clone without .git suffix' '
  15        cd "$D" &&
  16        git clone -l -s a b &&
  17        cd b &&
  18        git fetch
  19'
  20
  21test_expect_success 'local clone with .git suffix' '
  22        cd "$D" &&
  23        git clone -l -s a.git c &&
  24        cd c &&
  25        git fetch
  26'
  27
  28test_expect_success 'local clone from x' '
  29        cd "$D" &&
  30        git clone -l -s x y &&
  31        cd y &&
  32        git fetch
  33'
  34
  35test_expect_success 'local clone from x.git that does not exist' '
  36        cd "$D" &&
  37        if git clone -l -s x.git z
  38        then
  39                echo "Oops, should have failed"
  40                false
  41        else
  42                echo happy
  43        fi
  44'
  45
  46test_expect_success 'With -no-hardlinks, local will make a copy' '
  47        cd "$D" &&
  48        git clone --bare --no-hardlinks x w &&
  49        cd w &&
  50        linked=$(find objects -type f ! -links 1 | wc -l) &&
  51        test "$linked" = 0
  52'
  53
  54test_expect_success 'Even without -l, local will make a hardlink' '
  55        cd "$D" &&
  56        rm -fr w &&
  57        git clone -l --bare x w &&
  58        cd w &&
  59        copied=$(find objects -type f -links 1 | wc -l) &&
  60        test "$copied" = 0
  61'
  62
  63test_done