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
10511000
Commit
10511000
authored
May 06, 2014
by
Russell Belfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2324 from libgit2/cmn/file-in-objects-dir
odb: ignore files in the objects dir
parents
6e9afb97
ee311907
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
src/odb_loose.c
+4
-0
tests/odb/foreach.c
+24
-0
No files found.
src/odb_loose.c
View file @
10511000
...
...
@@ -755,6 +755,10 @@ static int foreach_cb(void *_state, git_buf *path)
{
struct
foreach_state
*
state
=
(
struct
foreach_state
*
)
_state
;
/* non-dir is some stray file, ignore it */
if
(
!
git_path_isdir
(
git_buf_cstr
(
path
)))
return
0
;
return
git_path_direach
(
path
,
0
,
foreach_object_dir_cb
,
state
);
}
...
...
tests/odb/foreach.c
View file @
10511000
...
...
@@ -2,6 +2,7 @@
#include "odb.h"
#include "git2/odb_backend.h"
#include "pack.h"
#include "buffer.h"
static
git_odb
*
_odb
;
static
git_repository
*
_repo
;
...
...
@@ -80,3 +81,26 @@ void test_odb_foreach__interrupt_foreach(void)
cl_assert_equal_i
(
-
321
,
git_odb_foreach
(
_odb
,
foreach_stop_cb
,
&
nobj
));
cl_assert
(
nobj
==
1000
);
}
void
test_odb_foreach__files_in_objects_dir
(
void
)
{
git_repository
*
repo
;
git_odb
*
odb
;
git_buf
buf
=
GIT_BUF_INIT
;
size_t
nobj
=
0
;
cl_fixture_sandbox
(
"testrepo.git"
);
cl_git_pass
(
git_repository_open
(
&
repo
,
"testrepo.git"
));
cl_git_pass
(
git_buf_printf
(
&
buf
,
"%s/objects/somefile"
,
git_repository_path
(
repo
)));
cl_git_mkfile
(
buf
.
ptr
,
""
);
cl_git_pass
(
git_repository_odb
(
&
odb
,
repo
));
cl_git_pass
(
git_odb_foreach
(
odb
,
foreach_cb
,
&
nobj
));
cl_assert_equal_i
(
47
+
1640
,
nobj
);
/* count + in-pack */
git_odb_free
(
odb
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"testrepo.git"
);
}
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