Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
f5793057
Commit
f5793057
authored
Dec 15, 2023
by
Kevin Saul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attr: ignore missing index
parent
d1bdf2a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletions
+30
-1
src/libgit2/attr.c
+5
-1
tests/libgit2/attr/repo.c
+25
-0
No files found.
src/libgit2/attr.c
View file @
f5793057
...
...
@@ -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
;
...
...
tests/libgit2/attr/repo.c
View file @
f5793057
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment