Re: [PATCH 1/3] config: create a function to format section headers
On Tue, Jun 13, 2017 at 6:17 PM, Sahil Dua wrote: > Factor out the logic which creates section headers in the config file, > e.g. the 'branch.foo' key will be turned into '[branch "foo"]'. +CC Junio: This is to be applied, Sahil is using submitgit which apparently doesn't CC you by default (I don't know if there's some option for that he missed). Also +CC Lars who hacked up -m initially, Alex who hacked on some of the logic of git_config_rename_section(), and Johannes who also hacked on some of the guts of that code. Also, in the interest of full disclosure. Sahil's a co-worker of mine who I've been mentoring on how to submit changes to git.git, after I added a note to the internal company announcement saying I'd upgraded git advertising that I'd be happy to help anyone who's interested contribute to the project. That explains the off-list review & Sahil submitting a patch of mine first seen as part of this series.
Re: [PATCH 1/3] config: create a function to format section headers
Sahil Dua writes: > 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: Sahil Dua > Signed-off-by: Ævar Arnfjörð Bjarmason > --- > config.c | 13 +++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/config.c b/config.c > index 146cb3452adab..d5bb69e925dac 100644 > --- a/config.c > +++ b/config.c > @@ -2169,10 +2169,10 @@ static int write_error(const char *filename) > return 4; > } > > -static int store_write_section(int fd, const char *key) > +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); > > > -- > https://github.com/git/git/pull/363 Makes sense.
[PATCH 1/3] 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: Sahil Dua Signed-off-by: Ævar Arnfjörð Bjarmason --- config.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index 146cb3452adab..d5bb69e925dac 100644 --- a/config.c +++ b/config.c @@ -2169,10 +2169,10 @@ static int write_error(const char *filename) return 4; } -static int store_write_section(int fd, const char *key) +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); -- https://github.com/git/git/pull/363