3 test_description
='.git file
5 Verify that plumbing commands work when .git is a file
10 echo "$1" |
sed -e 's|\(..\)|\1/|'
13 test_expect_success
'initial setup' '
14 REAL="$(pwd)/.real" &&
18 test_expect_success
'bad setup: invalid .git file format' '
19 echo "gitdir $REAL" >.git &&
20 test_must_fail git rev-parse 2>.err &&
21 test_i18ngrep "invalid gitfile format" .err
24 test_expect_success
'bad setup: invalid .git file path' '
25 echo "gitdir: $REAL.not" >.git &&
26 test_must_fail git rev-parse 2>.err &&
27 test_i18ngrep "not a git repository" .err
30 test_expect_success
'final setup + check rev-parse --git-dir' '
31 echo "gitdir: $REAL" >.git &&
32 test "$REAL" = "$(git rev-parse --git-dir)"
35 test_expect_success
'check hash-object' '
37 SHA=$(cat bar | git hash-object -w --stdin) &&
38 test_path_is_file "$REAL/objects/$(objpath $SHA)"
41 test_expect_success
'check cat-file' '
42 git cat-file blob $SHA >actual &&
46 test_expect_success
'check update-index' '
47 test_path_is_missing "$REAL/index" &&
48 rm -f "$REAL/objects/$(objpath $SHA)" &&
49 git update-index --add bar &&
50 test_path_is_file "$REAL/index" &&
51 test_path_is_file "$REAL/objects/$(objpath $SHA)"
54 test_expect_success
'check write-tree' '
55 SHA=$(git write-tree) &&
56 test_path_is_file "$REAL/objects/$(objpath $SHA)"
59 test_expect_success
'check commit-tree' '
60 SHA=$(echo "commit bar" | git commit-tree $SHA) &&
61 test_path_is_file "$REAL/objects/$(objpath $SHA)"
64 test_expect_success
'check rev-list' '
65 echo $SHA >"$REAL/HEAD" &&
66 test "$SHA" = "$(git rev-list HEAD)"
69 test_expect_success
'setup_git_dir twice in subdir' '
73 git config alias.lsfi ls-files &&
75 echo "gitdir: .realgit" >.git &&
82 test_cmp expected actual
86 test_expect_success
'enter_repo non-strict mode' '
87 test_create_repo enter_repo &&
93 echo "gitdir: .realgit" >.git
95 head=$(git -C enter_repo rev-parse HEAD) &&
96 git ls-remote enter_repo >actual &&
97 cat >expected <<-EOF &&
99 $head refs/heads/master
102 test_cmp expected actual
105 test_expect_success
'enter_repo linked checkout' '
108 git worktree add ../foo refs/tags/foo
110 head=$(git -C enter_repo rev-parse HEAD) &&
111 git ls-remote foo >actual &&
112 cat >expected <<-EOF &&
114 $head refs/heads/master
117 test_cmp expected actual
120 test_expect_success
'enter_repo strict mode' '
121 head=$(git -C enter_repo rev-parse HEAD) &&
122 git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&
123 cat >expected <<-EOF &&
125 $head refs/heads/master
128 test_cmp expected actual