Skip to content

Commit b693753

Browse files
committed
Merge branch 'js/gitdir-at-unc-root' into jch
On Windows, the root level of UNC share is now allowed to be used just like any other directory. * js/gitdir-at-unc-root: setup_git_directory(): handle UNC root paths correctly Fix .git/ discovery at the root of UNC shares setup_git_directory(): handle UNC paths correctly
2 parents 48be1a6 + 5cf7b3b commit b693753

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

setup.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
798798
set_git_dir(gitdir);
799799
inside_git_dir = 0;
800800
inside_work_tree = 1;
801-
if (offset == cwd->len)
801+
if (offset >= cwd->len)
802802
return NULL;
803803

804804
/* Make "offset" point past the '/' (already the case for root dirs) */
@@ -920,7 +920,7 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
920920
const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
921921
struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
922922
const char *gitdirenv;
923-
int ceil_offset = -1, min_offset = has_dos_drive_prefix(dir->buf) ? 3 : 1;
923+
int ceil_offset = -1, min_offset = offset_1st_component(dir->buf);
924924
dev_t current_device = 0;
925925
int one_filesystem = 1;
926926

@@ -948,6 +948,12 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
948948
if (ceil_offset < 0)
949949
ceil_offset = min_offset - 2;
950950

951+
if (min_offset && min_offset == dir->len &&
952+
!is_dir_sep(dir->buf[min_offset - 1])) {
953+
strbuf_addch(dir, '/');
954+
min_offset++;
955+
}
956+
951957
/*
952958
* Test in the following order (relative to the dir):
953959
* - .git (file containing "gitdir: <path>")

0 commit comments

Comments
 (0)