本文整理汇总了C++中cl_git_mkfile函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_git_mkfile函数的具体用法?C++ cl_git_mkfile怎么用?C++ cl_git_mkfile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_git_mkfile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_checkout_crlf__autocrlf_input_text_auto_attr
void test_checkout_crlf__autocrlf_input_text_auto_attr(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_mkfile("./crlf/.gitattributes", "* text=auto\n");
cl_repo_set_string(g_repo, "core.autocrlf", "input");
git_checkout_head(g_repo, &opts);
check_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW);
check_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW);
}
示例2: test_stash_apply__uses_reflog_like_indices_2
void test_stash_apply__uses_reflog_like_indices_2(void)
{
git_oid oid;
cl_git_mkfile("stash/untracked", "untracked\n");
cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED));
assert_status(repo, "untracked", GIT_ENOTFOUND);
// [email protected]{0} is the newest stash we made immediately above
cl_git_pass(git_stash_apply(repo, 0, NULL));
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "untracked", GIT_STATUS_WT_NEW);
}
示例3: test_stash_save__skip_submodules
void test_stash_save__skip_submodules(void)
{
git_repository *untracked_repo;
cl_git_pass(git_repository_init(&untracked_repo, "stash/untracked_repo", false));
cl_git_mkfile("stash/untracked_repo/content", "stuff");
git_repository_free(untracked_repo);
assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW);
cl_git_pass(git_stash_save(
&stash_tip_oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED));
assert_status(repo, "untracked_repo/", GIT_STATUS_WT_NEW);
}
示例4: test_config_read__lone_variable_with_trailing_whitespace
void test_config_read__lone_variable_with_trailing_whitespace(void)
{
git_config *cfg;
int b;
cl_set_cleanup(&clean_test_config, NULL);
cl_git_mkfile("./testconfig", "[foo]\n lonevariable \n");
cl_git_pass(git_config_open_ondisk(&cfg, "./testconfig"));
cl_git_pass(git_config_get_bool(&b, cfg, "foo.lonevariable"));
cl_assert_equal_b(true, b);
git_config_free(cfg);
}
示例5: test_stash_apply__conflict_untracked_with_default
void test_stash_apply__conflict_untracked_with_default(void)
{
git_stash_apply_options opts = GIT_STASH_APPLY_OPTIONS_INIT;
cl_git_mkfile("stash/when", "nothing\n");
cl_git_fail_with(git_stash_apply(repo, 0, &opts), GIT_ECONFLICT);
cl_assert_equal_i(git_index_has_conflicts(repo_index), 0);
assert_status(repo, "what", GIT_STATUS_CURRENT);
assert_status(repo, "how", GIT_STATUS_CURRENT);
assert_status(repo, "who", GIT_STATUS_CURRENT);
assert_status(repo, "when", GIT_STATUS_WT_NEW);
}
示例6: test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension
void test_refs_list__do_not_retrieve_references_which_name_end_with_a_lock_extension(void)
{
git_strarray ref_list;
/* Create a fake locked reference */
cl_git_mkfile(
"./testrepo/.git/refs/heads/hanwen.lock",
"144344043ba4d4a405da03de3844aa829ae8be0e\n");
cl_git_pass(git_reference_list(&ref_list, g_repo));
cl_assert_equal_i((int)ref_list.count, 15);
git_strarray_free(&ref_list);
}
示例7: make_test_data
static void make_test_data(const char *reponame, const char **files)
{
const char **scan;
size_t repolen = strlen(reponame) + 1;
g_repo = cl_git_sandbox_init(reponame);
for (scan = files; *scan != NULL; ++scan) {
cl_git_pass(git_futils_mkdir(
*scan + repolen, reponame,
0777, GIT_MKDIR_PATH | GIT_MKDIR_SKIP_LAST));
cl_git_mkfile(*scan, "contents");
}
}
示例8: test_checkout_index__options_open_flags
void test_checkout_index__options_open_flags(void)
{
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
cl_git_mkfile("./testrepo/new.txt", "hi\n");
opts.checkout_strategy =
GIT_CHECKOUT_FORCE | GIT_CHECKOUT_DONT_REMOVE_EXISTING;
opts.file_open_flags = O_CREAT | O_RDWR | O_APPEND;
cl_git_pass(git_checkout_index(g_repo, NULL, &opts));
check_file_contents("./testrepo/new.txt", "hi\nmy new file\n");
}
示例9: test_apply_both__honors_crlf_attributes
void test_apply_both__honors_crlf_attributes(void)
{
git_diff *diff;
git_oid oid;
git_commit *commit;
const char *diff_file = DIFF_MODIFY_TWO_FILES;
struct merge_index_entry index_expected[] = {
{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
{ 0100644, "a7b066537e6be7109abfe4ff97b675d4e077da20", 0, "veal.txt" },
};
size_t index_expected_cnt = sizeof(index_expected) /
sizeof(struct merge_index_entry);
struct merge_index_entry workdir_expected[] = {
{ 0100644, "176a458f94e0ea5272ce67c36bf30b6be9caf623", 0, ".gitattributes" },
{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
{ 0100644, "a7b066537e6be7109abfe4ff97b675d4e077da20", 0, "veal.txt" },
};
size_t workdir_expected_cnt = sizeof(workdir_expected) /
sizeof(struct merge_index_entry);
cl_git_mkfile("merge-recursive/.gitattributes", "* text=auto\n");
cl_git_rmfile("merge-recursive/asparagus.txt");
cl_git_rmfile("merge-recursive/veal.txt");
git_oid_fromstr(&oid, "539bd011c4822c560c1d17cab095006b7a10f707");
cl_git_pass(git_commit_lookup(&commit, repo, &oid));
cl_git_pass(git_reset(repo, (git_object *)commit, GIT_RESET_HARD, NULL));
git_commit_free(commit);
cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file)));
cl_git_pass(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));
validate_apply_index(repo, index_expected, index_expected_cnt);
validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt);
git_diff_free(diff);
}
示例10: test_checkout_index__honor_the_gitattributes_directives
void test_checkout_index__honor_the_gitattributes_directives(void)
{
const char *attributes =
"branch_file.txt text eol=crlf\n"
"new.txt text eol=lf\n";
cl_git_mkfile("./testrepo/.gitattributes", attributes);
set_core_autocrlf_to(false);
cl_git_pass(git_checkout_index(g_repo, &g_opts));
test_file_contents("./testrepo/README", "hey there\n");
test_file_contents("./testrepo/new.txt", "my new file\n");
test_file_contents("./testrepo/branch_file.txt", "hi\r\nbye!\r\n");
}
示例11: test_reset_soft__fails_when_merging
void test_reset_soft__fails_when_merging(void)
{
git_buf merge_head_path = GIT_BUF_INIT;
cl_git_pass(git_repository_detach_head(repo));
cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
retrieve_target_from_oid(&target, repo, KNOWN_COMMIT_IN_BARE_REPO);
cl_assert_equal_i(GIT_EUNMERGED, git_reset(repo, target, GIT_RESET_SOFT));
cl_git_pass(p_unlink(git_buf_cstr(&merge_head_path)));
git_buf_free(&merge_head_path);
}
示例12: build_workdir_tree
static void build_workdir_tree(const char *root, int dirs, int subs)
{
int i, j;
char buf[64], sub[80];
for (i = 0; i < dirs; ++i) {
if (i % 2 == 0) {
p_snprintf(buf, sizeof(buf), "%s/dir%02d", root, i);
cl_git_pass(git_futils_mkdir(buf, 0775, GIT_MKDIR_PATH));
p_snprintf(buf, sizeof(buf), "%s/dir%02d/file", root, i);
cl_git_mkfile(buf, buf);
buf[strlen(buf) - 5] = '\0';
} else {
p_snprintf(buf, sizeof(buf), "%s/DIR%02d", root, i);
cl_git_pass(git_futils_mkdir(buf, 0775, GIT_MKDIR_PATH));
}
for (j = 0; j < subs; ++j) {
switch (j % 4) {
case 0: p_snprintf(sub, sizeof(sub), "%s/sub%02d", buf, j); break;
case 1: p_snprintf(sub, sizeof(sub), "%s/sUB%02d", buf, j); break;
case 2: p_snprintf(sub, sizeof(sub), "%s/Sub%02d", buf, j); break;
case 3: p_snprintf(sub, sizeof(sub), "%s/SUB%02d", buf, j); break;
}
cl_git_pass(git_futils_mkdir(sub, 0775, GIT_MKDIR_PATH));
if (j % 2 == 0) {
size_t sublen = strlen(sub);
memcpy(&sub[sublen], "/file", sizeof("/file"));
cl_git_mkfile(sub, sub);
sub[sublen] = '\0';
}
}
}
}
示例13: test_core_rmdir__fail_to_delete_non_empty_dir
/* make sure non-empty dir cannot be deleted recusively */
void test_core_rmdir__fail_to_delete_non_empty_dir(void)
{
git_buf file = GIT_BUF_INIT;
cl_git_pass(git_buf_joinpath(&file, empty_tmp_dir, "/two/file.txt"));
cl_git_mkfile(git_buf_cstr(&file), "dummy");
cl_git_fail(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
cl_must_pass(p_unlink(file.ptr));
cl_git_pass(git_futils_rmdir_r(empty_tmp_dir, NULL, GIT_RMDIR_EMPTY_HIERARCHY));
git_buf_dispose(&file);
}
示例14: test_core_filebuf__1
/* make sure GIT_FILEBUF_APPEND works as expected */
void test_core_filebuf__1(void)
{
git_filebuf file = GIT_FILEBUF_INIT;
char test[] = "test";
cl_git_mkfile(test, "libgit2 rocks\n");
cl_git_pass(git_filebuf_open(&file, test, GIT_FILEBUF_APPEND, 0666));
cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
cl_git_pass(git_filebuf_commit(&file));
cl_assert_equal_file("libgit2 rocks\nlibgit2 rocks\n", 0, test);
cl_must_pass(p_unlink(test));
}
示例15: test_filter_query__initialize
void test_filter_query__initialize(void)
{
g_repo = cl_git_sandbox_init("crlf");
cl_git_mkfile("crlf/.gitattributes",
"*.txt text\n"
"*.bin binary\n"
"*.crlf text eol=crlf\n"
"*.lf text eol=lf\n"
"*.binident binary ident\n"
"*.ident text ident\n"
"*.identcrlf ident text eol=crlf\n"
"*.identlf ident text eol=lf\n"
"*.custom custom ident text\n");
}