From 2a9eee6957c1d32330af8600ed45dbae3fcaa9d4 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Fri, 15 Nov 2013 14:55:40 +0000 Subject: config: Enhance config_rename_section error handling --- src/config.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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); -- cgit v1.2.1