]>
Commit | Line | Data |
---|---|---|
b44ebb19 LH |
1 | #!/bin/sh |
2 | ||
3 | test_description='.git file | |
4 | ||
5 | Verify that plumbing commands work when .git is a file | |
6 | ' | |
7 | . ./test-lib.sh | |
8 | ||
9 | objpath() { | |
10 | echo "$1" | sed -e 's|\(..\)|\1/|' | |
11 | } | |
12 | ||
13 | objck() { | |
14 | p=$(objpath "$1") | |
15 | if test ! -f "$REAL/objects/$p" | |
16 | then | |
17 | echo "Object not found: $REAL/objects/$p" | |
18 | false | |
19 | fi | |
20 | } | |
21 | ||
22 | ||
23 | test_expect_success 'initial setup' ' | |
24 | REAL="$(pwd)/.real" && | |
25 | mv .git "$REAL" | |
26 | ' | |
27 | ||
28 | test_expect_success 'bad setup: invalid .git file format' ' | |
29 | echo "gitdir $REAL" >.git && | |
30 | if git rev-parse 2>.err | |
31 | then | |
32 | echo "git rev-parse accepted an invalid .git file" | |
33 | false | |
34 | fi && | |
87539416 | 35 | if ! grep "Invalid gitfile format" .err |
b44ebb19 LH |
36 | then |
37 | echo "git rev-parse returned wrong error" | |
38 | false | |
39 | fi | |
40 | ' | |
41 | ||
42 | test_expect_success 'bad setup: invalid .git file path' ' | |
43 | echo "gitdir: $REAL.not" >.git && | |
44 | if git rev-parse 2>.err | |
45 | then | |
46 | echo "git rev-parse accepted an invalid .git file path" | |
47 | false | |
48 | fi && | |
87539416 | 49 | if ! grep "Not a git repository" .err |
b44ebb19 LH |
50 | then |
51 | echo "git rev-parse returned wrong error" | |
52 | false | |
53 | fi | |
54 | ' | |
55 | ||
56 | test_expect_success 'final setup + check rev-parse --git-dir' ' | |
57 | echo "gitdir: $REAL" >.git && | |
58 | test "$REAL" = "$(git rev-parse --git-dir)" | |
59 | ' | |
60 | ||
61 | test_expect_success 'check hash-object' ' | |
62 | echo "foo" >bar && | |
63 | SHA=$(cat bar | git hash-object -w --stdin) && | |
64 | objck $SHA | |
65 | ' | |
66 | ||
67 | test_expect_success 'check cat-file' ' | |
68 | git cat-file blob $SHA >actual && | |
2b14d072 | 69 | test_cmp bar actual |
b44ebb19 LH |
70 | ' |
71 | ||
72 | test_expect_success 'check update-index' ' | |
73 | if test -f "$REAL/index" | |
74 | then | |
75 | echo "Hmm, $REAL/index exists?" | |
76 | false | |
77 | fi && | |
78 | rm -f "$REAL/objects/$(objpath $SHA)" && | |
79 | git update-index --add bar && | |
80 | if ! test -f "$REAL/index" | |
81 | then | |
82 | echo "$REAL/index not found" | |
83 | false | |
84 | fi && | |
85 | objck $SHA | |
86 | ' | |
87 | ||
88 | test_expect_success 'check write-tree' ' | |
89 | SHA=$(git write-tree) && | |
90 | objck $SHA | |
91 | ' | |
92 | ||
93 | test_expect_success 'check commit-tree' ' | |
94 | SHA=$(echo "commit bar" | git commit-tree $SHA) && | |
95 | objck $SHA | |
96 | ' | |
97 | ||
98 | test_expect_success 'check rev-list' ' | |
99 | echo $SHA >"$REAL/HEAD" && | |
100 | test "$SHA" = "$(git rev-list HEAD)" | |
101 | ' | |
102 | ||
103 | test_done |