本文整理汇总了C++中cl_git_pass函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_git_pass函数的具体用法?C++ cl_git_pass怎么用?C++ cl_git_pass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_git_pass函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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]"));
}
示例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/*");
}
示例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);
}
示例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);
}
示例6: test_index_racy__initialize
void test_index_racy__initialize(void)
{
cl_git_pass(git_repository_init(&g_repo, "diff_racy", false));
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}