diff options
author | nulltoken <emeric.fermas@gmail.com> | 2013-11-15 14:55:40 +0000 |
---|---|---|
committer | nulltoken <emeric.fermas@gmail.com> | 2013-11-15 15:36:58 +0000 |
commit | 2a9eee6957c1d32330af8600ed45dbae3fcaa9d4 (patch) | |
tree | e3e08d9c4ecbcf62647aadc7a07e17b51dc7b6e1 /src/config.c | |
parent | 845eed800a85b0c51cead6c17e3cb4013564fb37 (diff) | |
download | libgit2-2a9eee6957c1d32330af8600ed45dbae3fcaa9d4.tar.gz |
config: Enhance config_rename_section error handlingntk/topic/config_rename_better_error
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c index 0d9471383..abf018ee6 100644 --- a/src/config.c +++ b/src/config.c @@ -1205,6 +1205,8 @@ int git_config_rename_section( int error = 0; struct rename_data data; + assert(repo && old_section_name); + git_buf_text_puts_escape_regex(&pattern, old_section_name); if ((error = git_buf_puts(&pattern, "\\..+")) < 0) @@ -1236,6 +1238,15 @@ int git_config_rename_section( if (error == GIT_EUSER) error = data.actual_error; + if (error < 0) { + if (!new_section_name) + giterr_set(GITERR_CONFIG, "Cannot remove config section '%s'", + old_section_name); + else + giterr_set(GITERR_CONFIG, "Cannot rename config section '%s' to '%s'", + old_section_name, new_section_name); + } + cleanup: git_buf_free(&pattern); git_buf_free(&replace); |