Commit 093d579f by Edward Thomson

attr: cache nonexistent attr files from commits

When looking up an attribute file in a commit, we can cache a
nonexistent attribute file indefinitely (since a commit could not
somehow later contain an attribute file).  Cache an empty buffer when an
attribute file does not exist in a given commit.
parent d7e8b934
...@@ -163,9 +163,24 @@ int git_attr_file__load( ...@@ -163,9 +163,24 @@ int git_attr_file__load(
break; break;
} }
case GIT_ATTR_FILE_SOURCE_COMMIT: { case GIT_ATTR_FILE_SOURCE_COMMIT: {
if ((error = git_repository_head_tree(&tree, repo)) < 0 || if ((error = git_repository_head_tree(&tree, repo)) < 0)
(error = git_tree_entry_bypath(&tree_entry, tree, entry->path)) < 0 || goto cleanup;
(error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0)
if ((error = git_tree_entry_bypath(&tree_entry, tree, entry->path)) < 0) {
/*
* If the attributes file does not exist, we can
* cache an empty file for this commit to prevent
* needless future lookups.
*/
if (error == GIT_ENOTFOUND) {
error = 0;
break;
}
goto cleanup;
}
if ((error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0)
goto cleanup; goto cleanup;
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment