Merge branch 'js/gitdir-at-unc-root'
authorJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2019 04:19:26 +0000 (13:19 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2019 04:19:26 +0000 (13:19 +0900)
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

1  2 
setup.c
diff --combined setup.c
index 25a3038277cdaaca736a82191dd6b7bb82cd9ae2,03efbb274a682c039e28ca46f09b34de08587f47..e2a479a64fa4076bad8eaf6cf0949d0ae263da9d
+++ b/setup.c
@@@ -4,7 -4,6 +4,7 @@@
  #include "dir.h"
  #include "string-list.h"
  #include "chdir-notify.h"
 +#include "promisor-remote.h"
  
  static int inside_git_dir = -1;
  static int inside_work_tree = -1;
@@@ -479,7 -478,7 +479,7 @@@ static int check_repository_format_gent
        }
  
        repository_format_precious_objects = candidate->precious_objects;
 -      repository_format_partial_clone = xstrdup_or_null(candidate->partial_clone);
 +      set_repository_format_partial_clone(candidate->partial_clone);
        repository_format_worktree_config = candidate->worktree_config;
        string_list_clear(&candidate->unknown_extensions, 0);
  
@@@ -798,7 -797,7 +798,7 @@@ static const char *setup_discovered_git
                set_git_dir(gitdir);
        inside_git_dir = 0;
        inside_work_tree = 1;
-       if (offset == cwd->len)
+       if (offset >= cwd->len)
                return NULL;
  
        /* Make "offset" point past the '/' (already the case for root dirs) */
@@@ -920,7 -919,7 +920,7 @@@ static enum discovery_result setup_git_
        const char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);
        struct string_list ceiling_dirs = STRING_LIST_INIT_DUP;
        const char *gitdirenv;
-       int ceil_offset = -1, min_offset = has_dos_drive_prefix(dir->buf) ? 3 : 1;
+       int ceil_offset = -1, min_offset = offset_1st_component(dir->buf);
        dev_t current_device = 0;
        int one_filesystem = 1;
  
        if (ceil_offset < 0)
                ceil_offset = min_offset - 2;
  
+       if (min_offset && min_offset == dir->len &&
+           !is_dir_sep(dir->buf[min_offset - 1])) {
+               strbuf_addch(dir, '/');
+               min_offset++;
+       }
        /*
         * Test in the following order (relative to the dir):
         * - .git (file containing "gitdir: <path>")