3 test_description='.git file
5 Verify that plumbing commands work when .git is a file
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
13 echo "$1" | sed -e 's|\(..\)|\1/|'
16 test_expect_success 'initial setup' '
17 REAL="$(pwd)/.real" &&
21 test_expect_success 'bad setup: invalid .git file format' '
22 echo "gitdir $REAL" >.git &&
23 test_must_fail git rev-parse 2>.err &&
24 test_i18ngrep "invalid gitfile format" .err
27 test_expect_success 'bad setup: invalid .git file path' '
28 echo "gitdir: $REAL.not" >.git &&
29 test_must_fail git rev-parse 2>.err &&
30 test_i18ngrep "not a git repository" .err
33 test_expect_success 'final setup + check rev-parse --git-dir' '
34 echo "gitdir: $REAL" >.git &&
35 test "$REAL" = "$(git rev-parse --git-dir)"
38 test_expect_success 'check hash-object' '
40 SHA=$(cat bar | git hash-object -w --stdin) &&
41 test_path_is_file "$REAL/objects/$(objpath $SHA)"
44 test_expect_success 'check cat-file' '
45 git cat-file blob $SHA >actual &&
49 test_expect_success 'check update-index' '
50 test_path_is_missing "$REAL/index" &&
51 rm -f "$REAL/objects/$(objpath $SHA)" &&
52 git update-index --add bar &&
53 test_path_is_file "$REAL/index" &&
54 test_path_is_file "$REAL/objects/$(objpath $SHA)"
57 test_expect_success 'check write-tree' '
58 SHA=$(git write-tree) &&
59 test_path_is_file "$REAL/objects/$(objpath $SHA)"
62 test_expect_success 'check commit-tree' '
63 SHA=$(echo "commit bar" | git commit-tree $SHA) &&
64 test_path_is_file "$REAL/objects/$(objpath $SHA)"
67 test_expect_success 'check rev-list' '
68 git update-ref "HEAD" "$SHA" &&
69 test "$SHA" = "$(git rev-list HEAD)"
72 test_expect_success 'setup_git_dir twice in subdir' '
76 git config alias.lsfi ls-files &&
78 echo "gitdir: .realgit" >.git &&
85 test_cmp expected actual
89 test_expect_success 'enter_repo non-strict mode' '
90 test_create_repo enter_repo &&
96 echo "gitdir: .realgit" >.git
98 head=$(git -C enter_repo rev-parse HEAD) &&
99 git ls-remote enter_repo >actual &&
100 cat >expected <<-EOF &&
102 $head refs/heads/master
105 test_cmp expected actual
108 test_expect_success 'enter_repo linked checkout' '
111 git worktree add ../foo refs/tags/foo
113 head=$(git -C enter_repo rev-parse HEAD) &&
114 git ls-remote foo >actual &&
115 cat >expected <<-EOF &&
117 $head refs/heads/master
120 test_cmp expected actual
123 test_expect_success 'enter_repo strict mode' '
124 head=$(git -C enter_repo rev-parse HEAD) &&
125 git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&
126 cat >expected <<-EOF &&
128 $head refs/heads/master
131 test_cmp expected actual