t / t5700-clone-reference.shon commit clone: the given repository dir should be relative to $PWD (ced78b3)
   1#!/bin/sh
   2#
   3# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
   4#
   5
   6test_description='test clone --reference'
   7. ./test-lib.sh
   8
   9base_dir=`pwd`
  10
  11test_expect_success 'preparing first repository' \
  12'test_create_repo A && cd A &&
  13echo first > file1 &&
  14git add file1 &&
  15git commit -m initial'
  16
  17cd "$base_dir"
  18
  19test_expect_success 'preparing second repository' \
  20'git clone A B && cd B &&
  21echo second > file2 &&
  22git add file2 &&
  23git commit -m addition &&
  24git repack -a -d &&
  25git prune'
  26
  27cd "$base_dir"
  28
  29test_expect_success 'cloning with reference' \
  30'git clone -l -s --reference B A C'
  31
  32cd "$base_dir"
  33
  34test_expect_success 'existence of info/alternates' \
  35'test `wc -l <C/.git/objects/info/alternates` = 2'
  36
  37cd "$base_dir"
  38
  39test_expect_success 'pulling from reference' \
  40'cd C &&
  41git pull ../B'
  42
  43cd "$base_dir"
  44
  45test_expect_success 'that reference gets used' \
  46'cd C &&
  47echo "0 objects, 0 kilobytes" > expected &&
  48git count-objects > current &&
  49diff expected current'
  50
  51cd "$base_dir"
  52
  53test_expect_success 'updating origin' \
  54'cd A &&
  55echo third > file3 &&
  56git add file3 &&
  57git commit -m update &&
  58git repack -a -d &&
  59git prune'
  60
  61cd "$base_dir"
  62
  63test_expect_success 'pulling changes from origin' \
  64'cd C &&
  65git pull origin'
  66
  67cd "$base_dir"
  68
  69# the 2 local objects are commit and tree from the merge
  70test_expect_success 'that alternate to origin gets used' \
  71'cd C &&
  72echo "2 objects" > expected &&
  73git count-objects | cut -d, -f1 > current &&
  74diff expected current'
  75
  76cd "$base_dir"
  77
  78test_done