3 test_description='.git file
5 Verify that plumbing commands work when .git is a file
10 echo "$1" | sed -e 's|\(..\)|\1/|'
15 if test ! -f "$REAL/objects/$p"
17 echo "Object not found: $REAL/objects/$p"
23 test_expect_success 'initial setup' '
24 REAL="$(pwd)/.real" &&
28 test_expect_success 'bad setup: invalid .git file format' '
29 echo "gitdir $REAL" >.git &&
30 if git rev-parse 2>.err
32 echo "git rev-parse accepted an invalid .git file"
35 if ! grep "Invalid gitfile format" .err
37 echo "git rev-parse returned wrong error"
42 test_expect_success 'bad setup: invalid .git file path' '
43 echo "gitdir: $REAL.not" >.git &&
44 if git rev-parse 2>.err
46 echo "git rev-parse accepted an invalid .git file path"
49 if ! grep "Not a git repository" .err
51 echo "git rev-parse returned wrong error"
56 test_expect_success 'final setup + check rev-parse --git-dir' '
57 echo "gitdir: $REAL" >.git &&
58 test "$REAL" = "$(git rev-parse --git-dir)"
61 test_expect_success 'check hash-object' '
63 SHA=$(cat bar | git hash-object -w --stdin) &&
67 test_expect_success 'check cat-file' '
68 git cat-file blob $SHA >actual &&
72 test_expect_success 'check update-index' '
73 if test -f "$REAL/index"
75 echo "Hmm, $REAL/index exists?"
78 rm -f "$REAL/objects/$(objpath $SHA)" &&
79 git update-index --add bar &&
80 if ! test -f "$REAL/index"
82 echo "$REAL/index not found"
88 test_expect_success 'check write-tree' '
89 SHA=$(git write-tree) &&
93 test_expect_success 'check commit-tree' '
94 SHA=$(echo "commit bar" | git commit-tree $SHA) &&
98 test_expect_success 'check rev-list' '
99 echo $SHA >"$REAL/HEAD" &&
100 test "$SHA" = "$(git rev-list HEAD)"