1#!/bin/sh
   2#
   3# Copyright (C) 2006 Martin Waitz <tali@admingilde.org>
   4#
   5test_description='test clone --reference'
   7. ./test-lib.sh
   8base_dir=`pwd`
  10test_expect_success 'preparing first repository' \
  12'test_create_repo A && cd A &&
  13echo first > file1 &&
  14git add file1 &&
  15git commit -m initial'
  16cd "$base_dir"
  18test_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'
  26cd "$base_dir"
  28test_expect_success 'cloning with reference' \
  30'git clone -l -s --reference B A C'
  31cd "$base_dir"
  33test_expect_success 'existence of info/alternates' \
  35'test `wc -l <C/.git/objects/info/alternates` = 2'
  36cd "$base_dir"
  38test_expect_success 'pulling from reference' \
  40'cd C &&
  41git pull ../B'
  42cd "$base_dir"
  44test_expect_success 'that reference gets used' \
  46'cd C &&
  47echo "0 objects, 0 kilobytes" > expected &&
  48git count-objects > current &&
  49diff expected current'
  50cd "$base_dir"
  52test_expect_success 'updating origin' \
  54'cd A &&
  55echo third > file3 &&
  56git add file3 &&
  57git commit -m update &&
  58git repack -a -d &&
  59git prune'
  60cd "$base_dir"
  62test_expect_success 'pulling changes from origin' \
  64'cd C &&
  65git pull origin'
  66cd "$base_dir"
  68# 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'
  75cd "$base_dir"
  77test_done