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
329eee33
Commit
329eee33
authored
Feb 01, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1286 from lznuaa/master
Fix clone fail if repo head detached
parents
7c32a0b5
aa928de0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
src/clone.c
+4
-2
tests-clar/clone/nonetwork.c
+24
-0
No files found.
src/clone.c
View file @
329eee33
...
...
@@ -250,8 +250,10 @@ static int update_head_to_remote(git_repository *repo, git_remote *remote)
goto
cleanup
;
}
else
{
/* TODO: What should we do if nothing has been found?
*/
retcode
=
git_repository_set_head_detached
(
repo
,
&
head_info
.
remote_head_oid
);
goto
cleanup
;
}
cleanup:
...
...
tests-clar/clone/nonetwork.c
View file @
329eee33
...
...
@@ -175,3 +175,27 @@ void test_clone_nonetwork__can_checkout_given_branch(void)
cl_assert_equal_s
(
git_reference_name
(
g_ref
),
"refs/heads/test"
);
}
void
test_clone_nonetwork__can_detached_head
(
void
)
{
git_object
*
commit
;
git_repository
*
cloned
;
git_reference
*
cloned_head
;
cl_git_pass
(
git_clone
(
&
g_repo
,
cl_git_fixture_url
(
"testrepo.git"
),
"./foo"
,
&
g_options
));
cl_git_pass
(
git_revparse_single
(
&
commit
,
g_repo
,
"master~1"
));
cl_git_pass
(
git_repository_set_head_detached
(
g_repo
,
git_object_id
(
commit
)));
cl_git_pass
(
git_clone
(
&
cloned
,
"./foo"
,
"./foo1"
,
&
g_options
));
cl_assert
(
git_repository_head_detached
(
cloned
));
cl_git_pass
(
git_repository_head
(
&
cloned_head
,
cloned
));
cl_assert
(
!
git_oid_cmp
(
git_object_id
(
commit
),
git_reference_target
(
cloned_head
)));
git_commit_free
((
git_commit
*
)
commit
);
git_reference_free
(
cloned_head
);
git_repository_free
(
cloned
);
cl_fixture_cleanup
(
"./foo1"
);
}
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