当前位置: 首页>>代码示例>>C++>>正文


C++ cl_git_fail_with函数代码示例

本文整理汇总了C++中cl_git_fail_with函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_git_fail_with函数的具体用法?C++ cl_git_fail_with怎么用?C++ cl_git_fail_with使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cl_git_fail_with函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_transport_register__custom_transport_ssh

void test_transport_register__custom_transport_ssh(void)
{
	git_transport *transport;

#ifndef GIT_SSH
	cl_git_fail_with(git_transport_new(&transport, NULL, "ssh://somehost:somepath"), -1);
	cl_git_fail_with(git_transport_new(&transport, NULL, "[email protected]:somepath"), -1);
#else
	cl_git_pass(git_transport_new(&transport, NULL, "[email protected]:somepath"));
#endif

	cl_git_pass(git_transport_register("ssh", dummy_transport, NULL));

	cl_git_pass(git_transport_new(&transport, NULL, "[email protected]:somepath"));

	cl_assert(transport == &_transport);

	cl_git_pass(git_transport_unregister("ssh"));

#ifndef GIT_SSH
	cl_git_fail_with(git_transport_new(&transport, NULL, "ssh://somehost:somepath"), -1);
	cl_git_fail_with(git_transport_new(&transport, NULL, "[email protected]:somepath"), -1);
#else
	cl_git_pass(git_transport_new(&transport, NULL, "[email protected]:somepath"));
#endif
}
开发者ID:KindDragon,项目名称:libgit2,代码行数:26,代码来源:register.c

示例2: test_diff_parse__nonpatches_fail_with_notfound

void test_diff_parse__nonpatches_fail_with_notfound(void)
{
	git_diff *diff;
	const char *not = PATCH_NOT_A_PATCH;
	const char *not_with_leading = "Leading text.\n" PATCH_NOT_A_PATCH;
	const char *not_with_trailing = PATCH_NOT_A_PATCH "Trailing text.\n";
	const char *not_with_both = "Lead.\n" PATCH_NOT_A_PATCH "Trail.\n";

	cl_git_fail_with(GIT_ENOTFOUND,
		git_diff_from_buffer(&diff,
		not,
		strlen(not)));
	cl_git_fail_with(GIT_ENOTFOUND,
		git_diff_from_buffer(&diff,
		not_with_leading,
		strlen(not_with_leading)));
	cl_git_fail_with(GIT_ENOTFOUND,
		git_diff_from_buffer(&diff,
		not_with_trailing,
		strlen(not_with_trailing)));
	cl_git_fail_with(GIT_ENOTFOUND,
		git_diff_from_buffer(&diff,
		not_with_both,
		strlen(not_with_both)));
}
开发者ID:GuapoTaco,项目名称:chigraph,代码行数:25,代码来源:parse.c

示例3: test_stash_drop__cannot_drop_a_non_existing_stashed_state

void test_stash_drop__cannot_drop_a_non_existing_stashed_state(void)
{
	push_three_states();

	cl_git_fail_with(git_stash_drop(repo, 666), GIT_ENOTFOUND);
	cl_git_fail_with(git_stash_drop(repo, 42), GIT_ENOTFOUND);
	cl_git_fail_with(git_stash_drop(repo, 3), GIT_ENOTFOUND);
}
开发者ID:0CV0,项目名称:libgit2,代码行数:8,代码来源:drop.c

示例4: test_config_write__locking

