clean: make is_git_repository a public function
We have always had is_git_directory(), for looking at a specific directory to see if it contains a git repo. In0179ca7(clean: improve performance when removing lots of directories, 2015-06-15), we added is_git_repository() which checks for a non-bare repository by looking at its ".git" entry. However, the fix in0179ca7needs to be applied other places, too. Let's make this new helper globally available. We need to give it a better name, though, to avoid confusion with is_git_directory(). This patch does that, documents both functions with a comment to reduce confusion, and removes the clean-specific references in the comments. Based-on-a-patch-by: Andreas Krey <a.krey@gmx.de> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
1b0b6dd072
commit
ffd036b128
20
cache.h
20
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
|
||||
|
||||
Reference in New Issue
Block a user