mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
attr: ignore missing index
This commit is contained in:
@@ -424,9 +424,13 @@ static int attr_setup(
|
||||
goto out;
|
||||
|
||||
if ((error = git_repository_index__weakptr(&idx, repo)) < 0 ||
|
||||
(error = preload_attr_source(repo, attr_session, &index_source)) < 0)
|
||||
(error = preload_attr_source(repo, attr_session, &index_source)) < 0) {
|
||||
if (error != GIT_ENOTFOUND)
|
||||
goto out;
|
||||
|
||||
error = 0;
|
||||
}
|
||||
|
||||
if ((opts && (opts->flags & GIT_ATTR_CHECK_INCLUDE_HEAD) != 0) &&
|
||||
(error = preload_attr_source(repo, attr_session, &head_source)) < 0)
|
||||
goto out;
|
||||
|
||||
@@ -309,6 +309,31 @@ void test_attr_repo__bare_repo_with_index(void)
|
||||
cl_assert(GIT_ATTR_IS_UNSPECIFIED(values[3]));
|
||||
}
|
||||
|
||||
void test_attr_repo__inmemory_repo_without_index(void)
|
||||
{
|
||||
const char *names[1] = { "fake" };
|
||||
const char *values[1];
|
||||
git_repository *inmemory;
|
||||
git_index *index = NULL;
|
||||
|
||||
/* setup bare in-memory repo without index */
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
cl_git_pass(git_repository_new(&inmemory, GIT_OID_SHA1));
|
||||
#else
|
||||
cl_git_pass(git_repository_new(&inmemory));
|
||||
#endif
|
||||
cl_assert(git_repository_is_bare(inmemory));
|
||||
|
||||
/* verify repo isn't given an index upfront in future */
|
||||
git_repository_index(&index, inmemory);
|
||||
cl_assert(!index);
|
||||
|
||||
/* check attributes can be queried without error due to missing index */
|
||||
cl_git_pass(git_attr_get_many(values, inmemory, 0, "fake.txt", 1, names));
|
||||
|
||||
git_repository_free(inmemory);
|
||||
}
|
||||
|
||||
void test_attr_repo__sysdir(void)
|
||||
{
|
||||
git_str sysdir = GIT_STR_INIT;
|
||||
|
||||
Reference in New Issue
Block a user