summaryrefslogtreecommitdiff
path: root/builtin/clean.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-02-03 22:16:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-03 22:16:07 (GMT)
commitad25723e69606d9f4f3596eeb427fde3abee76c3 (patch)
treec02dbf8b2fdc076220de3862410b4cef5cb2078f /builtin/clean.c
parent48c39e98c6aff98b5dd165435373e517780302ad (diff)
parenta2d5156c2b0e6dbffc216b4a673156487a2f8b65 (diff)
downloadgit-ad25723e69606d9f4f3596eeb427fde3abee76c3.zip
git-ad25723e69606d9f4f3596eeb427fde3abee76c3.tar.gz
git-ad25723e69606d9f4f3596eeb427fde3abee76c3.tar.bz2
Merge branch 'jk/ref-cache-non-repository-optim'
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/clean.c')
-rw-r--r--builtin/clean.c26
1 files changed, 1 insertions, 25 deletions
diff --git a/builtin/clean.c b/builtin/clean.c
index cc5f972..7b08237 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),