summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-02-05 22:54:17 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-05 22:54:17 (GMT)
commite2d7739051cadf25094c3fc7593b73b30c680696 (patch)
treed5382b621dbf318f2a3ec7f85c531ad67fe53511 /cache.h
parent07be1da216debe1f76cd4d03ac5effcb9e40e6c6 (diff)
parenta2d5156c2b0e6dbffc216b4a673156487a2f8b65 (diff)
downloadgit-e2d7739051cadf25094c3fc7593b73b30c680696.zip
git-e2d7739051cadf25094c3fc7593b73b30c680696.tar.gz
git-e2d7739051cadf25094c3fc7593b73b30c680696.tar.bz2
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 'cache.h')
-rw-r--r--cache.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/cache.h b/cache.h
index ee0adc8..3efd7ac 100644
--- a/cache.h
+++ b/cache.h
@@ -456,7 +456,6 @@ extern char *git_work_tree_cfg;
extern int is_inside_work_tree(void);
extern const char *get_git_dir(void);
extern const char *get_git_common_dir(void);
-extern int is_git_directory(const char *path);
extern char *get_object_directory(void);
extern char *get_index_file(void);
extern char *get_graft_file(void);
@@ -467,6 +466,25 @@ extern const char *get_git_namespace(void);
extern const char *strip_namespace(const char *namespaced_ref);
extern const char *get_git_work_tree(void);
+/*
+ * Return true if the given path is a git directory; note that this _just_
+ * looks at the directory itself. If you want to know whether "foo/.git"
+ * is a repository, you must feed that path, not just "foo".
+ */
+extern int is_git_directory(const char *path);
+
+/*
+ * Return 1 if the given path is the root of a git repository or
+ * submodule, else 0. Will not return 1 for bare repositories with the
+ * exception of creating a bare repository in "foo/.git" and calling
+ * is_git_repository("foo").
+ *
+ * If we run into read errors, we err on the side of saying "yes, it is",
+ * as we usually consider sub-repos precious, and would prefer to err on the
+ * side of not disrupting or deleting them.
+ */
+extern int is_nonbare_repository_dir(struct strbuf *path);
+
#define READ_GITFILE_ERR_STAT_FAILED 1
#define READ_GITFILE_ERR_NOT_A_FILE 2
#define READ_GITFILE_ERR_OPEN_FAILED 3