t / t1013-loose-object-format.shon commit t3200.39: tracking setup should fail if there is no matching refspec. (9c9cd39)
   1#!/bin/sh
   2#
   3# Copyright (c) 2011 Roberto Tyley
   4#
   5
   6test_description='Correctly identify and parse loose object headers
   7
   8There are two file formats for loose objects - the original standard
   9format, and the experimental format introduced with Git v1.4.3, later
  10deprecated with v1.5.3. Although Git no longer writes the
  11experimental format, objects in both formats must be read, with the
  12format for a given file being determined by the header.
  13
  14Detecting file format based on header is not entirely trivial, not
  15least because the first byte of a zlib-deflated stream will vary
  16depending on how much memory was allocated for the deflation window
  17buffer when the object was written out (for example 4KB on Android,
  18rather that 32KB on a normal PC).
  19
  20The loose objects used as test vectors have been generated with the
  21following Git versions:
  22
  23standard format: Git v1.7.4.1
  24experimental format: Git v1.4.3 (legacyheaders=false)
  25standard format, deflated with 4KB window size: Agit/JGit on Android
  26'
  27
  28. ./test-lib.sh
  29
  30assert_blob_equals() {
  31        printf "%s" "$2" >expected &&
  32        git cat-file -p "$1" >actual &&
  33        test_cmp expected actual
  34}
  35
  36test_expect_success setup '
  37        cp -R "$TEST_DIRECTORY/t1013/objects" .git/ &&
  38        git --version
  39'
  40
  41test_expect_success 'read standard-format loose objects' '
  42        git cat-file tag 8d4e360d6c70fbd72411991c02a09c442cf7a9fa &&
  43        git cat-file commit 6baee0540ea990d9761a3eb9ab183003a71c3696 &&
  44        git ls-tree 7a37b887a73791d12d26c0d3e39568a8fb0fa6e8 &&
  45        assert_blob_equals "257cc5642cb1a054f08cc83f2d943e56fd3ebe99" "foo$LF"
  46'
  47
  48test_expect_success 'read experimental-format loose objects' '
  49        git cat-file tag 76e7fa9941f4d5f97f64fea65a2cba436bc79cbb &&
  50        git cat-file commit 7875c6237d3fcdd0ac2f0decc7d3fa6a50b66c09 &&
  51        git ls-tree 95b1625de3ba8b2214d1e0d0591138aea733f64f &&
  52        assert_blob_equals "2e65efe2a145dda7ee51d1741299f848e5bf752e" "a" &&
  53        assert_blob_equals "9ae9e86b7bd6cb1472d9373702d8249973da0832" "ab" &&
  54        assert_blob_equals "85df50785d62d3b05ab03d9cbf7e4a0b49449730" "abcd" &&
  55        assert_blob_equals "1656f9233d999f61ef23ef390b9c71d75399f435" "abcdefgh" &&
  56        assert_blob_equals "1e72a6b2c4a577ab0338860fa9fe87f761fc9bbd" "abcdefghi" &&
  57        assert_blob_equals "70e6a83d8dcb26fc8bc0cf702e2ddeb6adca18fd" "abcdefghijklmnop" &&
  58        assert_blob_equals "bd15045f6ce8ff75747562173640456a394412c8" "abcdefghijklmnopqrstuvwx"
  59'
  60
  61test_expect_success 'read standard-format objects deflated with smaller window buffer' '
  62        git cat-file tag f816d5255855ac160652ee5253b06cd8ee14165a &&
  63        git cat-file tag 149cedb5c46929d18e0f118e9fa31927487af3b6
  64'
  65
  66test_done