Factor out the logic which creates section headers in the config file,
e.g. the 'branch.foo' key will be turned into '[branch "foo"]'.
This introduces no function changes, but is needed for a later change
which adds support for copying branch sections in the config file.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
Signed-off-by: Ramsay Jones <redacted>
Signed-off-by: Sahil Dua <redacted>
Signed-off-by: Junio C Hamano <redacted>
return 4;
}
-static int store_write_section(int fd, const char *key)
+static struct strbuf store_create_section(const char *key)
{
const char *dot;
- int i, success;
+ int i;
struct strbuf sb = STRBUF_INIT;
dot = memchr(key, '.', store.baselen);
strbuf_addf(&sb, "[%.*s]\n", store.baselen, key);
}
+ return sb;
+}
+
+static int store_write_section(int fd, const char *key)
+{
+ int success;
+
+ struct strbuf sb = store_create_section(key);
+
success = write_in_full(fd, sb.buf, sb.len) == sb.len;
strbuf_release(&sb);