本文整理汇总了C++中cl_git_pass函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_git_pass函数的具体用法?C++ cl_git_pass怎么用?C++ cl_git_pass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_git_pass函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_stash_apply__pop
void test_stash_apply__pop(void)
{
cl_git_pass(git_stash_pop(repo, 0, NULL));
cl_git_fail_with(git_stash_pop(repo, 0, NULL), GIT_ENOTFOUND);
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:6,代码来源:apply.c
示例2: test_notes_notes__initialize
void test_notes_notes__initialize(void)
{
_repo = cl_git_sandbox_init("testrepo.git");
cl_git_pass(git_signature_now(&_sig, "alice", "[email protected]"));
}
开发者ID:Asquera,项目名称:libgit2,代码行数:5,代码来源:notes.c
示例3: test_network_remoterename__renaming_a_remote_updates_default_fetchrefspec
void test_network_remoterename__renaming_a_remote_updates_default_fetchrefspec(void)
{
cl_git_pass(git_remote_rename(_remote, "just/renamed", dont_call_me_cb, NULL));
assert_config_entry_value(_repo, "remote.just/renamed.fetch", "+refs/heads/*:refs/remotes/just/renamed/*");
}
开发者ID:ralpheav,项目名称:PM_GIT,代码行数:6,代码来源:remoterename.c
示例4: test_submodule_status__ignore_all
void test_submodule_status__ignore_all(void)
{
unsigned int status;
git_submodule *sm;
git_buf path = GIT_BUF_INIT;
git_submodule_ignore_t ign = GIT_SUBMODULE_IGNORE_ALL;
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(g_repo), "sm_unchanged"));
cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), NULL, GIT_RMDIR_REMOVE_FILES));
cl_git_pass(git_submodule_foreach(g_repo, set_sm_ignore, &ign));
cl_git_fail(git_submodule_lookup(&sm, g_repo, "not_submodule"));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_index"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_file"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_untracked_file"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
/* removed sm_unchanged for deleted workdir */
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
/* now mkdir sm_unchanged to test uninitialized */
cl_git_pass(git_futils_mkdir(git_buf_cstr(&path), NULL, 0755, 0));
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_unchanged"));
cl_git_pass(git_submodule_reload(sm));
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
/* update sm_changed_head in index */
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head"));
cl_git_pass(git_submodule_add_to_index(sm, true));
/* reload is not needed because add_to_index updates the submodule data */
cl_git_pass(git_submodule_status(&status, sm));
cl_assert(GIT_SUBMODULE_STATUS_IS_UNMODIFIED(status));
git_buf_free(&path);
}
开发者ID:duralog,项目名称:node-sencillo,代码行数:59,代码来源:status.c
示例5: test_config_write__replace_value
void test_config_write__replace_value(void)
{
git_config *cfg;
int i;
int64_t l, expected = +9223372036854775803;
/* By freeing the config, we make sure we flush the values */
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_int32(cfg, "core.dummy", 5));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_get_int32(&i, cfg, "core.dummy"));
cl_assert(i == 5);
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_int32(cfg, "core.dummy", 1));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_int64(cfg, "core.verylong", expected));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_get_int64(&l, cfg, "core.verylong"));
cl_assert(l == expected);
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_must_fail(git_config_get_int32(&i, cfg, "core.verylong"));
git_config_free(cfg);
cl_git_pass(git_config_open_ondisk(&cfg, "config9"));
cl_git_pass(git_config_set_int64(cfg, "core.verylong", 1));
git_config_free(cfg);
}
开发者ID:jmendeth,项目名称:node-gitteh,代码行数:37,代码来源:write.c
示例6: test_index_racy__initialize
void test_index_racy__initialize(void)
{
cl_git_pass(git_repository_init(&g_repo, "diff_racy", false));
}
开发者ID:ImadBouirmane,项目名称:libgit2,代码行数:4,代码来源:racy.c
示例7: test_core_buffer__similarity_metric_whitespace
void test_core_buffer__similarity_metric_whitespace(void)
{
git_hashsig *a, *b;
git_buf buf = GIT_BUF_INIT;
int sim, i, j;
git_hashsig_option_t opt;
const char *tabbed =
" for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
" separator = sep[s];\n"
" expect = expect_values[s];\n"
"\n"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
" git_buf_join(&buf, separator, a[i], b[j]);\n"
" cl_assert_equal_s(*expect, buf.ptr);\n"
" expect++;\n"
" }\n"
" }\n"
" }\n";
const char *spaced =
" for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\n"
" separator = sep[s];\n"
" expect = expect_values[s];\n"
"\n"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\n"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\n"
" git_buf_join(&buf, separator, a[i], b[j]);\n"
" cl_assert_equal_s(*expect, buf.ptr);\n"
" expect++;\n"
" }\n"
" }\n"
" }\n";
const char *crlf_spaced2 =
" for (s = 0; s < sizeof(sep) / sizeof(char); ++s) {\r\n"
" separator = sep[s];\r\n"
" expect = expect_values[s];\r\n"
"\r\n"
" for (j = 0; j < sizeof(b) / sizeof(char*); ++j) {\r\n"
" for (i = 0; i < sizeof(a) / sizeof(char*); ++i) {\r\n"
" git_buf_join(&buf, separator, a[i], b[j]);\r\n"
" cl_assert_equal_s(*expect, buf.ptr);\r\n"
" expect++;\r\n"
" }\r\n"
" }\r\n"
" }\r\n";
const char *text[3] = { tabbed, spaced, crlf_spaced2 };
/* let's try variations of our own code with whitespace changes */
for (opt = GIT_HASHSIG_NORMAL; opt <= GIT_HASHSIG_SMART_WHITESPACE; ++opt) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
cl_git_pass(git_buf_sets(&buf, text[i]));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, opt));
cl_git_pass(git_buf_sets(&buf, text[j]));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, opt));
sim = git_hashsig_compare(a, b);
if (opt == GIT_HASHSIG_NORMAL) {
if (i == j)
cl_assert_equal_i(100, sim);
else
cl_assert_in_range(0, sim, 30); /* pretty different */
} else {
cl_assert_equal_i(100, sim);
}
git_hashsig_free(a);
git_hashsig_free(b);
}
}
}
git_buf_free(&buf);
}
开发者ID:ANNAVARAMVENKATESH,项目名称:libgit2,代码行数:77,代码来源:buffer.c
示例8: test_rebase_inmemory__no_common_ancestor
void test_rebase_inmemory__no_common_ancestor(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_oid commit_id, expected_final_id;
git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
opts.inmemory = true;
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/barley"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, &opts));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature,
NULL, NULL));
cl_git_pass(git_rebase_finish(rebase, signature));
git_oid_fromstr(&expected_final_id, "71e7ee8d4fe7d8bf0d107355197e0a953dfdb7f3");
cl_assert_equal_oid(&expected_final_id, &commit_id);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_rebase_free(rebase);
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:50,代码来源:inmemory.c
示例9: test_rebase_inmemory__can_resolve_conflicts
void test_rebase_inmemory__can_resolve_conflicts(void)
{
git_rebase *rebase;
git_reference *branch_ref, *upstream_ref;
git_annotated_commit *branch_head, *upstream_head;
git_rebase_operation *rebase_operation;
git_status_list *status_list;
git_oid pick_id, commit_id, expected_commit_id;
git_signature *signature;
git_index *repo_index;
git_index_entry resolution = {{0}};
git_rebase_options opts = GIT_REBASE_OPTIONS_INIT;
cl_git_pass(git_signature_new(&signature,
"Rebaser", "[email protected]", 1405694510, 0));
opts.inmemory = true;
cl_git_pass(git_reference_lookup(&branch_ref, repo, "refs/heads/asparagus"));
cl_git_pass(git_reference_lookup(&upstream_ref, repo, "refs/heads/master"));
cl_git_pass(git_annotated_commit_from_ref(&branch_head, repo, branch_ref));
cl_git_pass(git_annotated_commit_from_ref(&upstream_head, repo, upstream_ref));
cl_git_pass(git_rebase_init(&rebase, repo, branch_head, upstream_head, NULL, &opts));
cl_git_pass(git_rebase_next(&rebase_operation, rebase));
git_oid_fromstr(&pick_id, "33f915f9e4dbd9f4b24430e48731a59b45b15500");
cl_assert_equal_i(GIT_REBASE_OPERATION_PICK, rebase_operation->type);
cl_assert_equal_oid(&pick_id, &rebase_operation->id);
/* ensure that we did not do anything stupid to the workdir or repo index */
cl_git_pass(git_repository_index(&repo_index, repo));
cl_assert(!git_index_has_conflicts(repo_index));
cl_git_pass(git_status_list_new(&status_list, repo, NULL));
cl_assert_equal_i(0, git_status_list_entrycount(status_list));
/* but that the index returned from rebase does have conflicts */
cl_assert(git_index_has_conflicts(rebase_operation->index));
cl_git_fail_with(GIT_EUNMERGED, git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL));
/* ensure that we can work with the in-memory index to resolve the conflict */
resolution.path = "asparagus.txt";
resolution.mode = GIT_FILEMODE_BLOB;
git_oid_fromstr(&resolution.id, "414dfc71ead79c07acd4ea47fecf91f289afc4b9");
cl_git_pass(git_index_conflict_remove(rebase_operation->index, "asparagus.txt"));
cl_git_pass(git_index_add(rebase_operation->index, &resolution));
/* and finally create a commit for the resolved rebase operation */
cl_git_pass(git_rebase_commit(&commit_id, rebase, NULL, signature, NULL, NULL));
cl_git_pass(git_oid_fromstr(&expected_commit_id, "db7af47222181e548810da2ab5fec0e9357c5637"));
cl_assert_equal_oid(&commit_id, &expected_commit_id);
git_signature_free(signature);
git_status_list_free(status_list);
git_annotated_commit_free(branch_head);
git_annotated_commit_free(upstream_head);
git_reference_free(branch_ref);
git_reference_free(upstream_ref);
git_index_free(repo_index);
git_rebase_free(rebase);
}
开发者ID:torgebo,项目名称:libgit2,代码行数:67,代码来源:inmemory.c
示例10: diff_foreach_via_iterator
int diff_foreach_via_iterator(
git_diff_list *diff,
git_diff_file_cb file_cb,
git_diff_hunk_cb hunk_cb,
git_diff_data_cb line_cb,
void *data)
{
size_t d, num_d = git_diff_num_deltas(diff);
for (d = 0; d < num_d; ++d) {
git_diff_patch *patch;
const git_diff_delta *delta;
size_t h, num_h;
cl_git_pass(git_diff_get_patch(&patch, &delta, diff, d));
cl_assert(delta);
/* call file_cb for this file */
if (file_cb != NULL && file_cb(delta, (float)d / num_d, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
/* if there are no changes, then the patch will be NULL */
if (!patch) {
cl_assert(delta->status == GIT_DELTA_UNMODIFIED ||
(delta->flags & GIT_DIFF_FLAG_BINARY) != 0);
continue;
}
if (!hunk_cb && !line_cb) {
git_diff_patch_free(patch);
continue;
}
num_h = git_diff_patch_num_hunks(patch);
for (h = 0; h < num_h; h++) {
const git_diff_range *range;
const char *hdr;
size_t hdr_len, l, num_l;
cl_git_pass(git_diff_patch_get_hunk(
&range, &hdr, &hdr_len, &num_l, patch, h));
if (hunk_cb && hunk_cb(delta, range, hdr, hdr_len, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
for (l = 0; l < num_l; ++l) {
char origin;
const char *line;
size_t line_len;
int old_lineno, new_lineno;
cl_git_pass(git_diff_patch_get_line_in_hunk(
&origin, &line, &line_len, &old_lineno, &new_lineno,
patch, h, l));
if (line_cb &&
line_cb(delta, range, origin, line, line_len, data) != 0) {
git_diff_patch_free(patch);
goto abort;
}
}
}
git_diff_patch_free(patch);
}
return 0;
abort:
giterr_clear();
return GIT_EUSER;
}
开发者ID:aep,项目名称:libgit2,代码行数:77,代码来源:diff_helpers.c
示例11: diff_print_raw
void diff_print_raw(FILE *fp, git_diff_list *diff)
{
cl_git_pass(git_diff_print_raw(diff, diff_print_cb, fp ? fp : stderr));
}
开发者ID:aep,项目名称:libgit2,代码行数:4,代码来源:diff_helpers.c
示例12: test_core_path__15_resolve_relative
void test_core_path__15_resolve_relative(void)
{
git_buf buf = GIT_BUF_INIT;
assert_resolve_relative(&buf, "", "");
assert_resolve_relative(&buf, "", ".");
assert_resolve_relative(&buf, "", "./");
assert_resolve_relative(&buf, "..", "..");
assert_resolve_relative(&buf, "../", "../");
assert_resolve_relative(&buf, "..", "./..");
assert_resolve_relative(&buf, "../", "./../");
assert_resolve_relative(&buf, "../", "../.");
assert_resolve_relative(&buf, "../", ".././");
assert_resolve_relative(&buf, "../..", "../..");
assert_resolve_relative(&buf, "../../", "../../");
assert_resolve_relative(&buf, "/", "/");
assert_resolve_relative(&buf, "/", "/.");
assert_resolve_relative(&buf, "", "a/..");
assert_resolve_relative(&buf, "", "a/../");
assert_resolve_relative(&buf, "", "a/../.");
assert_resolve_relative(&buf, "/a", "/a");
assert_resolve_relative(&buf, "/a/", "/a/.");
assert_resolve_relative(&buf, "/", "/a/../");
assert_resolve_relative(&buf, "/", "/a/../.");
assert_resolve_relative(&buf, "/", "/a/.././");
assert_resolve_relative(&buf, "a", "a");
assert_resolve_relative(&buf, "a/", "a/");
assert_resolve_relative(&buf, "a/", "a/.");
assert_resolve_relative(&buf, "a/", "a/./");
assert_resolve_relative(&buf, "a/b", "a//b");
assert_resolve_relative(&buf, "a/b/c", "a/b/c");
assert_resolve_relative(&buf, "b/c", "./b/c");
assert_resolve_relative(&buf, "a/c", "a/./c");
assert_resolve_relative(&buf, "a/b/", "a/b/.");
assert_resolve_relative(&buf, "/a/b/c", "///a/b/c");
assert_resolve_relative(&buf, "/", "////");
assert_resolve_relative(&buf, "/a", "///a");
assert_resolve_relative(&buf, "/", "///.");
assert_resolve_relative(&buf, "/", "///a/..");
assert_resolve_relative(&buf, "../../path", "../../test//../././path");
assert_resolve_relative(&buf, "../d", "a/b/../../../c/../d");
cl_git_pass(git_buf_sets(&buf, "/.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
cl_git_pass(git_buf_sets(&buf, "/./.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
cl_git_pass(git_buf_sets(&buf, "/.//.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
cl_git_pass(git_buf_sets(&buf, "/../."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
cl_git_pass(git_buf_sets(&buf, "/../.././../a"));
cl_git_fail(git_path_resolve_relative(&buf, 0));
cl_git_pass(git_buf_sets(&buf, "////.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
/* things that start with Windows network paths */
#ifdef GIT_WIN32
assert_resolve_relative(&buf, "//a/b/c", "//a/b/c");
assert_resolve_relative(&buf, "//a/", "//a/b/..");
assert_resolve_relative(&buf, "//a/b/c", "//a/Q/../b/x/y/../../c");
cl_git_pass(git_buf_sets(&buf, "//a/b/../.."));
cl_git_fail(git_path_resolve_relative(&buf, 0));
#else
assert_resolve_relative(&buf, "/a/b/c", "//a/b/c");
assert_resolve_relative(&buf, "/a/", "//a/b/..");
assert_resolve_relative(&buf, "/a/b/c", "//a/Q/../b/x/y/../../c");
assert_resolve_relative(&buf, "/", "//a/b/../..");
#endif
git_buf_dispose(&buf);
}
开发者ID:CodeSmithyIDE,项目名称:libgit2,代码行数:84,代码来源:path.c
示例13: test_core_path__14_apply_relative
void test_core_path__14_apply_relative(void)
{
git_buf p = GIT_BUF_INIT;
cl_git_pass(git_buf_sets(&p, "/this/is/a/base"));
cl_git_pass(git_path_apply_relative(&p, "../test"));
cl_assert_equal_s("/this/is/a/test", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../../the/./end"));
cl_assert_equal_s("/this/is/the/end", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "./of/this/../the/string"));
cl_assert_equal_s("/this/is/the/end/of/the/string", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../../../../../.."));
cl_assert_equal_s("/this/", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../"));
cl_assert_equal_s("/", p.ptr);
cl_git_fail(git_path_apply_relative(&p, "../../.."));
cl_git_pass(git_buf_sets(&p, "d:/another/test"));
cl_git_pass(git_path_apply_relative(&p, "../.."));
cl_assert_equal_s("d:/", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "from/here/to/../and/./back/."));
cl_assert_equal_s("d:/from/here/and/back/", p.ptr);
cl_git_pass(git_buf_sets(&p, "https://my.url.com/test.git"));
cl_git_pass(git_path_apply_relative(&p, "../another.git"));
cl_assert_equal_s("https://my.url.com/another.git", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../full/path/url.patch"));
cl_assert_equal_s("https://my.url.com/full/path/url.patch", p.ptr);
cl_git_pass(git_path_apply_relative(&p, ".."));
cl_assert_equal_s("https://my.url.com/full/path/", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../../../"));
cl_assert_equal_s("https://", p.ptr);
cl_git_pass(git_buf_sets(&p, "../../this/is/relative"));
cl_git_pass(git_path_apply_relative(&p, "../../preserves/the/prefix"));
cl_assert_equal_s("../../this/preserves/the/prefix", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../../../../that"));
cl_assert_equal_s("../../that", p.ptr);
cl_git_pass(git_path_apply_relative(&p, "../there"));
cl_assert_equal_s("../../there", p.ptr);
git_buf_dispose(&p);
}
开发者ID:CodeSmithyIDE,项目名称:libgit2,代码行数:60,代码来源:path.c
示例14: test_core_path__11_walkup
void test_core_path__11_walkup(void)
{
git_buf p = GIT_BUF_INIT;
char *expect[] = {
/* 1 */ "/a/b/c/d/e/", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL,
/* 2 */ "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL,
/* 3 */ "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL,
/* 4 */ "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", "/a/", "/", NULL,
/* 5 */ "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", NULL,
/* 6 */ "/a/b/c/d/e", "/a/b/c/d/", "/a/b/c/", "/a/b/", NULL,
/* 7 */ "this_is_a_path", "", NULL,
/* 8 */ "this_is_a_path/", "", NULL,
/* 9 */ "///a///b///c///d///e///", "///a///b///c///d///", "///a///b///c///", "///a///b///", "///a///", "///", NULL,
/* 10 */ "a/b/c/", "a/b/", "a/", "", NULL,
/* 11 */ "a/b/c", "a/b/", "a/", "", NULL,
/* 12 */ "a/b/c/", "a/b/", "a/", NULL,
/* 13 */ "", NULL,
/* 14 */ "/", NULL,
/* 15 */ NULL
};
char *root[] = {
/* 1 */ NULL,
/* 2 */ NULL,
/* 3 */ "/",
/* 4 */ "",
/* 5 */ "/a/b",
/* 6 */ "/a/b/",
/* 7 */ NULL,
/* 8 */ NULL,
/* 9 */ NULL,
/* 10 */ NULL,
/* 11 */ NULL,
/* 12 */ "a/",
/* 13 */ NULL,
/* 14 */ NULL,
};
int i, j;
check_walkup_info info;
info.expect = expect;
info.cancel_after = -1;
for (i = 0, j = 0; expect[i] != NULL; i++, j++) {
git_buf_sets(&p, expect[i]);
info.expect_idx = i;
cl_git_pass(
git_path_walk_up(&p, root[j], check_one_walkup_step, &info)
);
cl_assert_equal_s(p.ptr, expect[i]);
cl_assert(expect[info.expect_idx] == NULL);
i = info.expect_idx;
}
git_buf_dispose(&p);
}
开发者ID:CodeSmithyIDE,项目名称:libgit2,代码行数:61,代码来源:path.c
示例15: test_status_ignore__issue_1766_negated_ignores
void test_status_ignore__issue_1766_negated_ignores(void)
{
unsigned int status;
g_repo = cl_git_sandbox_init("empty_standard_repo");
cl_git_pass(git_futils_mkdir_r(
"empty_standard_repo/a", NULL, 0775));
cl_git_mkfile(
"empty_standard_repo/a/.gitignore", "*\n!.gitignore\n");
cl_git_mkfile(
"empty_standard_repo/a/ignoreme", "I should be ignored\n");
refute_is_ignored("a/.gitignore");
assert_is_ignored("a/ignoreme");
cl_git_pass(git_futils_mkdir_r(
"empty_standard_repo/b", NULL, 0775));
cl_git_mkfile(
"empty_standard_repo/b/.gitignore", "*\n!.gitignore\n");
cl_git_mkfile(
"empty_standard_repo/b/ignoreme", "I should be ignored\n");
refute_is_ignored("b/.gitignore");
assert_is_ignored("b/ignoreme");
/* shouldn't have changed results from first couple either */
refute_is_ignored("a/.gitignore");
assert_is_ignored("a/ignoreme");
/* status should find the two ignore files and nothing else */
cl_git_pass(git_status_file(&status, g_repo, "a/.gitignore"));
cl_assert_equal_i(GIT_STATUS_WT_NEW, (int)status);
cl_git_pass(git_status_file(&status, g_repo, "a/ignoreme"));
cl_assert_equal_i(GIT_STATUS_IGNORED, (int)status);
cl_git_pass(git_status_file(&status, g_repo, "b/.gitignore"));
cl_assert_equal_i(GIT_STATUS_WT_NEW, (int)status);
cl_git_pass(git_status_file(&status, g_repo, "b/ignoreme"));
cl_assert_equal_i(GIT_STATUS_IGNORED, (int)status);
{
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
status_entry_counts counts;
static const char *paths[] = {
"a/.gitignore",
"a/ignoreme",
"b/.gitignore",
"b/ignoreme",
};
static const unsigned int statuses[] = {
GIT_STATUS_WT_NEW,
GIT_STATUS_IGNORED,
GIT_STATUS_WT_NEW,
GIT_STATUS_IGNORED,
};
memset(&counts, 0x0, sizeof(status_entry_counts));
counts.expected_entry_count = 4;
counts.expected_paths = paths;
counts.expected_statuses = statuses;
opts.flags = GIT_STATUS_OPT_DEFAULTS;
cl_git_pass(git_status_foreach_ext(
g_repo, &opts, cb_status__normal, &counts));
cl_assert_equal_i(counts.expected_entry_count, counts.entry_count);
cl_assert_equal_i(0, counts.wrong_status_flags_count);
cl_assert_equal_i(0, counts.wrong_sorted_path);
}
}
开发者ID:DaneTheory,项目名称:libgit2,代码行数:75,代码来源:ignore.c
示例16: test_index_tests__remove_directory
void test_index_tests__remove_directory(void)
{
git_repository *repo;
git_index *index;
p_mkdir("index_test", 0770);
cl_git_pass(git_repository_init(&repo, "index_test", 0));
cl_git_pass(git_repository_index(&index, repo));
cl_assert_equal_i(0, (int)git_index_entrycount(index));
p_mkdir("index_test/a", 0770);
cl_git_mkfile("index_test/a/1.txt", NULL);
cl_git_mkfile("index_test/a/2.txt", NULL);
cl_git_mkfile("index_test/a/3.txt", NULL);
cl_git_mkfile("index_test/b.txt", NULL);
cl_git_pass(git_index_add_bypath(index, "a/1.txt"));
cl_git_pass(git_index_add_bypath(index, "a/2.txt"));
cl_git_pass(git_index_add_bypath(index, "a/3.txt"));
cl_git_pass(git_index_add_bypath(index, "b.txt"));
cl_git_pass(git_index_write(index));
cl_git_pass(git_index_read(index)); /* reload */
cl_assert_equal_i(4, (int)git_index_entrycount(index));
cl_assert(git_index_get_bypath(index, "a/1.txt", 0) != NULL);
cl_assert(git_index_get_bypath(index, "a/2.txt", 0) != NULL);
cl_assert(git_index_get_bypath(index, "b.txt", 0) != NULL);
cl_git_pass(git_index_remove(index, "a/1.txt", 0));
cl_git_pass(git_index_write(index));
cl_git_pass(git_index_read(index)); /* reload */
cl_assert_equal_i(3, (int)git_index_entrycount(index));
cl_assert(git_index_get_bypath(index, "a/1.txt", 0) == NULL);
cl_assert(git_index_get_bypath(index, "a/2.txt", 0) != NULL);
cl_assert(git_index_get_bypath(index, "b.txt", 0) != NULL);
cl_git_pass(git_index_remove_directory(index, "a", 0));
cl_git_pass(git_index_write(index));
cl_git_pass(git_index_read(index)); /* reload */
cl_assert_equal_i(1, (int)git_index_entrycount(index));
cl_assert(git_index_get_bypath(index, "a/1.txt", 0) == NULL);
cl_assert(git_index_get_bypath(index, "a/2.txt", 0) == NULL);
cl_assert(git_index_get_bypath(index, "b.txt", 0) != NULL);
git_index_free(index);
git_repository_free(repo);
cl_fixture_cleanup("index_test");
}
开发者ID:lznuaa,项目名称:libgit2,代码行数:51,代码来源:tests.c
示例17: test_index_bypath__initialize
void test_index_bypath__initialize(void)
{
g_repo = setup_fixture_submod2();
cl_git_pass(git_repository_index__weakptr(&g_idx, g_repo));
}
开发者ID:stewid,项目名称:libgit2,代码行数:5,代码来源:bypath.c
示例18: test_stash_drop__initialize
void test_stash_drop__initialize(void)
{
cl_git_pass(git_repository_init(&repo, "stash", 0));
cl_git_pass(git_signature_new(&signature, "nulltoken", "[email protected]", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */
}
开发者ID:0CV0,项目名称:libgit2,代码行数:5,代码来源:drop.c
示例19: test_core_buffer__similarity_metric
void test_core_buffer__similarity_metric(void)
{
git_hashsig *a, *b;
git_buf buf = GIT_BUF_INIT;
int sim;
/* in the first case, we compare data to itself and expect 100% match */
cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_assert_equal_i(100, git_hashsig_compare(a, b));
git_hashsig_free(a);
git_hashsig_free(b);
/* if we change just a single byte, how much does that change magnify? */
cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_buf_sets(&buf,
"000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
"010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
"x020x\n021\n022\n023\n024\n025\n026\n027\n028\n029\n" \
"030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n" \
"040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n"
));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
sim = git_hashsig_compare(a, b);
cl_assert_in_range(95, sim, 100); /* expect >95% similarity */
git_hashsig_free(a);
git_hashsig_free(b);
/* let's try comparing data to a superset of itself */
cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1
"050\n051\n052\n053\n054\n055\n056\n057\n058\n059\n"));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
sim = git_hashsig_compare(a, b);
/* 20% lines added ~= 10% lines changed */
cl_assert_in_range(85, sim, 95); /* expect similarity around 90% */
git_hashsig_free(a);
git_hashsig_free(b);
/* what if we keep about half the original data and add half new */
cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_buf_sets(&buf,
"000\n001\n002\n003\n004\n005\n006\n007\n008\n009\n" \
"010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n" \
"020x\n021\n022\n023\n024\n" \
"x25\nx26\nx27\nx28\nx29\n" \
"x30\nx31\nx32\nx33\nx34\nx35\nx36\nx37\nx38\nx39\n" \
"x40\nx41\nx42\nx43\nx44\nx45\nx46\nx47\nx48\nx49\n"
));
cl_git_pass(git_hashsig_create(&b, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
sim = git_hashsig_compare(a, b);
/* 50% lines changed */
cl_assert_in_range(40, sim, 60); /* expect in the 40-60% similarity range */
git_hashsig_free(a);
git_hashsig_free(b);
/* lastly, let's check that we can hash file content as well */
cl_git_pass(git_buf_sets(&buf, SIMILARITY_TEST_DATA_1));
cl_git_pass(git_hashsig_create(&a, buf.ptr, buf.size, GIT_HASHSIG_NORMAL));
cl_git_pass(git_futils_mkdir("scratch", NULL, 0755, GIT_MKDIR_PATH));
cl_git_mkfile("scratch/testdata", SIMILARITY_TEST_DATA_1);
cl_git_pass(git_hashsig_create_fromfile(
&b, "scratch/testdata", GIT_HASHSIG_NORMAL));
cl_assert_equal_i(100, git_hashsig_compare(a, b));
git_hashsig_free(a);
git_hashsig_free(b);
git_buf_free(&buf);
git_futils_rmdir_r("scratch", NULL, GIT_RMDIR_REMOVE_FILES);
}
开发者ID:ANNAVARAMVENKATESH,项目名称:libgit2,代码行数:93,代码来源:buffer.c
示例20: checkout_tree_with_blob_ignored_in_workdir
static int checkout_tree_with_blob_ignored_in_workdir(int strategy, bool isdir)
{
git_oid oid;
git_object *obj = NULL;
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
int ignored = 0, error;
assert_on_branch(g_repo, "master");
/* do first checkout with FORCE because we don't know if testrepo
* base data is clean for a checkout or not
*/
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/dir"));
cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/dir", NULL, NULL));
cl_assert(git_path_isfile("testrepo/README"));
cl_assert(git_path_isfile("testrepo/branch_file.txt"));
cl_assert(git_path_isfile("testrepo/new.txt"));
cl_assert(git_path_isfile("testrepo/a/b.txt"));
cl_assert(!git_path_isdir("testrepo/ab"));
assert_on_branch(g_repo, "dir");
git_object_free(obj);
opts.checkout_strategy = strategy;
if (isdir) {
cl_must_pass(p_mkdir("testrepo/ab", 0777));
cl_must_pass(p_mkdir("testrepo/ab/4.txt", 0777));
cl_git_mkfile("testrepo/ab/4.txt/file1.txt", "as you wish");
cl_git_mkfile("testrepo/ab/4.txt/file2.txt", "foo bar foo");
cl_git_mkfile("testrepo/ab/4.txt/file3.txt", "inky blinky pinky clyde");
cl_assert(git_path_isdir("testrepo/ab/4.txt"));
} else {
cl_must_pass(p_mkdir("testrepo/ab", 0777));
cl_git_mkfile("testrepo/ab/4.txt", "as you wish");
cl_assert(git_path_isfile("testrepo/ab/4.txt"));
}
cl_git_pass(git_ignore_add_rule(g_repo, "ab/4.txt\n"));
cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "ab/4.txt"));
cl_assert_equal_i(1, ignored);
cl_git_pass(git_reference_name_to_id(&oid, g_repo, "refs/heads/subtrees"));
cl_git_pass(git_object_lookup(&obj, g_repo, &oid, GIT_OBJ_ANY));
error = git_checkout_tree(g_repo, obj, &opts);
git_object_free(obj);
return error;
}
开发者ID:Nangal,项目名称:libgit2,代码行数:63,代码来源:tree.c
注:本文中的cl_git_pass函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论