t / t5306-pack-nobase.shon commit Merge branch 'jc/doc-merge-options' into maint (bb8cbe7)
   1#!/bin/sh
   2#
   3# Copyright (c) 2008 Google Inc.
   4#
   5
   6test_description='git-pack-object with missing base
   7
   8'
   9. ./test-lib.sh
  10
  11# Create A-B chain
  12#
  13test_expect_success \
  14    'setup base' \
  15    'for a in a b c d e f g h i; do echo $a >>text; done &&
  16     echo side >side &&
  17     git update-index --add text side &&
  18     A=$(echo A | git commit-tree $(git write-tree)) &&
  19
  20     echo m >>text &&
  21     git update-index text &&
  22     B=$(echo B | git commit-tree $(git write-tree) -p $A) &&
  23     git update-ref HEAD $B
  24    '
  25
  26# Create repository with C whose parent is B.
  27# Repository contains C, C^{tree}, C:text, B, B^{tree}.
  28# Repository is missing B:text (best delta base for C:text).
  29# Repository is missing A (parent of B).
  30# Repository is missing A:side.
  31#
  32test_expect_success \
  33    'setup patch_clone' \
  34    'base_objects=$(pwd)/.git/objects &&
  35     (mkdir patch_clone &&
  36      cd patch_clone &&
  37      git init &&
  38      echo "$base_objects" >.git/objects/info/alternates &&
  39      echo q >>text &&
  40      git read-tree $B &&
  41      git update-index text &&
  42      git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) &&
  43      rm .git/objects/info/alternates &&
  44
  45      git --git-dir=../.git cat-file commit $B |
  46      git hash-object -t commit -w --stdin &&
  47
  48      git --git-dir=../.git cat-file tree "$B^{tree}" |
  49      git hash-object -t tree -w --stdin
  50     ) &&
  51     C=$(git --git-dir=patch_clone/.git rev-parse HEAD)
  52    '
  53
  54# Clone patch_clone indirectly by cloning base and fetching.
  55#
  56test_expect_success \
  57    'indirectly clone patch_clone' \
  58    '(mkdir user_clone &&
  59      cd user_clone &&
  60      git init &&
  61      git pull ../.git &&
  62      test $(git rev-parse HEAD) = $B &&
  63
  64      git pull ../patch_clone/.git &&
  65      test $(git rev-parse HEAD) = $C
  66     )
  67    '
  68
  69# Cloning the patch_clone directly should fail.
  70#
  71test_expect_success \
  72    'clone of patch_clone is incomplete' \
  73    '(mkdir user_direct &&
  74      cd user_direct &&
  75      git init &&
  76      test_must_fail git fetch ../patch_clone/.git
  77     )
  78    '
  79
  80test_done