diff options
author | Russell Belfer <rb@github.com> | 2013-03-23 01:27:56 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-03-23 01:27:56 +0400 |
commit | 1323c6d18049163fc81e5e246e7d4e120c8de03a (patch) | |
tree | a75d2a576d38890a8c009b299ec2cb744d571282 /tests-clar/status | |
parent | 3ba01362437102501a173b9fe072a5690358baa0 (diff) |
Add cl_repo_set_bool and cleanup tests
This adds a helper function for the cases where you want to
quickly set a single boolean config value for a repository.
This allowed me to remove a lot of code.
Diffstat (limited to 'tests-clar/status')
-rw-r--r-- | tests-clar/status/worktree.c | 19 | ||||
-rw-r--r-- | tests-clar/status/worktree_init.c | 5 |
2 files changed, 6 insertions, 18 deletions
diff --git a/tests-clar/status/worktree.c b/tests-clar/status/worktree.c index b5449f6f1..5b11d1f82 100644 --- a/tests-clar/status/worktree.c +++ b/tests-clar/status/worktree.c @@ -470,15 +470,14 @@ void test_status_worktree__filemode_changes(void) git_repository *repo = cl_git_sandbox_init("filemodes"); status_entry_counts counts; git_status_options opts = GIT_STATUS_OPTIONS_INIT; - git_config *cfg; /* overwrite stored filemode with platform appropriate value */ - cl_git_pass(git_repository_config(&cfg, repo)); if (cl_is_chmod_supported()) - cl_git_pass(git_config_set_bool(cfg, "core.filemode", true)); + cl_repo_set_bool(repo, "core.filemode", true); else { int i; - cl_git_pass(git_config_set_bool(cfg, "core.filemode", false)); + + cl_repo_set_bool(repo, "core.filemode", false); /* won't trust filesystem mode diffs, so these will appear unchanged */ for (i = 0; i < filemode_count; ++i) @@ -502,8 +501,6 @@ void test_status_worktree__filemode_changes(void) 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); - - git_config_free(cfg); } static int cb_status__interrupt(const char *p, unsigned int s, void *payload) @@ -533,12 +530,9 @@ void test_status_worktree__interruptable_foreach(void) void test_status_worktree__line_endings_dont_count_as_changes_with_autocrlf(void) { git_repository *repo = cl_git_sandbox_init("status"); - git_config *config; unsigned int status; - cl_git_pass(git_repository_config(&config, repo)); - cl_git_pass(git_config_set_bool(config, "core.autocrlf", true)); - git_config_free(config); + cl_repo_set_bool(repo, "core.autocrlf", true); cl_git_rewritefile("status/current_file", "current_file\r\n"); @@ -621,7 +615,6 @@ static void assert_ignore_case( int expected_lower_cased_file_status, int expected_camel_cased_file_status) { - git_config *config; unsigned int status; git_buf lower_case_path = GIT_BUF_INIT, camel_case_path = GIT_BUF_INIT; git_repository *repo, *repo2; @@ -629,9 +622,7 @@ static void assert_ignore_case( repo = cl_git_sandbox_init("empty_standard_repo"); cl_git_remove_placeholders(git_repository_path(repo), "dummy-marker.txt"); - cl_git_pass(git_repository_config(&config, repo)); - cl_git_pass(git_config_set_bool(config, "core.ignorecase", should_ignore_case)); - git_config_free(config); + cl_repo_set_bool(repo, "core.ignorecase", should_ignore_case); cl_git_pass(git_buf_joinpath(&lower_case_path, git_repository_workdir(repo), "plop")); diff --git a/tests-clar/status/worktree_init.c b/tests-clar/status/worktree_init.c index 0c34dde87..b67107aec 100644 --- a/tests-clar/status/worktree_init.c +++ b/tests-clar/status/worktree_init.c @@ -316,15 +316,13 @@ void test_status_worktree_init__new_staged_file_must_handle_crlf(void) { git_repository *repo; git_index *index; - git_config *config; unsigned int status; cl_set_cleanup(&cleanup_new_repo, "getting_started"); cl_git_pass(git_repository_init(&repo, "getting_started", 0)); // Ensure that repo has core.autocrlf=true - cl_git_pass(git_repository_config(&config, repo)); - cl_git_pass(git_config_set_bool(config, "core.autocrlf", true)); + cl_repo_set_bool(repo, "core.autocrlf", true); cl_git_mkfile("getting_started/testfile.txt", "content\r\n"); // Content with CRLF @@ -335,7 +333,6 @@ void test_status_worktree_init__new_staged_file_must_handle_crlf(void) cl_git_pass(git_status_file(&status, repo, "testfile.txt")); cl_assert_equal_i(GIT_STATUS_INDEX_NEW, status); - git_config_free(config); git_index_free(index); git_repository_free(repo); } |