1#!/bin/sh
   2#
   3# Copyright (c) 2009, Red Hat Inc, Author: Michael S. Tsirkin (mst@redhat.com)
   4#
   5test_description='test clone --reference'
   7. ./test-lib.sh
   8base_dir=`pwd`
  10U=$base_dir/UPLOAD_LOG
  12test_expect_success 'preparing first repository' \
  14'test_create_repo A && cd A &&
  15echo first > file1 &&
  16git add file1 &&
  17git commit -m A-initial'
  18cd "$base_dir"
  20test_expect_success 'preparing second repository' \
  22'git clone A B && cd B &&
  23echo second > file2 &&
  24git add file2 &&
  25git commit -m B-addition &&
  26git repack -a -d &&
  27git prune'
  28cd "$base_dir"
  30test_expect_success 'preparing superproject' \
  32'test_create_repo super && cd super &&
  33echo file > file &&
  34git add file &&
  35git commit -m B-super-initial'
  36cd "$base_dir"
  38test_expect_success 'submodule add --reference' \
  40'cd super && git submodule add --reference ../B "file://$base_dir/A" sub &&
  41git commit -m B-super-added'
  42cd "$base_dir"
  44test_expect_success 'after add: existence of info/alternates' \
  46'test_line_count = 1 super/.git/modules/sub/objects/info/alternates'
  47cd "$base_dir"
  49test_expect_success 'that reference gets used with add' \
  51'cd super/sub &&
  52echo "0 objects, 0 kilobytes" > expected &&
  53git count-objects > current &&
  54diff expected current'
  55cd "$base_dir"
  57test_expect_success 'cloning superproject' \
  59'git clone super super-clone'
  60cd "$base_dir"
  62test_expect_success 'update with reference' \
  64'cd super-clone && git submodule update --init --reference ../B'
  65cd "$base_dir"
  67test_expect_success 'after update: existence of info/alternates' \
  69'test_line_count = 1 super-clone/.git/modules/sub/objects/info/alternates'
  70cd "$base_dir"
  72test_expect_success 'that reference gets used with update' \
  74'cd super-clone/sub &&
  75echo "0 objects, 0 kilobytes" > expected &&
  76git count-objects > current &&
  77diff expected current'
  78cd "$base_dir"
  80test_done