diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-03-30 07:27:42 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@elego.de> | 2013-04-11 14:27:25 +0400 |
commit | d59942c2aba2fa5f9570b37e3bc9eaf34f16d671 (patch) | |
tree | 1afd5eb25931f18f1579176741ac9883eac84e16 /tests-clar/refs | |
parent | 97016f29ab2359da5c59e2acae6369794fceb9d4 (diff) |
branch: add more upstream configuration management
Add functions to set and unset the upstream configuration to
complement the getter we already have.
Diffstat (limited to 'tests-clar/refs')
-rw-r--r-- | tests-clar/refs/branches/upstream.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests-clar/refs/branches/upstream.c b/tests-clar/refs/branches/upstream.c index fca254161..2d0ebd240 100644 --- a/tests-clar/refs/branches/upstream.c +++ b/tests-clar/refs/branches/upstream.c @@ -93,3 +93,38 @@ void test_refs_branches_upstream__retrieve_a_remote_tracking_reference_from_a_br cl_git_sandbox_cleanup(); } + +void test_refs_branches_upstream__set_unset_upstream(void) +{ + git_reference *branch; + git_repository *repository; + const char *value; + git_config *config; + + repository = cl_git_sandbox_init("testrepo.git"); + + cl_git_pass(git_reference_lookup(&branch, repository, "refs/heads/test")); + cl_git_pass(git_branch_set_upstream(branch, "test/master")); + + cl_git_pass(git_repository_config(&config, repository)); + cl_git_pass(git_config_get_string(&value, config, "branch.test.remote")); + cl_assert_equal_s(value, "test"); + cl_git_pass(git_config_get_string(&value, config, "branch.test.merge")); + cl_assert_equal_s(value, "refs/heads/master"); + + cl_git_pass(git_branch_set_upstream(branch, NULL)); + cl_git_fail_with(git_config_get_string(&value, config, "branch.test.merge"), GIT_ENOTFOUND); + cl_git_fail_with(git_config_get_string(&value, config, "branch.test.remote"), GIT_ENOTFOUND); + + git_reference_free(branch); + + cl_git_pass(git_reference_lookup(&branch, repository, "refs/heads/master")); + cl_git_pass(git_branch_set_upstream(branch, NULL)); + cl_git_fail_with(git_config_get_string(&value, config, "branch.master.merge"), GIT_ENOTFOUND); + cl_git_fail_with(git_config_get_string(&value, config, "branch.master.remote"), GIT_ENOTFOUND); + + git_reference_free(branch); + + git_config_free(config); + cl_git_sandbox_cleanup(); +} |