summaryrefslogtreecommitdiff
path: root/builtin
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 /builtin
parent07be1da216debe1f76cd4d03ac5effcb9e40e6c6 (diff)
parenta2d5156c2b0e6dbffc216b4a673156487a2f8b65 (diff)
downloadgit-e2d7739051cadf25094c3fc7593b73b30c680696.tar.gz
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 'builtin')
-rw-r--r--builtin/clean.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index d7acb94a95..919157bc2f 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -147,30 +147,6 @@ static int exclude_cb(const struct option *opt, const char *arg, int unset)
return 0;
}
-/*
- * 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").
- */
-static int is_git_repository(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; /* This could be a real .git file, take the
- * safe option and avoid cleaning */
- strbuf_setlen(path, orig_path_len);
- return ret;
-}
-
static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
int dry_run, int quiet, int *dir_gone)
{
@@ -182,7 +158,7 @@ static int remove_dirs(struct strbuf *path, const char *prefix, int force_flag,
*dir_gone = 1;
- if ((force_flag & REMOVE_DIR_KEEP_NESTED_GIT) && is_git_repository(path)) {
+ if ((force_flag & REMOVE_DIR_KEEP_NESTED_GIT) && is_nonbare_repository_dir(path)) {
if (!quiet) {
quote_path_relative(path->buf, prefix, &quoted);
printf(dry_run ? _(msg_would_skip_git_dir) : _(msg_skip_git_dir),