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
dde61de6
Commit
dde61de6
authored
Mar 30, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed linux build/test issues.
parent
6bb74993
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
4 deletions
+70
-4
tests-clar/object/tree/write.c
+70
-4
No files found.
tests-clar/object/tree/write.c
View file @
dde61de6
...
...
@@ -39,6 +39,70 @@ static int print_tree(git_repository *repo, const git_oid *tree_oid, int depth)
return
GIT_SUCCESS
;
}
static
void
locate_loose_object
(
const
char
*
repository_folder
,
git_object
*
object
,
char
**
out
,
char
**
out_folder
)
{
static
const
char
*
objects_folder
=
"objects/"
;
char
*
ptr
,
*
full_path
,
*
top_folder
;
int
path_length
,
objects_length
;
assert
(
repository_folder
&&
object
);
objects_length
=
strlen
(
objects_folder
);
path_length
=
strlen
(
repository_folder
);
ptr
=
full_path
=
git__malloc
(
path_length
+
objects_length
+
GIT_OID_HEXSZ
+
3
);
strcpy
(
ptr
,
repository_folder
);
strcpy
(
ptr
+
path_length
,
objects_folder
);
ptr
=
top_folder
=
ptr
+
path_length
+
objects_length
;
*
ptr
++
=
'/'
;
git_oid_pathfmt
(
ptr
,
git_object_id
(
object
));
ptr
+=
GIT_OID_HEXSZ
+
1
;
*
ptr
=
0
;
*
out
=
full_path
;
if
(
out_folder
)
*
out_folder
=
top_folder
;
}
static
int
loose_object_mode
(
const
char
*
repository_folder
,
git_object
*
object
)
{
char
*
object_path
;
struct
stat
st
;
locate_loose_object
(
repository_folder
,
object
,
&
object_path
,
NULL
);
if
(
p_stat
(
object_path
,
&
st
)
<
0
)
return
0
;
free
(
object_path
);
return
st
.
st_mode
;
}
static
int
loose_object_dir_mode
(
const
char
*
repository_folder
,
git_object
*
object
)
{
char
*
object_path
;
size_t
pos
;
struct
stat
st
;
locate_loose_object
(
repository_folder
,
object
,
&
object_path
,
NULL
);
pos
=
strlen
(
object_path
);
while
(
pos
--
)
{
if
(
object_path
[
pos
]
==
'/'
)
{
object_path
[
pos
]
=
0
;
break
;
}
}
if
(
p_stat
(
object_path
,
&
st
)
<
0
)
return
0
;
free
(
object_path
);
return
st
.
st_mode
;
}
// Fixture setup and teardown
void
test_object_tree_write__initialize
(
void
)
...
...
@@ -52,8 +116,8 @@ void test_object_tree_write__cleanup(void)
}
void
_
test_object_tree_write__print
(
void
)
#if 0
void
x
test_object_tree_write__print(void)
{
// write a tree from an index
git_index *index;
...
...
@@ -64,6 +128,7 @@ void _test_object_tree_write__print(void)
cl_git_pass(git_tree_create_fromindex(&tree_oid, index));
cl_git_pass(print_tree(g_repo, &tree_oid, 0));
}
#endif
void
test_object_tree_write__from_memory
(
void
)
{
...
...
@@ -126,8 +191,9 @@ void test_object_tree_write__subtree(void)
cl_git_pass
(
git_tree_lookup
(
&
tree
,
g_repo
,
&
id_hiearar
));
cl_assert
(
2
==
git_tree_entrycount
(
tree
));
#ifndef GIT_WIN32
cl_assert
((
loose_object_dir_mode
(
TEMP_REPO_FOLDER
,
(
git_object
*
)
tree
)
&
0777
)
==
GIT_OBJECT_DIR_MODE
);
cl_assert
((
loose_object_mode
(
TEMP_REPO_FOLDER
,
(
git_object
*
)
tree
)
&
0777
)
==
GIT_OBJECT_FILE_MODE
);
// TODO: fix these
//cl_assert((loose_object_dir_mode("testrepo", (git_object *)tree) & 0777) == GIT_OBJECT_DIR_MODE);
//cl_assert((loose_object_mode("testrespo", (git_object *)tree) & 0777) == GIT_OBJECT_FILE_MODE);
#endif
git_tree_free
(
tree
);
}
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