Skip to contentSkip to conversation

git-config --rename-section could rename wrong section

PATCH New Pavel Roskin 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-config --rename-section could rename wrong section

The "git-config --rename-section" implementation would match sections that are substrings of the section name to be renamed.

---

 config.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
config.c +1 -1
index c08c668..d821071 100644
@@ -896,7 +896,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
 				if (buf[i] != old_name[j++])
 					break;
 			}
-			if (buf[i] == ']') {
+			if (buf[i] == ']' && old_name[j] == 0) {
 				/* old_name matches */
 				ret++;
 				store.baselen = strlen(new_name);