diff options
| author | Vicent Martà <vicent@github.com> | 2012-06-18 17:50:12 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-06-18 17:50:12 -0700 |
| commit | 68f527c4480f0c1e24f29dc0a2337469fe50967f (patch) | |
| tree | 8049acfcc94855ab4a04c9e8f0c3ea1bfc9e6888 /tests-clar/config/write.c | |
| parent | 8c4c357f1830c246c1935c84aacc606e5d0762be (diff) | |
| parent | 67d334c1cd569d13b1709c3ef1864d630e608c95 (diff) | |
| download | libgit2-68f527c4480f0c1e24f29dc0a2337469fe50967f.tar.gz | |
Merge pull request #758 from libgit2/config-values-containing-quotes
Quotes inside config values don't survive serialization/deserialization
Diffstat (limited to 'tests-clar/config/write.c')
| -rw-r--r-- | tests-clar/config/write.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests-clar/config/write.c b/tests-clar/config/write.c index f8774473e..13b669cb2 100644 --- a/tests-clar/config/write.c +++ b/tests-clar/config/write.c @@ -90,3 +90,49 @@ void test_config_write__delete_inexistent(void) cl_assert(git_config_delete(cfg, "core.imaginary") == GIT_ENOTFOUND); git_config_free(cfg); } + +void test_config_write__value_containing_quotes(void) +{ + git_config *cfg; + const char* str; + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_set_string(cfg, "core.somevar", "this \"has\" quotes")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this \"has\" quotes"); + git_config_free(cfg); + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this \"has\" quotes"); + git_config_free(cfg); + + /* The code path for values that already exist is different, check that one as well */ + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_set_string(cfg, "core.somevar", "this also \"has\" quotes")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this also \"has\" quotes"); + git_config_free(cfg); + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this also \"has\" quotes"); + git_config_free(cfg); +} + +void test_config_write__escape_value(void) +{ + git_config *cfg; + const char* str; + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_set_string(cfg, "core.somevar", "this \"has\" quotes and \t")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this \"has\" quotes and \t"); + git_config_free(cfg); + + cl_git_pass(git_config_open_ondisk(&cfg, "config9")); + cl_git_pass(git_config_get_string(&str, cfg, "core.somevar")); + cl_assert_equal_s(str, "this \"has\" quotes and \t"); + git_config_free(cfg); +} |
