Skip to content

Commit 1f5fbe1

Browse files
pcloudsgitster
authored andcommitted
enter_repo: allow .git files in strict mode
Strict mode is about not guessing where .git is. If the user points to a .git file, we know exactly where the target .git dir will be. This makes it possible to serve .git files as repository on the server side. This may be needed even in local clone case because transport.c code uses upload-pack for fetching remote refs. But right now the clone/transport code goes with non-strict. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f64cc4 commit 1f5fbe1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

path.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,13 @@ const char *enter_repo(const char *path, int strict)
438438
return NULL;
439439
path = validated_path;
440440
}
441-
else if (chdir(path))
442-
return NULL;
441+
else {
442+
const char *gitfile = read_gitfile(path);
443+
if (gitfile)
444+
path = gitfile;
445+
if (chdir(path))
446+
return NULL;
447+
}
443448

444449
if (is_git_directory(".")) {
445450
set_git_dir(".");

t/t0002-gitfile.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,14 @@ test_expect_success 'enter_repo linked checkout' '
148148
test_cmp expected actual
149149
'
150150

151+
test_expect_success 'enter_repo strict mode' '
152+
git ls-remote --upload-pack="git upload-pack --strict" foo/.git >actual &&
153+
cat >expected <<-\EOF &&
154+
946e985ab20de757ca5b872b16d64e92ff3803a9 HEAD
155+
946e985ab20de757ca5b872b16d64e92ff3803a9 refs/heads/master
156+
946e985ab20de757ca5b872b16d64e92ff3803a9 refs/tags/foo
157+
EOF
158+
test_cmp expected actual
159+
'
160+
151161
test_done

0 commit comments

Comments
 (0)