summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2018-02-02 11:31:15 -0800
committerGitHub <noreply@github.com>2018-02-02 11:31:15 -0800
commit53454b6819df9a2f04de65a65bfce90ce4dc15e8 (patch)
tree680abfcb53392af532439d45a56762c8a9f803c1
parentf55accce05c3eff9a3ef09a06e80c09135328790 (diff)
parente28e17e60e7a73640a493918d610b9fe56e7f727 (diff)
downloadlibgit2-53454b6819df9a2f04de65a65bfce90ce4dc15e8.tar.gz
Merge pull request #4510 from pks-t/pks/attr-file-bare-stat
attr: avoid stat'ting files for bare repositories
-rw-r--r--src/attr.c18
-rw-r--r--src/ignore.c6
2 files changed, 20 insertions, 4 deletions
diff --git a/src/attr.c b/src/attr.c
index 17309d0eb..93d9551d9 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -56,12 +56,16 @@ int git_attr_get(
git_attr_file *file;
git_attr_name attr;
git_attr_rule *rule;
+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
assert(value && repo && name);
*value = NULL;
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0)
+ if (git_repository_is_bare(repo))
+ dir_flag = GIT_DIR_FLAG_FALSE;
+
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
return -1;
if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0)
@@ -114,13 +118,17 @@ int git_attr_get_many_with_session(
git_attr_rule *rule;
attr_get_many_info *info = NULL;
size_t num_found = 0;
+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
if (!num_attr)
return 0;
assert(values && repo && names);
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0)
+ if (git_repository_is_bare(repo))
+ dir_flag = GIT_DIR_FLAG_FALSE;
+
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
return -1;
if ((error = collect_attr_files(repo, attr_session, flags, pathname, &files)) < 0)
@@ -196,10 +204,14 @@ int git_attr_foreach(
git_attr_rule *rule;
git_attr_assignment *assign;
git_strmap *seen = NULL;
+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
assert(repo && callback);
- if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), GIT_DIR_FLAG_UNKNOWN) < 0)
+ if (git_repository_is_bare(repo))
+ dir_flag = GIT_DIR_FLAG_FALSE;
+
+ if (git_attr_path__init(&path, pathname, git_repository_workdir(repo), dir_flag) < 0)
return -1;
if ((error = collect_attr_files(repo, NULL, flags, pathname, &files)) < 0 ||
diff --git a/src/ignore.c b/src/ignore.c
index 615cd94bf..ddbcaf3bf 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -540,6 +540,7 @@ int git_ignore_path_is_ignored(
git_ignores ignores;
unsigned int i;
git_attr_file *file;
+ git_dir_flag dir_flag = GIT_DIR_FLAG_UNKNOWN;
assert(repo && ignored && pathname);
@@ -548,7 +549,10 @@ int git_ignore_path_is_ignored(
memset(&path, 0, sizeof(path));
memset(&ignores, 0, sizeof(ignores));
- if ((error = git_attr_path__init(&path, pathname, workdir, GIT_DIR_FLAG_UNKNOWN)) < 0 ||
+ if (git_repository_is_bare(repo))
+ dir_flag = GIT_DIR_FLAG_FALSE;
+
+ if ((error = git_attr_path__init(&path, pathname, workdir, dir_flag)) < 0 ||
(error = git_ignore__for_path(repo, path.path, &ignores)) < 0)
goto cleanup;