提交 5463caab 编写于 作者: S Sahil Dua 提交者: Junio C Hamano

config: create a function to format section headers

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: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: NRamsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: NSahil Dua <sahildua2305@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 41dd4330
......@@ -2169,10 +2169,10 @@ static int write_error(const char *filename)
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);
......@@ -2188,6 +2188,15 @@ static int store_write_section(int fd, const char *key)
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册