void test_config_write__locking(void)
{
	git_config *cfg, *cfg2;
	git_config_entry *entry;
	git_transaction *tx;
	const char *filename = "locked-file";

	/* Open the config and lock it */
	cl_git_mkfile(filename, "[section]\n\tname = value\n");
	cl_git_pass(git_config_open_ondisk(&cfg, filename));
	cl_git_pass(git_config_get_entry(&entry, cfg, "section.name"));
	cl_assert_equal_s("value", entry->value);
	git_config_entry_free(entry);
	cl_git_pass(git_config_lock(&tx, cfg));

	/* Change entries in the locked backend */
	cl_git_pass(git_config_set_string(cfg, "section.name", "other value"));
	cl_git_pass(git_config_set_string(cfg, "section2.name3", "more value"));

	/* We can see that the file we read from hasn't changed */
	cl_git_pass(git_config_open_ondisk(&cfg2, filename));
	cl_git_pass(git_config_get_entry(&entry, cfg2, "section.name"));
	cl_assert_equal_s("value", entry->value);
	git_config_entry_free(entry);
	cl_git_fail_with(GIT_ENOTFOUND, git_config_get_entry(&entry, cfg2, "section2.name3"));
	git_config_free(cfg2);

	/* And we also get the old view when we read from the locked config */
	cl_git_pass(git_config_get_entry(&entry, cfg, "section.name"));
	cl_assert_equal_s("value", entry->value);
	git_config_entry_free(entry);
	cl_git_fail_with(GIT_ENOTFOUND, git_config_get_entry(&entry, cfg, "section2.name3"));

	cl_git_pass(git_transaction_commit(tx));
	git_transaction_free(tx);

	/* Now that we've unlocked it, we should see both updates */
	cl_git_pass(git_config_get_entry(&entry, cfg, "section.name"));
	cl_assert_equal_s("other value", entry->value);
	git_config_entry_free(entry);
	cl_git_pass(git_config_get_entry(&entry, cfg, "section2.name3"));
	cl_assert_equal_s("more value", entry->value);
	git_config_entry_free(entry);

	git_config_free(cfg);

	/* We should also see the changes after reopening the config */
	cl_git_pass(git_config_open_ondisk(&cfg, filename));
	cl_git_pass(git_config_get_entry(&entry, cfg, "section.name"));
	cl_assert_equal_s("other value", entry->value);
	git_config_entry_free(entry);
	cl_git_pass(git_config_get_entry(&entry, cfg, "section2.name3"));
	cl_assert_equal_s("more value", entry->value);
	git_config_entry_free(entry);

	git_config_free(cfg);
}
开发者ID:Angolier,项目名称:sonic-pi,代码行数:57,代码来源:write.c

示例5: test_online_clone__certificate_invalid

void test_online_clone__certificate_invalid(void)
{
	g_options.fetch_opts.callbacks.certificate_check = fail_certificate_check;

	cl_git_fail_with(git_clone(&g_repo, "https://github.com/libgit2/TestGitRepository", "./foo", &g_options),
		GIT_ECERTIFICATE);

#ifdef GIT_SSH
	cl_git_fail_with(git_clone(&g_repo, "ssh://github.com/libgit2/TestGitRepository", "./foo", &g_options),
		GIT_ECERTIFICATE);
#endif
}
开发者ID:RsrchBoy,项目名称:p5-Git-Raw,代码行数:12,代码来源:clone.c

示例6: assert_invalid_config_key_name

static void assert_invalid_config_key_name(const char *name)
{
	cl_git_fail_with(git_config_get_string(&value, cfg, name),
		GIT_EINVALIDSPEC);
	cl_git_fail_with(git_config_set_string(cfg, name, "42"),
		GIT_EINVALIDSPEC);
	cl_git_fail_with(git_config_delete_entry(cfg, name),
		GIT_EINVALIDSPEC);
	cl_git_fail_with(git_config_get_multivar_foreach(cfg, name, "*", NULL, NULL),
		GIT_EINVALIDSPEC);
	cl_git_fail_with(git_config_set_multivar(cfg, name, "*", "42"),
		GIT_EINVALIDSPEC);
}
开发者ID:DaneTheory,项目名称:libgit2,代码行数:13,代码来源:validkeyname.c

示例7: test_checkout_tree__can_cancel_checkout_from_notify

void test_checkout_tree__can_cancel_checkout_from_notify(void)
{
	struct checkout_cancel_at ca;
	git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
	git_oid oid;
	git_object *obj = NULL;

	assert_on_branch(g_repo, "master");

	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));

	ca.filename = "new.txt";
	ca.error = -5555;
	ca.count = 0;

	opts.notify_flags = GIT_CHECKOUT_NOTIFY_UPDATED;
	opts.notify_cb = checkout_cancel_cb;
	opts.notify_payload = &ca;
	opts.checkout_strategy = GIT_CHECKOUT_FORCE;

	cl_assert(!git_path_exists("testrepo/new.txt"));

	cl_git_fail_with(git_checkout_tree(g_repo, obj, &opts), -5555);

	cl_assert(!git_path_exists("testrepo/new.txt"));

	/* on case-insensitive FS = a/b.txt, branch_file.txt, new.txt */
	/* on case-sensitive FS   = README, then above */

	if (git_path_exists("testrepo/.git/CoNfIg")) /* case insensitive */
		cl_assert_equal_i(3, ca.count);
	else
		cl_assert_equal_i(4, ca.count);

	/* and again with a different stopping point and return code */
	ca.filename = "README";
	ca.error = 123;
	ca.count = 0;

	cl_git_fail_with(git_checkout_tree(g_repo, obj, &opts), 123);

	cl_assert(!git_path_exists("testrepo/new.txt"));

	if (git_path_exists("testrepo/.git/CoNfIg")) /* case insensitive */
		cl_assert_equal_i(4, ca.count);
	else
		cl_assert_equal_i(1, ca.count);

	git_object_free(obj);
}
开发者ID:Kat7984,项目名称:libgit2,代码行数:51,代码来源:tree.c

