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
6cd92193
Commit
6cd92193
authored
May 13, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3115 from libgit2/cmn/clone-submodule
submodule: add test initialising and cloning a repo
parents
a3ff28e9
1e44ea97
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
tests/clone/nonetwork.c
+55
-0
No files found.
tests/clone/nonetwork.c
View file @
6cd92193
#include "clar_libgit2.h"
#include "clar_libgit2.h"
#include "git2/clone.h"
#include "git2/clone.h"
#include "git2/sys/commit.h"
#include "../submodule/submodule_helpers.h"
#include "remote.h"
#include "remote.h"
#include "fileops.h"
#include "fileops.h"
#include "repository.h"
#include "repository.h"
...
@@ -347,3 +349,56 @@ void test_clone_nonetwork__clone_from_empty_sets_upstream(void)
...
@@ -347,3 +349,56 @@ void test_clone_nonetwork__clone_from_empty_sets_upstream(void)
git_repository_free
(
repo
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"./repowithunborn"
);
cl_fixture_cleanup
(
"./repowithunborn"
);
}
}
static
int
just_return_origin
(
git_remote
**
out
,
git_repository
*
repo
,
const
char
*
name
,
const
char
*
url
,
void
*
payload
)
{
GIT_UNUSED
(
url
);
GIT_UNUSED
(
payload
);
return
git_remote_lookup
(
out
,
repo
,
name
);
}
static
int
just_return_repo
(
git_repository
**
out
,
const
char
*
path
,
int
bare
,
void
*
payload
)
{
git_submodule
*
sm
=
payload
;
GIT_UNUSED
(
path
);
GIT_UNUSED
(
bare
);
return
git_submodule_open
(
out
,
sm
);
}
void
test_clone_nonetwork__clone_submodule
(
void
)
{
git_clone_options
clone_opts
=
GIT_CLONE_OPTIONS_INIT
;
git_index
*
index
;
git_oid
tree_id
,
commit_id
;
git_submodule
*
sm
;
git_signature
*
sig
;
git_repository
*
sm_repo
;
cl_git_pass
(
git_repository_init
(
&
g_repo
,
"willaddsubmodule"
,
false
));
/* Create the submodule structure, clone into it and finalize */
cl_git_pass
(
git_submodule_add_setup
(
&
sm
,
g_repo
,
cl_fixture
(
"testrepo.git"
),
"testrepo"
,
true
));
clone_opts
.
repository_cb
=
just_return_repo
;
clone_opts
.
repository_cb_payload
=
sm
;
clone_opts
.
remote_cb
=
just_return_origin
;
clone_opts
.
remote_cb_payload
=
sm
;
cl_git_pass
(
git_clone
(
&
sm_repo
,
cl_fixture
(
"testrepo.git"
),
"testrepo"
,
&
clone_opts
));
cl_git_pass
(
git_submodule_add_finalize
(
sm
));
git_repository_free
(
sm_repo
);
git_submodule_free
(
sm
);
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
git_index_write_tree
(
&
tree_id
,
index
));
git_index_free
(
index
);
cl_git_pass
(
git_signature_now
(
&
sig
,
"Submoduler"
,
"submoduler@local"
));
cl_git_pass
(
git_commit_create_from_ids
(
&
commit_id
,
g_repo
,
"HEAD"
,
sig
,
sig
,
NULL
,
"A submodule
\n
"
,
&
tree_id
,
0
,
NULL
));
git_signature_free
(
sig
);
assert_submodule_exists
(
g_repo
,
"testrepo"
);
}
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