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
579d87c5
Commit
579d87c5
authored
Aug 16, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New test that inits repo and make commit
parent
ce23330f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
tests-clar/repo/init.c
+49
-0
No files found.
tests-clar/repo/init.c
View file @
579d87c5
...
...
@@ -530,3 +530,52 @@ void test_repo_init__can_reinit_an_initialized_repository(void)
git_repository_free
(
reinit
);
}
void
test_repo_init__init_with_initial_commit
(
void
)
{
git_index
*
index
;
cl_set_cleanup
(
&
cleanup_repository
,
"committed"
);
/* Initialize the repository */
cl_git_pass
(
git_repository_init
(
&
_repo
,
"committed"
,
0
));
/* Init will be automatically created when requested for a new repo */
cl_git_pass
(
git_repository_index
(
&
index
,
_repo
));
/* Create a file so we can commit it
*
* If you are writing code outside the test suite, you can create this
* file any way that you like, such as:
* FILE *fp = fopen("committed/file.txt", "w");
* fputs("some stuff\n", fp);
* fclose(fp);
* We like to use the help functions because they do error detection
* in a way that's easily compatible with our test suite.
*/
cl_git_mkfile
(
"committed/file.txt"
,
"some stuff
\n
"
);
/* Add file to the index */
cl_git_pass
(
git_index_add_bypath
(
index
,
"file.txt"
));
cl_git_pass
(
git_index_write
(
index
));
/* Create a commit with the new contents of the index */
{
git_signature
*
sig
;
git_oid
tree_id
,
commit_id
;
git_tree
*
tree
;
cl_git_pass
(
git_signature_default
(
&
sig
,
_repo
));
cl_git_pass
(
git_index_write_tree
(
&
tree_id
,
index
));
cl_git_pass
(
git_tree_lookup
(
&
tree
,
_repo
,
&
tree_id
));
cl_git_pass
(
git_commit_create_v
(
&
commit_id
,
_repo
,
"HEAD"
,
sig
,
sig
,
NULL
,
"First"
,
tree
,
0
));
git_tree_free
(
tree
);
git_signature_free
(
sig
);
}
git_index_free
(
index
);
}
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