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
80642656
Commit
80642656
authored
Oct 16, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert checkout_* to use progress callback
parent
2c8bbb27
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
16 deletions
+27
-16
include/git2/checkout.h
+2
-7
src/checkout.c
+3
-5
src/clone.c
+1
-1
tests-clar/checkout/tree.c
+21
-3
No files found.
include/git2/checkout.h
View file @
80642656
...
...
@@ -86,22 +86,19 @@ typedef struct git_checkout_opts {
*
* @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be NULL)
* @param stats structure through which progress information is reported
* @return 0 on success, GIT_EORPHANEDHEAD when HEAD points to a non existing
* branch, GIT_ERROR otherwise (use giterr_last for information
* about the error)
*/
GIT_EXTERN
(
int
)
git_checkout_head
(
git_repository
*
repo
,
git_checkout_opts
*
opts
,
git_indexer_stats
*
stats
);
git_checkout_opts
*
opts
);
/**
* Updates files in the working tree to match the content of the index.
*
* @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be NULL)
* @param stats structure through which progress information is reported
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
* about the error)
*/
...
...
@@ -117,15 +114,13 @@ GIT_EXTERN(int) git_checkout_index(
* @param treeish a commit, tag or tree which content will be used to update
* the working directory
* @param opts specifies checkout options (may be NULL)
* @param stats structure through which progress information is reported
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
* about the error)
*/
GIT_EXTERN
(
int
)
git_checkout_tree
(
git_repository
*
repo
,
git_object
*
treeish
,
git_checkout_opts
*
opts
,
git_indexer_stats
*
stats
);
git_checkout_opts
*
opts
);
/** @} */
GIT_END_DECL
...
...
src/checkout.c
View file @
80642656
...
...
@@ -387,8 +387,7 @@ cleanup:
int
git_checkout_tree
(
git_repository
*
repo
,
git_object
*
treeish
,
git_checkout_opts
*
opts
,
git_indexer_stats
*
stats
)
git_checkout_opts
*
opts
)
{
git_index
*
index
=
NULL
;
git_tree
*
tree
=
NULL
;
...
...
@@ -421,8 +420,7 @@ cleanup:
int
git_checkout_head
(
git_repository
*
repo
,
git_checkout_opts
*
opts
,
git_indexer_stats
*
stats
)
git_checkout_opts
*
opts
)
{
git_reference
*
head
;
int
error
;
...
...
@@ -436,7 +434,7 @@ int git_checkout_head(
if
((
error
=
git_reference_peel
(
&
tree
,
head
,
GIT_OBJ_TREE
))
<
0
)
goto
cleanup
;
error
=
git_checkout_tree
(
repo
,
tree
,
opts
,
stats
);
error
=
git_checkout_tree
(
repo
,
tree
,
opts
);
cleanup:
git_reference_free
(
head
);
...
...
src/clone.c
View file @
80642656
...
...
@@ -333,7 +333,7 @@ static int clone_internal(
}
if
(
!
retcode
&&
should_checkout
(
repo
,
is_bare
,
checkout_opts
))
retcode
=
git_checkout_head
(
*
out
,
checkout_opts
,
checkout_stats
);
retcode
=
git_checkout_head
(
*
out
,
checkout_opts
);
return
retcode
;
}
...
...
tests-clar/checkout/tree.c
View file @
80642656
...
...
@@ -27,7 +27,7 @@ void test_checkout_tree__cannot_checkout_a_non_treeish(void)
/* blob */
cl_git_pass
(
git_revparse_single
(
&
g_object
,
g_repo
,
"a71586c1dfe8a71c6cbf6c129f404c5642ff31bd"
));
cl_git_fail
(
git_checkout_tree
(
g_repo
,
g_object
,
NULL
,
NULL
));
cl_git_fail
(
git_checkout_tree
(
g_repo
,
g_object
,
NULL
));
}
void
test_checkout_tree__can_checkout_a_subdirectory_from_a_commit
(
void
)
...
...
@@ -41,7 +41,7 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void)
cl_assert_equal_i
(
false
,
git_path_isdir
(
"./testrepo/ab/"
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
,
NULL
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/ab/de/2.txt"
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/ab/de/fgh/1.txt"
));
...
...
@@ -58,8 +58,26 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree(void)
cl_assert_equal_i
(
false
,
git_path_isdir
(
"./testrepo/de/"
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
,
NULL
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/de/2.txt"
));
cl_assert_equal_i
(
true
,
git_path_isfile
(
"./testrepo/de/fgh/1.txt"
));
}
static
void
progress
(
const
char
*
path
,
float
progress
,
void
*
payload
)
{
GIT_UNUSED
(
path
);
GIT_UNUSED
(
progress
);
int
*
count
=
(
int
*
)
payload
;
(
*
count
)
++
;
}
void
test_checkout_tree__calls_progress_callback
(
void
)
{
int
count
=
0
;
g_opts
.
progress_cb
=
progress
;
g_opts
.
progress_payload
=
&
count
;
cl_git_pass
(
git_revparse_single
(
&
g_object
,
g_repo
,
"master"
));
cl_git_pass
(
git_checkout_tree
(
g_repo
,
g_object
,
&
g_opts
));
cl_assert_equal_i
(
count
,
4
);
}
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