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"
22 test_expect_success 'initial setup' '
23 REAL="$(pwd)/.real" &&
27 test_expect_success 'bad setup: invalid .git file format' '
28 echo "gitdir $REAL" >.git &&
29 if git rev-parse 2>.err
31 echo "git rev-parse accepted an invalid .git file"
34 if ! grep "Invalid gitfile format" .err
36 echo "git rev-parse returned wrong error"
41 test_expect_success 'bad setup: invalid .git file path' '
42 echo "gitdir: $REAL.not" >.git &&
43 if git rev-parse 2>.err
45 echo "git rev-parse accepted an invalid .git file path"
48 if ! grep "Not a git repository" .err
50 echo "git rev-parse returned wrong error"
55 test_expect_success 'final setup + check rev-parse --git-dir' '
56 echo "gitdir: $REAL" >.git &&
57 test "$REAL" = "$(git rev-parse --git-dir)"
60 test_expect_success 'check hash-object' '
62 SHA=$(cat bar | git hash-object -w --stdin) &&
66 test_expect_success 'check cat-file' '
67 git cat-file blob $SHA >actual &&
71 test_expect_success 'check update-index' '
72 if test -f "$REAL/index"
74 echo "Hmm, $REAL/index exists?"
77 rm -f "$REAL/objects/$(objpath $SHA)" &&
78 git update-index --add bar &&
79 if ! test -f "$REAL/index"
81 echo "$REAL/index not found"
87 test_expect_success 'check write-tree' '
88 SHA=$(git write-tree) &&
92 test_expect_success 'check commit-tree' '
93 SHA=$(echo "commit bar" | git commit-tree $SHA) &&
97 test_expect_success 'check rev-list' '
98 echo $SHA >"$REAL/HEAD" &&
99 test "$SHA" = "$(git rev-list HEAD)"