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
44acdd1f
Commit
44acdd1f
authored
Nov 04, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1937 from scunz/checkout_assert
Don't assert in git_checkout_tree
parents
5a0b8803
7b3959b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
22 deletions
+21
-22
include/git2/checkout.h
+3
-3
src/checkout.c
+18
-19
No files found.
include/git2/checkout.h
View file @
44acdd1f
...
...
@@ -272,7 +272,7 @@ GIT_EXTERN(int) git_checkout_head(
GIT_EXTERN
(
int
)
git_checkout_index
(
git_repository
*
repo
,
git_index
*
index
,
git_checkout_opts
*
opts
);
const
git_checkout_opts
*
opts
);
/**
* Updates files in the index and working tree to match the content of the
...
...
@@ -280,7 +280,7 @@ GIT_EXTERN(int) git_checkout_index(
*
* @param repo repository to check out (must be non-bare)
* @param treeish a commit, tag or tree which content will be used to update
* the working directory
* the working directory
(or NULL to use HEAD)
* @param opts specifies checkout options (may be NULL)
* @return 0 on success, GIT_ERROR otherwise (use giterr_last for information
* about the error)
...
...
@@ -288,7 +288,7 @@ GIT_EXTERN(int) git_checkout_index(
GIT_EXTERN
(
int
)
git_checkout_tree
(
git_repository
*
repo
,
const
git_object
*
treeish
,
git_checkout_opts
*
opts
);
const
git_checkout_opts
*
opts
);
/** @} */
GIT_END_DECL
...
...
src/checkout.c
View file @
44acdd1f
...
...
@@ -2018,7 +2018,7 @@ cleanup:
int
git_checkout_index
(
git_repository
*
repo
,
git_index
*
index
,
git_checkout_opts
*
opts
)
const
git_checkout_opts
*
opts
)
{
int
error
;
git_iterator
*
index_i
;
...
...
@@ -2053,7 +2053,7 @@ int git_checkout_index(
int
git_checkout_tree
(
git_repository
*
repo
,
const
git_object
*
treeish
,
git_checkout_opts
*
opts
)
const
git_checkout_opts
*
opts
)
{
int
error
;
git_tree
*
tree
=
NULL
;
...
...
@@ -2073,10 +2073,21 @@ int git_checkout_tree(
if
(
!
repo
)
repo
=
git_object_owner
(
treeish
);
if
(
git_object_peel
((
git_object
**
)
&
tree
,
treeish
,
GIT_OBJ_TREE
)
<
0
)
{
giterr_set
(
GITERR_CHECKOUT
,
"Provided object cannot be peeled to a tree"
);
return
-
1
;
if
(
treeish
)
{
if
(
git_object_peel
((
git_object
**
)
&
tree
,
treeish
,
GIT_OBJ_TREE
)
<
0
)
{
giterr_set
(
GITERR_CHECKOUT
,
"Provided object cannot be peeled to a tree"
);
return
-
1
;
}
}
else
{
if
((
error
=
checkout_lookup_head_tree
(
&
tree
,
repo
))
<
0
)
{
if
(
error
!=
GIT_EUNBORNBRANCH
)
giterr_set
(
GITERR_CHECKOUT
,
"HEAD could not be peeled to a tree and no treeish given"
);
return
error
;
}
}
if
(
!
(
error
=
git_iterator_for_tree
(
&
tree_i
,
tree
,
0
,
NULL
,
NULL
)))
...
...
@@ -2092,18 +2103,6 @@ int git_checkout_head(
git_repository
*
repo
,
const
git_checkout_opts
*
opts
)
{
int
error
;
git_tree
*
head
=
NULL
;
git_iterator
*
head_i
=
NULL
;
assert
(
repo
);
if
(
!
(
error
=
checkout_lookup_head_tree
(
&
head
,
repo
))
&&
!
(
error
=
git_iterator_for_tree
(
&
head_i
,
head
,
0
,
NULL
,
NULL
)))
error
=
git_checkout_iterator
(
head_i
,
opts
);
git_iterator_free
(
head_i
);
git_tree_free
(
head
);
return
error
;
return
git_checkout_tree
(
repo
,
NULL
,
opts
);
}
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