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
92249656
Commit
92249656
authored
May 19, 2016
by
Carlos Martín Nieto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: use testrepo2 for the tree updater tests
This gives us trees with subdirectories, which the new test needs.
parent
1b56cda1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
8 deletions
+37
-8
tests/object/tree/update.c
+37
-8
No files found.
tests/object/tree/update.c
View file @
92249656
...
...
@@ -5,7 +5,7 @@ static git_repository *g_repo;
void
test_object_tree_update__initialize
(
void
)
{
g_repo
=
cl_git_sandbox_init
(
"testrepo"
);
g_repo
=
cl_git_sandbox_init
(
"testrepo
2
"
);
}
void
test_object_tree_update__cleanup
(
void
)
...
...
@@ -24,7 +24,36 @@ void test_object_tree_update__remove_blob(void)
{
GIT_TREE_UPDATE_REMOVE
,
{{
0
}},
GIT_FILEMODE_BLOB
/* ignored */
,
path
},
};
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"45dd856fdd4d89b884c340ba0e047752d9b085d6"
));
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"
));
cl_git_pass
(
git_tree_lookup
(
&
base_tree
,
g_repo
,
&
base_id
));
/* Create it with an index */
cl_git_pass
(
git_index_new
(
&
idx
));
cl_git_pass
(
git_index_read_tree
(
idx
,
base_tree
));
cl_git_pass
(
git_index_remove
(
idx
,
path
,
0
));
cl_git_pass
(
git_index_write_tree_to
(
&
tree_index_id
,
idx
,
g_repo
));
git_index_free
(
idx
);
/* Perform the same operation via the tree updater */
cl_git_pass
(
git_tree_create_updated
(
&
tree_updater_id
,
g_repo
,
base_tree
,
1
,
updates
));
cl_assert_equal_oid
(
&
tree_index_id
,
&
tree_updater_id
);
git_tree_free
(
base_tree
);
}
void
test_object_tree_update__remove_blob_deeper
(
void
)
{
git_oid
tree_index_id
,
tree_updater_id
,
base_id
;
git_tree
*
base_tree
;
git_index
*
idx
;
const
char
*
path
=
"subdir/README"
;
git_tree_update
updates
[]
=
{
{
GIT_TREE_UPDATE_REMOVE
,
{{
0
}},
GIT_FILEMODE_BLOB
/* ignored */
,
path
},
};
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"
));
cl_git_pass
(
git_tree_lookup
(
&
base_tree
,
g_repo
,
&
base_id
));
/* Create it with an index */
...
...
@@ -54,7 +83,7 @@ void test_object_tree_update__replace_blob(void)
{
GIT_TREE_UPDATE_UPSERT
,
{{
0
}},
GIT_FILEMODE_BLOB
,
path
},
};
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"
45dd856fdd4d89b884c340ba0e047752d9b085d6
"
));
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"
c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b
"
));
cl_git_pass
(
git_tree_lookup
(
&
base_tree
,
g_repo
,
&
base_id
));
/* Create it with an index */
...
...
@@ -62,7 +91,7 @@ void test_object_tree_update__replace_blob(void)
cl_git_pass
(
git_index_read_tree
(
idx
,
base_tree
));
entry
.
path
=
path
;
cl_git_pass
(
git_oid_fromstr
(
&
entry
.
id
,
"
3697d64be941a53d4ae8f6a271e4e3fa56b022cc
"
));
cl_git_pass
(
git_oid_fromstr
(
&
entry
.
id
,
"
fa49b077972391ad58037050f2a75f74e3671e92
"
));
entry
.
mode
=
GIT_FILEMODE_BLOB
;
cl_git_pass
(
git_index_add
(
idx
,
&
entry
));
...
...
@@ -70,7 +99,7 @@ void test_object_tree_update__replace_blob(void)
git_index_free
(
idx
);
/* Perform the same operation via the tree updater */
cl_git_pass
(
git_oid_fromstr
(
&
updates
[
0
].
id
,
"
3697d64be941a53d4ae8f6a271e4e3fa56b022cc
"
));
cl_git_pass
(
git_oid_fromstr
(
&
updates
[
0
].
id
,
"
fa49b077972391ad58037050f2a75f74e3671e92
"
));
cl_git_pass
(
git_tree_create_updated
(
&
tree_updater_id
,
g_repo
,
base_tree
,
1
,
updates
));
cl_assert_equal_oid
(
&
tree_index_id
,
&
tree_updater_id
);
...
...
@@ -97,14 +126,14 @@ void test_object_tree_update__add_blobs(void)
{
GIT_TREE_UPDATE_UPSERT
,
{{
0
}},
GIT_FILEMODE_BLOB
,
paths
[
2
]},
};
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"
45dd856fdd4d89b884c340ba0e047752d9b085d6
"
));
cl_git_pass
(
git_oid_fromstr
(
&
base_id
,
"
c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b
"
));
cl_git_pass
(
git_tree_lookup
(
&
base_tree
,
g_repo
,
&
base_id
));
entry
.
mode
=
GIT_FILEMODE_BLOB
;
cl_git_pass
(
git_oid_fromstr
(
&
entry
.
id
,
"
a71586c1dfe8a71c6cbf6c129f404c5642ff31bd
"
));
cl_git_pass
(
git_oid_fromstr
(
&
entry
.
id
,
"
fa49b077972391ad58037050f2a75f74e3671e92
"
));
for
(
i
=
0
;
i
<
3
;
i
++
)
{
cl_git_pass
(
git_oid_fromstr
(
&
updates
[
i
].
id
,
"
a71586c1dfe8a71c6cbf6c129f404c5642ff31bd
"
));
cl_git_pass
(
git_oid_fromstr
(
&
updates
[
i
].
id
,
"
fa49b077972391ad58037050f2a75f74e3671e92
"
));
}
for
(
i
=
0
;
i
<
2
;
i
++
)
{
...
...
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