dir: do not traverse repositories with no commits
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index b2cabadf2503b22cc10b3e47c548a5904d77158e..a4e59eb351ca4a095d30e7ef4a8265080f1774c7 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1467,9 +1467,11 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
                        return path_none;
                }
                if (!(dir->flags & DIR_NO_GITLINKS)) {
-                       struct object_id oid;
-                       if (resolve_gitlink_ref(dirname, "HEAD", &oid) == 0)
+                       struct strbuf sb = STRBUF_INIT;
+                       strbuf_addstr(&sb, dirname);
+                       if (is_nonbare_repository_dir(&sb))
                                return exclude ? path_excluded : path_untracked;
+                       strbuf_release(&sb);
                }
                return path_recurse;
        }