summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-01-29 14:40:55 -0600
committerEdward Thomson <ethomson@microsoft.com>2015-02-03 00:31:08 -0500
commit9f779aacdd950fd53a407da615ca60d628e31d35 (patch)
tree55819aa11a18e2d272d75118239d23243b49357a /src/checkout.c
parent60561d54468d7097e04466fd8125be5231cea637 (diff)
downloadlibgit2-9f779aacdd950fd53a407da615ca60d628e31d35.tar.gz
attrcache: don't re-read attrs during checkout
During checkout, assume that the .gitattributes files aren't modified during the checkout. Instead, create an "attribute session" during checkout. Assume that attribute data read in the same checkout "session" hasn't been modified since the checkout started. (But allow subsequent checkouts to invalidate the cache.) Further, cache nonexistent git_attr_file data even when .gitattributes files are not found to prevent re-scanning for nonexistent files.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/checkout.c b/src/checkout.c
index 52a076da6..04493a3cb 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -28,6 +28,7 @@
#include "buf_text.h"
#include "merge_file.h"
#include "path.h"
+#include "attr.h"
/* See docs/checkout-internals.md for more information */
@@ -69,6 +70,7 @@ typedef struct {
size_t completed_steps;
git_checkout_perfdata perfdata;
git_buf last_mkdir;
+ git_attr_session attr_session;
} checkout_data;
typedef struct {
@@ -1425,8 +1427,8 @@ static int blob_content_to_file(
hint_path = path;
if (!data->opts.disable_filters)
- error = git_filter_list_load(
- &fl, git_blob_owner(blob), blob, hint_path,
+ error = git_filter_list__load_with_attr_session(
+ &fl, data->repo, &data->attr_session, blob, hint_path,
GIT_FILTER_TO_WORKTREE, GIT_FILTER_OPT_DEFAULT);
if (!error)
@@ -2008,7 +2010,8 @@ static int checkout_write_merge(
in_data.ptr = (char *)result.ptr;
in_data.size = result.len;
- if ((error = git_filter_list_load(&fl, data->repo, NULL, git_buf_cstr(&path_workdir),
+ if ((error = git_filter_list__load_with_attr_session(
+ &fl, data->repo, &data->attr_session, NULL, git_buf_cstr(&path_workdir),
GIT_FILTER_TO_WORKTREE, GIT_FILTER_OPT_DEFAULT)) < 0 ||
(error = git_filter_list_apply_to_data(&out_data, fl, &in_data)) < 0)
goto done;
@@ -2218,6 +2221,8 @@ static void checkout_data_clear(checkout_data *data)
git_index_free(data->index);
data->index = NULL;
+
+ git_attr_session__free(&data->attr_session);
}
static int checkout_data_init(
@@ -2360,6 +2365,8 @@ static int checkout_data_init(
data->workdir_len = git_buf_len(&data->path);
+ git_attr_session__init(&data->attr_session, data->repo);
+
cleanup:
if (error < 0)
checkout_data_clear(data);