aboutsummaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-02-05 14:54:17 -0800
committerJunio C Hamano <gitster@pobox.com>2016-02-05 14:54:17 -0800
commite2d7739051cadf25094c3fc7593b73b30c680696 (patch)
treed5382b621dbf318f2a3ec7f85c531ad67fe53511 /setup.c
parent07be1da216debe1f76cd4d03ac5effcb9e40e6c6 (diff)
parenta2d5156c2b0e6dbffc216b4a673156487a2f8b65 (diff)
downloadgit-e2d7739051cadf25094c3fc7593b73b30c680696.tar.xz
Merge branch 'jk/ref-cache-non-repository-optim' into maint
The underlying machinery used by "ls-files -o" and other commands have been taught not to create empty submodule ref cache for a directory that is not a submodule. This removes a ton of wasted CPU cycles. * jk/ref-cache-non-repository-optim: resolve_gitlink_ref: ignore non-repository paths clean: make is_git_repository a public function
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/setup.c b/setup.c
index d34372520b..2c4b22c845 100644
--- a/setup.c
+++ b/setup.c
@@ -312,6 +312,23 @@ done:
return ret;
}
+int is_nonbare_repository_dir(struct strbuf *path)
+{
+ int ret = 0;
+ int gitfile_error;
+ size_t orig_path_len = path->len;
+ assert(orig_path_len != 0);
+ strbuf_complete(path, '/');
+ strbuf_addstr(path, ".git");
+ if (read_gitfile_gently(path->buf, &gitfile_error) || is_git_directory(path->buf))
+ ret = 1;
+ if (gitfile_error == READ_GITFILE_ERR_OPEN_FAILED ||
+ gitfile_error == READ_GITFILE_ERR_READ_FAILED)
+ ret = 1;
+ strbuf_setlen(path, orig_path_len);
+ return ret;
+}
+
int is_inside_git_dir(void)
{
if (inside_git_dir < 0)