Merge branch 'nd/clone-linked-checkout'
[gitweb.git] / path.c
diff --git a/path.c b/path.c
index 5ec34905a39d6e74134dd3488145b9da44f61b55..62a2ae82ddfd3fc9213da0988e761985a5f177e4 100644 (file)
--- a/path.c
+++ b/path.c
@@ -668,11 +668,15 @@ const char *enter_repo(const char *path, int strict)
                        return NULL;
                path = validated_path;
        }
-       else if (chdir(path))
-               return NULL;
+       else {
+               const char *gitfile = read_gitfile(path);
+               if (gitfile)
+                       path = gitfile;
+               if (chdir(path))
+                       return NULL;
+       }
 
-       if (access("objects", X_OK) == 0 && access("refs", X_OK) == 0 &&
-           validate_headref("HEAD") == 0) {
+       if (is_git_directory(".")) {
                set_git_dir(".");
                check_repository_format();
                return path;