t / t7701-repack-unpack-unreachable.shon commit Ignore .gitattributes in bare repositories (2d35d55)
   1#!/bin/sh
   2
   3test_description='git-repack works correctly'
   4
   5. ./test-lib.sh
   6
   7test_expect_success '-A option leaves unreachable objects unpacked' '
   8        echo content > file1 &&
   9        git add . &&
  10        git commit -m initial_commit &&
  11        # create a transient branch with unique content
  12        git checkout -b transient_branch &&
  13        echo more content >> file1 &&
  14        # record the objects created in the database for file, commit, tree
  15        fsha1=$(git hash-object file1) &&
  16        git commit -a -m more_content &&
  17        csha1=$(git rev-parse HEAD^{commit}) &&
  18        tsha1=$(git rev-parse HEAD^{tree}) &&
  19        git checkout master &&
  20        echo even more content >> file1 &&
  21        git commit -a -m even_more_content &&
  22        # delete the transient branch
  23        git branch -D transient_branch &&
  24        # pack the repo
  25        git repack -A -d -l &&
  26        # verify objects are packed in repository
  27        test 3 = $(git verify-pack -v -- .git/objects/pack/*.idx |
  28                   grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
  29                   sort | uniq | wc -l) &&
  30        git show $fsha1 &&
  31        git show $csha1 &&
  32        git show $tsha1 &&
  33        # now expire the reflog
  34        sleep 1 &&
  35        git reflog expire --expire-unreachable=now --all &&
  36        # and repack
  37        git repack -A -d -l &&
  38        # verify objects are retained unpacked
  39        test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
  40                   grep -e "^$fsha1 " -e "^$csha1 " -e "^$tsha1 " |
  41                   sort | uniq | wc -l) &&
  42        git show $fsha1 &&
  43        git show $csha1 &&
  44        git show $tsha1
  45'
  46
  47test_done