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
c89f1cf9
Commit
c89f1cf9
authored
Nov 21, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2724 from libgit2/vmg/empty
odb: `git_odb_object` contents are never NULL
parents
fc6ac074
e0156651
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
+20
-2
src/odb.c
+2
-2
tests/odb/emptyobjects.c
+18
-0
No files found.
src/odb.c
View file @
c89f1cf9
...
...
@@ -762,12 +762,12 @@ static int hardcoded_objects(git_rawobj *raw, const git_oid *id)
if
(
!
git_oid_cmp
(
id
,
&
empty_blob
))
{
raw
->
type
=
GIT_OBJ_BLOB
;
raw
->
len
=
0
;
raw
->
data
=
NULL
;
raw
->
data
=
git__calloc
(
1
,
sizeof
(
uint8_t
))
;
return
0
;
}
else
if
(
!
git_oid_cmp
(
id
,
&
empty_tree
))
{
raw
->
type
=
GIT_OBJ_TREE
;
raw
->
len
=
0
;
raw
->
data
=
NULL
;
raw
->
data
=
git__calloc
(
1
,
sizeof
(
uint8_t
))
;
return
0
;
}
else
{
return
GIT_ENOTFOUND
;
...
...
tests/odb/emptyobjects.c
View file @
c89f1cf9
...
...
@@ -21,6 +21,8 @@ void test_odb_emptyobjects__read(void)
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"
));
cl_git_pass
(
git_blob_lookup
(
&
blob
,
g_repo
,
&
id
));
cl_assert_equal_i
(
GIT_OBJ_BLOB
,
git_object_type
((
git_object
*
)
blob
));
cl_assert
(
git_blob_rawcontent
(
blob
));
cl_assert_equal_s
(
""
,
git_blob_rawcontent
(
blob
));
cl_assert_equal_i
(
0
,
git_blob_rawsize
(
blob
));
git_blob_free
(
blob
);
}
...
...
@@ -37,3 +39,19 @@ void test_odb_emptyobjects__read_tree(void)
cl_assert_equal_p
(
NULL
,
git_tree_entry_byname
(
tree
,
"foo"
));
git_tree_free
(
tree
);
}
void
test_odb_emptyobjects__read_tree_odb
(
void
)
{
git_oid
id
;
git_odb
*
odb
;
git_odb_object
*
tree_odb
;
cl_git_pass
(
git_oid_fromstr
(
&
id
,
"4b825dc642cb6eb9a060e54bf8d69288fbee4904"
));
cl_git_pass
(
git_repository_odb
(
&
odb
,
g_repo
));
cl_git_pass
(
git_odb_read
(
&
tree_odb
,
odb
,
&
id
));
cl_assert
(
git_odb_object_data
(
tree_odb
));
cl_assert_equal_s
(
""
,
git_odb_object_data
(
tree_odb
));
cl_assert_equal_i
(
0
,
git_odb_object_size
(
tree_odb
));
git_odb_object_free
(
tree_odb
);
git_odb_free
(
odb
);
}
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