config: Enhance config_rename_section error handling
diff --git a/src/config.c b/src/config.c
index 0d94713..abf018e 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1205,6 +1205,8 @@
 	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 @@
 	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);