Commit 5ee50488 by Edward Thomson

attr: rename internal attr file source enum

The enum `git_attr_file_source` is better suffixed with a `_t` since
it's a type-of source.  Similarly, its members should have a matching
name.
parent 5c5c19a6
...@@ -256,7 +256,7 @@ cleanup: ...@@ -256,7 +256,7 @@ cleanup:
static int preload_attr_file( static int preload_attr_file(
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *base, const char *base,
const char *file, const char *file,
bool allow_macros) bool allow_macros)
...@@ -266,8 +266,10 @@ static int preload_attr_file( ...@@ -266,8 +266,10 @@ static int preload_attr_file(
if (!file) if (!file)
return 0; return 0;
if (!(error = git_attr_cache__get(&preload, repo, attr_session, source, base, file, if (!(error = git_attr_cache__get(&preload, repo, attr_session,
git_attr_file__parse_buffer, allow_macros))) source_type, base, file,
git_attr_file__parse_buffer,
allow_macros)))
git_attr_file__free(preload); git_attr_file__free(preload);
return error; return error;
...@@ -333,36 +335,36 @@ static int attr_setup( ...@@ -333,36 +335,36 @@ static int attr_setup(
*/ */
if ((error = system_attr_file(&path, attr_session)) < 0 || if ((error = system_attr_file(&path, attr_session)) < 0 ||
(error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE, (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE_SOURCE_FILE,
NULL, path.ptr, true)) < 0) { NULL, path.ptr, true)) < 0) {
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
goto out; goto out;
} }
if ((error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE, if ((error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE_SOURCE_FILE,
NULL, git_repository_attr_cache(repo)->cfg_attr_file, true)) < 0) NULL, git_repository_attr_cache(repo)->cfg_attr_file, true)) < 0)
goto out; goto out;
git_buf_clear(&path); /* git_repository_item_path expects an empty buffer, because it uses git_buf_set */ git_buf_clear(&path); /* git_repository_item_path expects an empty buffer, because it uses git_buf_set */
if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 || if ((error = git_repository_item_path(&path, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
(error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE, (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE_SOURCE_FILE,
path.ptr, GIT_ATTR_FILE_INREPO, true)) < 0) { path.ptr, GIT_ATTR_FILE_INREPO, true)) < 0) {
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
goto out; goto out;
} }
if ((workdir = git_repository_workdir(repo)) != NULL && if ((workdir = git_repository_workdir(repo)) != NULL &&
(error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_FILE, (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE_SOURCE_FILE,
workdir, GIT_ATTR_FILE, true)) < 0) workdir, GIT_ATTR_FILE, true)) < 0)
goto out; goto out;
if ((error = git_repository_index__weakptr(&idx, repo)) < 0 || if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
(error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_INDEX, (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE_SOURCE_INDEX,
NULL, GIT_ATTR_FILE, true)) < 0) NULL, GIT_ATTR_FILE, true)) < 0)
goto out; goto out;
if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 && if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0 &&
(error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE__FROM_HEAD, (error = preload_attr_file(repo, attr_session, GIT_ATTR_FILE_SOURCE_HEAD,
NULL, GIT_ATTR_FILE, true)) < 0) NULL, GIT_ATTR_FILE, true)) < 0)
goto out; goto out;
...@@ -422,31 +424,34 @@ typedef struct { ...@@ -422,31 +424,34 @@ typedef struct {
} attr_walk_up_info; } attr_walk_up_info;
static int attr_decide_sources( static int attr_decide_sources(
uint32_t flags, bool has_wd, bool has_index, git_attr_file_source *srcs) uint32_t flags,
bool has_wd,
bool has_index,
git_attr_file_source_t *srcs)
{ {
int count = 0; int count = 0;
switch (flags & 0x03) { switch (flags & 0x03) {
case GIT_ATTR_CHECK_FILE_THEN_INDEX: case GIT_ATTR_CHECK_FILE_THEN_INDEX:
if (has_wd) if (has_wd)
srcs[count++] = GIT_ATTR_FILE__FROM_FILE; srcs[count++] = GIT_ATTR_FILE_SOURCE_FILE;
if (has_index) if (has_index)
srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; srcs[count++] = GIT_ATTR_FILE_SOURCE_INDEX;
break; break;
case GIT_ATTR_CHECK_INDEX_THEN_FILE: case GIT_ATTR_CHECK_INDEX_THEN_FILE:
if (has_index) if (has_index)
srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; srcs[count++] = GIT_ATTR_FILE_SOURCE_INDEX;
if (has_wd) if (has_wd)
srcs[count++] = GIT_ATTR_FILE__FROM_FILE; srcs[count++] = GIT_ATTR_FILE_SOURCE_FILE;
break; break;
case GIT_ATTR_CHECK_INDEX_ONLY: case GIT_ATTR_CHECK_INDEX_ONLY:
if (has_index) if (has_index)
srcs[count++] = GIT_ATTR_FILE__FROM_INDEX; srcs[count++] = GIT_ATTR_FILE_SOURCE_INDEX;
break; break;
} }
if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0) if ((flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0)
srcs[count++] = GIT_ATTR_FILE__FROM_HEAD; srcs[count++] = GIT_ATTR_FILE_SOURCE_HEAD;
return count; return count;
} }
...@@ -455,7 +460,7 @@ static int push_attr_file( ...@@ -455,7 +460,7 @@ static int push_attr_file(
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_vector *list, git_vector *list,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *base, const char *base,
const char *filename, const char *filename,
bool allow_macros) bool allow_macros)
...@@ -464,7 +469,9 @@ static int push_attr_file( ...@@ -464,7 +469,9 @@ static int push_attr_file(
git_attr_file *file = NULL; git_attr_file *file = NULL;
error = git_attr_cache__get(&file, repo, attr_session, error = git_attr_cache__get(&file, repo, attr_session,
source, base, filename, git_attr_file__parse_buffer, allow_macros); source_type, base, filename,
git_attr_file__parse_buffer,
allow_macros);
if (error < 0) if (error < 0)
return error; return error;
...@@ -480,7 +487,7 @@ static int push_attr_file( ...@@ -480,7 +487,7 @@ static int push_attr_file(
static int push_one_attr(void *ref, const char *path) static int push_one_attr(void *ref, const char *path)
{ {
attr_walk_up_info *info = (attr_walk_up_info *)ref; attr_walk_up_info *info = (attr_walk_up_info *)ref;
git_attr_file_source src[GIT_ATTR_FILE_NUM_SOURCES]; git_attr_file_source_t src[GIT_ATTR_FILE_NUM_SOURCES];
int error = 0, n_src, i; int error = 0, n_src, i;
bool allow_macros; bool allow_macros;
...@@ -542,7 +549,7 @@ static int collect_attr_files( ...@@ -542,7 +549,7 @@ static int collect_attr_files(
*/ */
if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 || if ((error = git_repository_item_path(&attrfile, repo, GIT_REPOSITORY_ITEM_INFO)) < 0 ||
(error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, (error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE_SOURCE_FILE,
attrfile.ptr, GIT_ATTR_FILE_INREPO, true)) < 0) { attrfile.ptr, GIT_ATTR_FILE_INREPO, true)) < 0) {
if (error != GIT_ENOTFOUND) if (error != GIT_ENOTFOUND)
goto cleanup; goto cleanup;
...@@ -565,7 +572,7 @@ static int collect_attr_files( ...@@ -565,7 +572,7 @@ static int collect_attr_files(
goto cleanup; goto cleanup;
if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) { if (git_repository_attr_cache(repo)->cfg_attr_file != NULL) {
error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE_SOURCE_FILE,
NULL, git_repository_attr_cache(repo)->cfg_attr_file, true); NULL, git_repository_attr_cache(repo)->cfg_attr_file, true);
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
...@@ -575,7 +582,7 @@ static int collect_attr_files( ...@@ -575,7 +582,7 @@ static int collect_attr_files(
error = system_attr_file(&dir, attr_session); error = system_attr_file(&dir, attr_session);
if (!error) if (!error)
error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE__FROM_FILE, error = push_attr_file(repo, attr_session, files, GIT_ATTR_FILE_SOURCE_FILE,
NULL, dir.ptr, true); NULL, dir.ptr, true);
else if (error == GIT_ENOTFOUND) else if (error == GIT_ENOTFOUND)
error = 0; error = 0;
......
...@@ -33,7 +33,7 @@ static void attr_file_free(git_attr_file *file) ...@@ -33,7 +33,7 @@ static void attr_file_free(git_attr_file *file)
int git_attr_file__new( int git_attr_file__new(
git_attr_file **out, git_attr_file **out,
git_attr_file_entry *entry, git_attr_file_entry *entry,
git_attr_file_source source) git_attr_file_source_t source_type)
{ {
git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file)); git_attr_file *attrs = git__calloc(1, sizeof(git_attr_file));
GIT_ERROR_CHECK_ALLOC(attrs); GIT_ERROR_CHECK_ALLOC(attrs);
...@@ -47,8 +47,8 @@ int git_attr_file__new( ...@@ -47,8 +47,8 @@ int git_attr_file__new(
goto on_error; goto on_error;
GIT_REFCOUNT_INC(attrs); GIT_REFCOUNT_INC(attrs);
attrs->entry = entry; attrs->entry = entry;
attrs->source = source; attrs->source_type = source_type;
*out = attrs; *out = attrs;
return 0; return 0;
...@@ -108,7 +108,7 @@ int git_attr_file__load( ...@@ -108,7 +108,7 @@ int git_attr_file__load(
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_attr_file_entry *entry, git_attr_file_entry *entry,
git_attr_file_source source, git_attr_file_source_t source_type,
git_attr_file_parser parser, git_attr_file_parser parser,
bool allow_macros) bool allow_macros)
{ {
...@@ -128,11 +128,11 @@ int git_attr_file__load( ...@@ -128,11 +128,11 @@ int git_attr_file__load(
*out = NULL; *out = NULL;
switch (source) { switch (source_type) {
case GIT_ATTR_FILE__IN_MEMORY: case GIT_ATTR_FILE_SOURCE_MEMORY:
/* in-memory attribute file doesn't need data */ /* in-memory attribute file doesn't need data */
break; break;
case GIT_ATTR_FILE__FROM_INDEX: { case GIT_ATTR_FILE_SOURCE_INDEX: {
if ((error = attr_file_oid_from_index(&id, repo, entry->path)) < 0 || if ((error = attr_file_oid_from_index(&id, repo, entry->path)) < 0 ||
(error = git_blob_lookup(&blob, repo, &id)) < 0) (error = git_blob_lookup(&blob, repo, &id)) < 0)
return error; return error;
...@@ -145,7 +145,7 @@ int git_attr_file__load( ...@@ -145,7 +145,7 @@ int git_attr_file__load(
git_buf_put(&content, git_blob_rawcontent(blob), (size_t)blobsize); git_buf_put(&content, git_blob_rawcontent(blob), (size_t)blobsize);
break; break;
} }
case GIT_ATTR_FILE__FROM_FILE: { case GIT_ATTR_FILE_SOURCE_FILE: {
int fd = -1; int fd = -1;
/* For open or read errors, pretend that we got ENOTFOUND. */ /* For open or read errors, pretend that we got ENOTFOUND. */
...@@ -162,7 +162,7 @@ int git_attr_file__load( ...@@ -162,7 +162,7 @@ int git_attr_file__load(
break; break;
} }
case GIT_ATTR_FILE__FROM_HEAD: { case GIT_ATTR_FILE_SOURCE_HEAD: {
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 || (error = git_tree_entry_bypath(&tree_entry, tree, entry->path)) < 0 ||
(error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0) (error = git_blob_lookup(&blob, repo, git_tree_entry_id(tree_entry))) < 0)
...@@ -182,11 +182,11 @@ int git_attr_file__load( ...@@ -182,11 +182,11 @@ int git_attr_file__load(
break; break;
} }
default: default:
git_error_set(GIT_ERROR_INVALID, "unknown file source %d", source); git_error_set(GIT_ERROR_INVALID, "unknown file source %d", source_type);
return -1; return -1;
} }
if ((error = git_attr_file__new(&file, entry, source)) < 0) if ((error = git_attr_file__new(&file, entry, source_type)) < 0)
goto cleanup; goto cleanup;
/* advance over a UTF8 BOM */ /* advance over a UTF8 BOM */
...@@ -210,11 +210,11 @@ int git_attr_file__load( ...@@ -210,11 +210,11 @@ int git_attr_file__load(
/* write cache breakers */ /* write cache breakers */
if (nonexistent) if (nonexistent)
file->nonexistent = 1; file->nonexistent = 1;
else if (source == GIT_ATTR_FILE__FROM_INDEX) else if (source_type == GIT_ATTR_FILE_SOURCE_INDEX)
git_oid_cpy(&file->cache_data.oid, git_blob_id(blob)); git_oid_cpy(&file->cache_data.oid, git_blob_id(blob));
else if (source == GIT_ATTR_FILE__FROM_HEAD) else if (source_type == GIT_ATTR_FILE_SOURCE_HEAD)
git_oid_cpy(&file->cache_data.oid, git_tree_id(tree)); git_oid_cpy(&file->cache_data.oid, git_tree_id(tree));
else if (source == GIT_ATTR_FILE__FROM_FILE) else if (source_type == GIT_ATTR_FILE_SOURCE_FILE)
git_futils_filestamp_set_from_stat(&file->cache_data.stamp, &st); git_futils_filestamp_set_from_stat(&file->cache_data.stamp, &st);
/* else always cacheable */ /* else always cacheable */
...@@ -245,15 +245,15 @@ int git_attr_file__out_of_date( ...@@ -245,15 +245,15 @@ int git_attr_file__out_of_date(
else if (file->nonexistent) else if (file->nonexistent)
return 1; return 1;
switch (file->source) { switch (file->source_type) {
case GIT_ATTR_FILE__IN_MEMORY: case GIT_ATTR_FILE_SOURCE_MEMORY:
return 0; return 0;
case GIT_ATTR_FILE__FROM_FILE: case GIT_ATTR_FILE_SOURCE_FILE:
return git_futils_filestamp_check( return git_futils_filestamp_check(
&file->cache_data.stamp, file->entry->fullpath); &file->cache_data.stamp, file->entry->fullpath);
case GIT_ATTR_FILE__FROM_INDEX: { case GIT_ATTR_FILE_SOURCE_INDEX: {
int error; int error;
git_oid id; git_oid id;
...@@ -264,7 +264,7 @@ int git_attr_file__out_of_date( ...@@ -264,7 +264,7 @@ int git_attr_file__out_of_date(
return (git_oid__cmp(&file->cache_data.oid, &id) != 0); return (git_oid__cmp(&file->cache_data.oid, &id) != 0);
} }
case GIT_ATTR_FILE__FROM_HEAD: { case GIT_ATTR_FILE_SOURCE_HEAD: {
git_tree *tree; git_tree *tree;
int error; int error;
...@@ -278,7 +278,7 @@ int git_attr_file__out_of_date( ...@@ -278,7 +278,7 @@ int git_attr_file__out_of_date(
} }
default: default:
git_error_set(GIT_ERROR_INVALID, "invalid file type %d", file->source); git_error_set(GIT_ERROR_INVALID, "invalid file type %d", file->source_type);
return -1; return -1;
} }
} }
...@@ -400,7 +400,7 @@ int git_attr_file__load_standalone(git_attr_file **out, const char *path) ...@@ -400,7 +400,7 @@ int git_attr_file__load_standalone(git_attr_file **out, const char *path)
* don't have to free it - freeing file+pool will free cache entry, too. * don't have to free it - freeing file+pool will free cache entry, too.
*/ */
if ((error = git_attr_file__new(&file, NULL, GIT_ATTR_FILE__FROM_FILE)) < 0 || if ((error = git_attr_file__new(&file, NULL, GIT_ATTR_FILE_SOURCE_FILE)) < 0 ||
(error = git_attr_file__parse_buffer(NULL, file, content.ptr, true)) < 0 || (error = git_attr_file__parse_buffer(NULL, file, content.ptr, true)) < 0 ||
(error = git_attr_cache__alloc_file_entry(&file->entry, NULL, NULL, path, &file->pool)) < 0) (error = git_attr_cache__alloc_file_entry(&file->entry, NULL, NULL, path, &file->pool)) < 0)
goto out; goto out;
......
...@@ -37,13 +37,13 @@ ...@@ -37,13 +37,13 @@
(GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_ALLOWMACRO) (GIT_ATTR_FNMATCH_ALLOWSPACE | GIT_ATTR_FNMATCH_ALLOWNEG | GIT_ATTR_FNMATCH_ALLOWMACRO)
typedef enum { typedef enum {
GIT_ATTR_FILE__IN_MEMORY = 0, GIT_ATTR_FILE_SOURCE_MEMORY = 0,
GIT_ATTR_FILE__FROM_FILE = 1, GIT_ATTR_FILE_SOURCE_FILE = 1,
GIT_ATTR_FILE__FROM_INDEX = 2, GIT_ATTR_FILE_SOURCE_INDEX = 2,
GIT_ATTR_FILE__FROM_HEAD = 3, GIT_ATTR_FILE_SOURCE_HEAD = 3,
GIT_ATTR_FILE_NUM_SOURCES = 4 GIT_ATTR_FILE_NUM_SOURCES = 4
} git_attr_file_source; } git_attr_file_source_t;
extern const char *git_attr__true; extern const char *git_attr__true;
extern const char *git_attr__false; extern const char *git_attr__false;
...@@ -81,7 +81,7 @@ typedef struct { ...@@ -81,7 +81,7 @@ typedef struct {
git_refcount rc; git_refcount rc;
git_mutex lock; git_mutex lock;
git_attr_file_entry *entry; git_attr_file_entry *entry;
git_attr_file_source source; git_attr_file_source_t source_type;
git_vector rules; /* vector of <rule*> or <fnmatch*> */ git_vector rules; /* vector of <rule*> or <fnmatch*> */
git_pool pool; git_pool pool;
unsigned int nonexistent:1; unsigned int nonexistent:1;
...@@ -142,7 +142,7 @@ typedef int (*git_attr_file_parser)( ...@@ -142,7 +142,7 @@ typedef int (*git_attr_file_parser)(
int git_attr_file__new( int git_attr_file__new(
git_attr_file **out, git_attr_file **out,
git_attr_file_entry *entry, git_attr_file_entry *entry,
git_attr_file_source source); git_attr_file_source_t source_type);
void git_attr_file__free(git_attr_file *file); void git_attr_file__free(git_attr_file *file);
...@@ -151,7 +151,7 @@ int git_attr_file__load( ...@@ -151,7 +151,7 @@ int git_attr_file__load(
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_attr_file_entry *ce, git_attr_file_entry *ce,
git_attr_file_source source, git_attr_file_source_t source_type,
git_attr_file_parser parser, git_attr_file_parser parser,
bool allow_macros); bool allow_macros);
......
...@@ -112,7 +112,7 @@ static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file) ...@@ -112,7 +112,7 @@ static int attr_cache_upsert(git_attr_cache *cache, git_attr_file *file)
* Replace the existing value if another thread has * Replace the existing value if another thread has
* created it in the meantime. * created it in the meantime.
*/ */
old = git_atomic_swap(entry->file[file->source], file); old = git_atomic_swap(entry->file[file->source_type], file);
if (old) { if (old) {
GIT_REFCOUNT_OWN(old, NULL); GIT_REFCOUNT_OWN(old, NULL);
...@@ -136,7 +136,7 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file) ...@@ -136,7 +136,7 @@ static int attr_cache_remove(git_attr_cache *cache, git_attr_file *file)
return error; return error;
if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL) if ((entry = attr_cache_lookup_entry(cache, file->entry->path)) != NULL)
old = git_atomic_compare_and_swap(&entry->file[file->source], file, NULL); old = git_atomic_compare_and_swap(&entry->file[file->source_type], file, NULL);
attr_cache_unlock(cache); attr_cache_unlock(cache);
...@@ -158,7 +158,7 @@ static int attr_cache_lookup( ...@@ -158,7 +158,7 @@ static int attr_cache_lookup(
git_attr_file_entry **out_entry, git_attr_file_entry **out_entry,
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *base, const char *base,
const char *filename) const char *filename)
{ {
...@@ -191,8 +191,8 @@ static int attr_cache_lookup( ...@@ -191,8 +191,8 @@ static int attr_cache_lookup(
entry = attr_cache_lookup_entry(cache, relfile); entry = attr_cache_lookup_entry(cache, relfile);
if (!entry) if (!entry)
error = attr_cache_make_entry(&entry, repo, relfile); error = attr_cache_make_entry(&entry, repo, relfile);
else if (entry->file[source] != NULL) { else if (entry->file[source_type] != NULL) {
file = entry->file[source]; file = entry->file[source_type];
GIT_REFCOUNT_INC(file); GIT_REFCOUNT_INC(file);
} }
...@@ -210,7 +210,7 @@ int git_attr_cache__get( ...@@ -210,7 +210,7 @@ int git_attr_cache__get(
git_attr_file **out, git_attr_file **out,
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *base, const char *base,
const char *filename, const char *filename,
git_attr_file_parser parser, git_attr_file_parser parser,
...@@ -221,13 +221,15 @@ int git_attr_cache__get( ...@@ -221,13 +221,15 @@ int git_attr_cache__get(
git_attr_file_entry *entry = NULL; git_attr_file_entry *entry = NULL;
git_attr_file *file = NULL, *updated = NULL; git_attr_file *file = NULL, *updated = NULL;
if ((error = attr_cache_lookup( if ((error = attr_cache_lookup(&file, &entry, repo, attr_session,
&file, &entry, repo, attr_session, source, base, filename)) < 0) source_type, base, filename)) < 0)
return error; return error;
/* load file if we don't have one or if existing one is out of date */ /* load file if we don't have one or if existing one is out of date */
if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0) if (!file || (error = git_attr_file__out_of_date(repo, attr_session, file)) > 0)
error = git_attr_file__load(&updated, repo, attr_session, entry, source, parser, allow_macros); error = git_attr_file__load(&updated, repo, attr_session,
entry, source_type, parser,
allow_macros);
/* if we loaded the file, insert into and/or update cache */ /* if we loaded the file, insert into and/or update cache */
if (updated) { if (updated) {
...@@ -260,7 +262,7 @@ int git_attr_cache__get( ...@@ -260,7 +262,7 @@ int git_attr_cache__get(
bool git_attr_cache__is_cached( bool git_attr_cache__is_cached(
git_repository *repo, git_repository *repo,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *filename) const char *filename)
{ {
git_attr_cache *cache = git_repository_attr_cache(repo); git_attr_cache *cache = git_repository_attr_cache(repo);
...@@ -273,7 +275,7 @@ bool git_attr_cache__is_cached( ...@@ -273,7 +275,7 @@ bool git_attr_cache__is_cached(
if ((entry = git_strmap_get(files, filename)) == NULL) if ((entry = git_strmap_get(files, filename)) == NULL)
return false; return false;
return entry && (entry->file[source] != NULL); return entry && (entry->file[source_type] != NULL);
} }
......
...@@ -31,7 +31,7 @@ extern int git_attr_cache__get( ...@@ -31,7 +31,7 @@ extern int git_attr_cache__get(
git_attr_file **file, git_attr_file **file,
git_repository *repo, git_repository *repo,
git_attr_session *attr_session, git_attr_session *attr_session,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *base, const char *base,
const char *filename, const char *filename,
git_attr_file_parser parser, git_attr_file_parser parser,
...@@ -39,7 +39,7 @@ extern int git_attr_cache__get( ...@@ -39,7 +39,7 @@ extern int git_attr_cache__get(
extern bool git_attr_cache__is_cached( extern bool git_attr_cache__is_cached(
git_repository *repo, git_repository *repo,
git_attr_file_source source, git_attr_file_source_t source_type,
const char *path); const char *path);
extern int git_attr_cache__alloc_file_entry( extern int git_attr_cache__alloc_file_entry(
......
...@@ -250,8 +250,10 @@ static int push_ignore_file( ...@@ -250,8 +250,10 @@ static int push_ignore_file(
int error = 0; int error = 0;
git_attr_file *file = NULL; git_attr_file *file = NULL;
error = git_attr_cache__get(&file, ignores->repo, NULL, GIT_ATTR_FILE__FROM_FILE, error = git_attr_cache__get(&file, ignores->repo, NULL,
base, filename, parse_ignore_file, false); GIT_ATTR_FILE_SOURCE_FILE, base,
filename, parse_ignore_file, false);
if (error < 0) if (error < 0)
return error; return error;
...@@ -277,8 +279,9 @@ static int get_internal_ignores(git_attr_file **out, git_repository *repo) ...@@ -277,8 +279,9 @@ static int get_internal_ignores(git_attr_file **out, git_repository *repo)
if ((error = git_attr_cache__init(repo)) < 0) if ((error = git_attr_cache__init(repo)) < 0)
return error; return error;
error = git_attr_cache__get(out, repo, NULL, GIT_ATTR_FILE__IN_MEMORY, NULL, error = git_attr_cache__get(out, repo, NULL,
GIT_IGNORE_INTERNAL, NULL, false); GIT_ATTR_FILE_SOURCE_MEMORY, NULL,
GIT_IGNORE_INTERNAL, NULL, false);
/* if internal rules list is empty, insert default rules */ /* if internal rules list is empty, insert default rules */
if (!error && !(*out)->rules.length) if (!error && !(*out)->rules.length)
......
...@@ -71,11 +71,11 @@ void test_attr_repo__get_one(void) ...@@ -71,11 +71,11 @@ void test_attr_repo__get_one(void)
} }
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/attributes")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".git/info/attributes"));
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitattributes")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".gitattributes"));
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, "sub/.gitattributes")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, "sub/.gitattributes"));
} }
void test_attr_repo__get_one_start_deep(void) void test_attr_repo__get_one_start_deep(void)
...@@ -92,11 +92,11 @@ void test_attr_repo__get_one_start_deep(void) ...@@ -92,11 +92,11 @@ void test_attr_repo__get_one_start_deep(void)
} }
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/attributes")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".git/info/attributes"));
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitattributes")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".gitattributes"));
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, "sub/.gitattributes")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, "sub/.gitattributes"));
} }
void test_attr_repo__get_many(void) void test_attr_repo__get_many(void)
......
...@@ -70,9 +70,9 @@ void test_ignore_status__0(void) ...@@ -70,9 +70,9 @@ void test_ignore_status__0(void)
/* confirm that ignore files were cached */ /* confirm that ignore files were cached */
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, ".git/info/exclude")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".git/info/exclude"));
cl_assert(git_attr_cache__is_cached( cl_assert(git_attr_cache__is_cached(
g_repo, GIT_ATTR_FILE__FROM_FILE, ".gitignore")); g_repo, GIT_ATTR_FILE_SOURCE_FILE, ".gitignore"));
} }
......
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