summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorAlex Vandiver <alex@chmrr.net>2009-07-24 17:21:44 -0400
committerJunio C Hamano <gitster@pobox.com>2009-07-24 23:42:44 -0700
commit9a5abfc737b18c23d060ff3be1ee8df560b81fa5 (patch)
treed3775b7cf9119856b46adb359dcb8b896487c887 /config.c
parenta4c0d463c0a1b38b7af45c1e7dd5608860eb1e28 (diff)
downloadgit-9a5abfc737b18c23d060ff3be1ee8df560b81fa5.tar.gz
After renaming a section, print any trailing variable definitions
Signed-off-by: Alex Vandiver <alex@chmrr.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/config.c b/config.c
index 8d0e549976..738b24419d 100644
--- a/config.c
+++ b/config.c
@@ -1237,6 +1237,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
while (fgets(buf, sizeof(buf), config_file)) {
int i;
int length;
+ char *output = buf;
for (i = 0; buf[i] && isspace(buf[i]); i++)
; /* do nothing */
if (buf[i] == '[') {
@@ -1253,14 +1254,29 @@ int git_config_rename_section(const char *old_name, const char *new_name)
ret = write_error(lock->filename);
goto out;
}
- continue;
+ /*
+ * We wrote out the new section, with
+ * a newline, now skip the old
+ * section's length
+ */
+ output += offset + i;
+ if (strlen(output) > 0) {
+ /*
+ * More content means there's
+ * a declaration to put on the
+ * next line; indent with a
+ * tab
+ */
+ output -= 1;
+ output[0] = '\t';
+ }
}
remove = 0;
}
if (remove)
continue;
- length = strlen(buf);
- if (write_in_full(out_fd, buf, length) != length) {
+ length = strlen(output);
+ if (write_in_full(out_fd, output, length) != length) {
ret = write_error(lock->filename);
goto out;
}