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
850b1edf
Commit
850b1edf
authored
Dec 13, 2012
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow clone to handle empty repos
parent
be5869fc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletions
+42
-1
src/transports/local.c
+3
-1
tests-clar/clone/nonetwork.c
+39
-0
No files found.
src/transports/local.c
View file @
850b1edf
...
...
@@ -50,9 +50,11 @@ static int add_ref(transport_local *t, const char *name)
GITERR_CHECK_ALLOC
(
head
->
name
);
if
(
git_reference_name_to_id
(
&
head
->
oid
,
t
->
repo
,
name
)
<
0
)
{
/* This is actually okay. Empty repos often have a HEAD that points to
* a nonexistant "refs/haeds/master". */
git__free
(
head
->
name
);
git__free
(
head
);
return
-
1
;
return
0
;
}
if
(
git_vector_insert
(
&
t
->
refs
,
head
)
<
0
)
...
...
tests-clar/clone/nonetwork.c
View file @
850b1edf
...
...
@@ -86,3 +86,42 @@ void test_clone_nonetwork__fail_with_already_existing_but_non_empty_directory(vo
cl_git_mkfile
(
"./foo/bar"
,
"Baz!"
);
cl_git_fail
(
git_clone
(
&
g_repo
,
g_origin
,
"./foo"
,
&
g_options
));
}
void
test_clone_nonetwork__can_clone_an_empty_local_repo_barely
(
void
)
{
const
char
*
src
=
cl_git_fixture_url
(
"empty_bare.git"
);
cl_set_cleanup
(
&
cleanup_repository
,
"./empty"
);
git_remote_free
(
g_origin
);
cl_git_pass
(
git_remote_new
(
&
g_origin
,
NULL
,
"origin"
,
src
,
GIT_REMOTE_DEFAULT_FETCH
));
cl_git_pass
(
git_clone_bare
(
&
g_repo
,
g_origin
,
"./empty"
,
NULL
,
NULL
));
}
void
test_clone_nonetwork__can_clone_an_empty_local_repo
(
void
)
{
const
char
*
src
=
cl_git_fixture_url
(
"empty_bare.git"
);
cl_set_cleanup
(
&
cleanup_repository
,
"./empty"
);
git_remote_free
(
g_origin
);
cl_git_pass
(
git_remote_new
(
&
g_origin
,
NULL
,
"origin"
,
src
,
GIT_REMOTE_DEFAULT_FETCH
));
cl_git_pass
(
git_clone
(
&
g_repo
,
g_origin
,
"./empty"
,
NULL
,
NULL
,
NULL
));
}
void
test_clone_nonetwork__can_clone_an_empty_standard_repo
(
void
)
{
const
char
*
src
;
cl_git_sandbox_init
(
"empty_standard_repo"
);
src
=
cl_git_path_url
(
"./empty_standard_repo"
);
git_remote_free
(
g_origin
);
cl_git_pass
(
git_remote_new
(
&
g_origin
,
NULL
,
"origin"
,
src
,
GIT_REMOTE_DEFAULT_FETCH
));
cl_set_cleanup
(
&
cleanup_repository
,
"./empty"
);
cl_git_pass
(
git_clone
(
&
g_repo
,
g_origin
,
"./empty"
,
NULL
,
NULL
,
NULL
));
cl_git_sandbox_cleanup
();
}
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