t / t5309-pack-delta-cycles.shon commit remote: add a macro for "refs/tags/*:refs/tags/*" (750d0da)
   1#!/bin/sh
   2
   3test_description='test index-pack handling of delta cycles in packfiles'
   4. ./test-lib.sh
   5. "$TEST_DIRECTORY"/lib-pack.sh
   6
   7# Two similar-ish objects that we have computed deltas between.
   8A=01d7713666f4de822776c7622c10f1b07de280dc
   9B=e68fe8129b546b101aee9510c5328e7f21ca1d18
  10
  11# double-check our hand-constucted packs
  12test_expect_success 'index-pack works with a single delta (A->B)' '
  13        clear_packs &&
  14        {
  15                pack_header 2 &&
  16                pack_obj $A $B &&
  17                pack_obj $B
  18        } >ab.pack &&
  19        pack_trailer ab.pack &&
  20        git index-pack --stdin <ab.pack &&
  21        git cat-file -t $A &&
  22        git cat-file -t $B
  23'
  24
  25test_expect_success 'index-pack works with a single delta (B->A)' '
  26        clear_packs &&
  27        {
  28                pack_header 2 &&
  29                pack_obj $A &&
  30                pack_obj $B $A
  31        } >ba.pack &&
  32        pack_trailer ba.pack &&
  33        git index-pack --stdin <ba.pack &&
  34        git cat-file -t $A &&
  35        git cat-file -t $B
  36'
  37
  38test_expect_success 'index-pack detects missing base objects' '
  39        clear_packs &&
  40        {
  41                pack_header 1 &&
  42                pack_obj $A $B
  43        } >missing.pack &&
  44        pack_trailer missing.pack &&
  45        test_must_fail git index-pack --fix-thin --stdin <missing.pack
  46'
  47
  48test_expect_success 'index-pack detects REF_DELTA cycles' '
  49        clear_packs &&
  50        {
  51                pack_header 2 &&
  52                pack_obj $A $B &&
  53                pack_obj $B $A
  54        } >cycle.pack &&
  55        pack_trailer cycle.pack &&
  56        test_must_fail git index-pack --fix-thin --stdin <cycle.pack
  57'
  58
  59test_expect_failure 'failover to an object in another pack' '
  60        clear_packs &&
  61        git index-pack --stdin <ab.pack &&
  62        git index-pack --stdin --fix-thin <cycle.pack
  63'
  64
  65test_expect_failure 'failover to a duplicate object in the same pack' '
  66        clear_packs &&
  67        {
  68                pack_header 3 &&
  69                pack_obj $A $B &&
  70                pack_obj $B $A &&
  71                pack_obj $A
  72        } >recoverable.pack &&
  73        pack_trailer recoverable.pack &&
  74        git index-pack --fix-thin --stdin <recoverable.pack
  75'
  76
  77test_done