示例8: test_stream_deprecated__register_tls

void test_stream_deprecated__register_tls(void)
{
	git_stream *stream;
	int error;

	ctor_called = 0;
	cl_git_pass(git_stream_register_tls(test_stream_init));
	cl_git_pass(git_tls_stream_new(&stream, "localhost", "443"));
	cl_assert_equal_i(1, ctor_called);
	cl_assert_equal_p(&test_stream, stream);

	ctor_called = 0;
	stream = NULL;
	cl_git_pass(git_stream_register_tls(NULL));
	error = git_tls_stream_new(&stream, "localhost", "443");

	/*
	 * We don't have TLS support enabled, or we're on Windows,
	 * which has no arbitrary TLS stream support.
	 */
#if defined(GIT_WIN32) || !defined(GIT_HTTPS)
	cl_git_fail_with(-1, error);
#else
	cl_git_pass(error);
#endif

	cl_assert_equal_i(0, ctor_called);
	cl_assert(&test_stream != stream);

	git_stream_free(stream);
}
开发者ID:ethomson,项目名称:libgit2,代码行数:31,代码来源:deprecated.c

示例9: test_apply_both__application_failure_leaves_workdir_unmodified

void test_apply_both__application_failure_leaves_workdir_unmodified(void)
{
	git_diff *diff;
	git_index *index;

	const char *diff_file = DIFF_MODIFY_TWO_FILES;

	struct merge_index_entry workdir_expected[] = {
		{ 0100644, "f51658077d85f2264fa179b4d0848268cb3475c3", 0, "asparagus.txt" },
		{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
		{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
		{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
		{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
		{ 0100644, "8684724651336001c5dbce74bed6736d2443958d", 0, "veal.txt" },
	};
	size_t workdir_expected_cnt = sizeof(workdir_expected) /
		sizeof(struct merge_index_entry);

	/* mutate the workdir */
	cl_git_rewritefile("merge-recursive/veal.txt",
	    "This is a modification.\n");

	cl_git_pass(git_repository_index(&index, repo));
	cl_git_pass(git_index_add_bypath(index, "veal.txt"));
	cl_git_pass(git_index_write(index));
	git_index_free(index);

	cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file)));
	cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));

	validate_apply_workdir(repo, workdir_expected, workdir_expected_cnt);

	git_diff_free(diff);
}
开发者ID:CodeSmithyIDE,项目名称:libgit2,代码行数:34,代码来源:both.c

示例10: test_apply_both__index_must_match_workdir

void test_apply_both__index_must_match_workdir(void)
{
	git_diff *diff;
	git_index *index;
	git_index_entry idx_entry;

	const char *diff_file = DIFF_MODIFY_TWO_FILES;

	/*
	 * Append a line to the end of the file in both the index and the
	 * working directory.  Although the appended line would allow for
	 * patch application in each, the line appended is different in
	 * each, so the application should not be allowed.
	 */
	cl_git_append2file("merge-recursive/asparagus.txt",
	    "This is a modification.\n");

	cl_git_pass(git_repository_index(&index, repo));

	memset(&idx_entry, 0, sizeof(git_index_entry));
	idx_entry.mode = 0100644;
	idx_entry.path = "asparagus.txt";
	cl_git_pass(git_oid_fromstr(&idx_entry.id, "06d3fefb8726ab1099acc76e02dfb85e034b2538"));
	cl_git_pass(git_index_add(index, &idx_entry));

	cl_git_pass(git_index_write(index));
	git_index_free(index);

	cl_git_pass(git_diff_from_buffer(&diff, diff_file, strlen(diff_file)));
	cl_git_fail_with(GIT_EAPPLYFAIL, git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));

	git_diff_free(diff);
}
开发者ID:CodeSmithyIDE,项目名称:libgit2,代码行数:33,代码来源:both.c

示例11: test_network_remote_local__push_to_non_bare_remote

void test_network_remote_local__push_to_non_bare_remote(void)
{
    char *refspec_strings[] = {
        "master:master",
    };
    git_strarray array = {
        refspec_strings,
        1,
    };
    /* Shouldn't be able to push to a non-bare remote */
    git_remote *localremote;
    git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;

    /* Get some commits */
    connect_to_local_repository(cl_fixture("testrepo.git"));
    cl_git_pass(git_remote_fetch(remote, &array, &fetch_opts, NULL));

    /* Set up an empty non-bare repo to push into */
    {
        git_repository *remoterepo = NULL;
        cl_git_pass(git_repository_init(&remoterepo, "localnonbare", 0));
        git_repository_free(remoterepo);
    }

    /* Connect to the bare repo */
    cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
    cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL, NULL));

    /* Try to push */
    cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));

    /* Clean up */
    git_remote_free(localremote);
    cl_fixture_cleanup("localbare.git");
}
开发者ID:rlugojr,项目名称:libgit2,代码行数:35,代码来源:local.c

示例12: test_rebase_merge__custom_merge_options

void test_rebase_merge__custom_merge_options(void)
{
	git_rebase *rebase;
	git_reference *branch_ref, *upstream_ref;
	git_annotated_commit *branch_head, *upstream_head;
	git_rebase_options rebase_options = GIT_REBASE_OPTIONS_INIT;
	git_rebase_operation *rebase_operation;

	rebase_options.merge_options.flags |=
		GIT_MERGE_FAIL_ON_CONFLICT |
		GIT_MERGE_SKIP_REUC;

	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, &rebase_options));

	cl_git_fail_with(GIT_EMERGECONFLICT, git_rebase_next(&rebase_operation, rebase));

	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:J1978,项目名称:libgit2,代码行数:28,代码来源:merge.c

示例13: test_network_remote_remotes__error_when_no_push_available

void test_network_remote_remotes__error_when_no_push_available(void)
{
	git_remote *r;
	git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
	char *specs = {
		"refs/heads/master",
	};
	git_strarray arr = {
		&specs,
		1,
	};


	cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git")));

	callbacks.transport = git_transport_local;
	cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks, NULL));

	/* Make sure that push is really not available */
	r->transport->push = NULL;

	cl_git_fail_with(-1, git_remote_upload(r, &arr, NULL));

	git_remote_free(r);
}
开发者ID:Angolier,项目名称:sonic-pi,代码行数:25,代码来源:remotes.c

示例14: test_repo_init__symlinks_win32_enabled_by_global_config

void test_repo_init__symlinks_win32_enabled_by_global_config(void)
{
#ifndef GIT_WIN32
	cl_skip();
#else
	git_config *config, *repo_config;
	int val;

	if (!filesystem_supports_symlinks("link"))
		cl_skip();

	create_tmp_global_config("tmp_global_config", "core.symlinks", "true");

	/*
	 * Create a new repository (can't use `assert_config_on_init` since we
	 * want to examine configuration levels with more granularity.)
	 */
	cl_git_pass(git_repository_init(&_repo, "config_entry/test.non.bare.git", false));

	/* Ensure that core.symlinks remains set (via the global config). */
	cl_git_pass(git_repository_config(&config, _repo));
	cl_git_pass(git_config_get_bool(&val, config, "core.symlinks"));
	cl_assert_equal_i(1, val);

	/*
	 * Ensure that the repository config does not set core.symlinks.
	 * It should remain inherited.
	 */
	cl_git_pass(git_config_open_level(&repo_config, config, GIT_CONFIG_LEVEL_LOCAL));
	cl_git_fail_with(GIT_ENOTFOUND, git_config_get_bool(&val, repo_config, "core.symlinks"));
	git_config_free(repo_config);

	git_config_free(config);
#endif
}
开发者ID:ethomson,项目名称:libgit2,代码行数:35,代码来源:init.c

示例15: test_core_stream__register_tls

void test_core_stream__register_tls(void)
{
	git_stream *stream;
	int error;

	ctor_called = 0;
	cl_git_pass(git_stream_register_tls(test_ctor));
	cl_git_pass(git_tls_stream_new(&stream, "localhost", "443"));
	cl_assert_equal_i(1, ctor_called);
	cl_assert_equal_p(&test_stream, stream);

	ctor_called = 0;
	stream = NULL;
	cl_git_pass(git_stream_register_tls(NULL));
	error = git_tls_stream_new(&stream, "localhost", "443");

	/* We don't have arbitrary TLS stream support on Windows
	 * or when openssl support is disabled (except on OSX
	 * with Security framework).
	 */
#if defined(GIT_WIN32) || \
	(!defined(GIT_SECURE_TRANSPORT) && !defined(GIT_OPENSSL))
	cl_git_fail_with(-1, error);
#else
	cl_git_pass(error);
#endif

	cl_assert_equal_i(0, ctor_called);
	cl_assert(&test_stream != stream);

	git_stream_free(stream);
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:32,代码来源:stream.c


注:本文中的cl_git_fail_with函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。