Re: [PATCH v2 1/3] config: create a function to format section headers
- From
Sahil Dua <sahildua2305@gmail.com>
- Date
- Jun 19, 2017, 14:51 UTC
- Message-ID
- <CALiud+=By79=ngbi6KoeSEW7PYAhrZR2my_=objq8Mgmx7h-RQ@mail.gmail.com>
- In-Reply-To
- <087c8d6e-10f0-2c1f-1974-a97f4f685288@ramsayjones.plus.com>
On Mon, Jun 19, 2017 at 2:08 PM, Ramsay Jones <ramsay@ramsayjones.plus.com> wrote:
Show 15 quoted lines
> > > On 18/06/17 22:16, 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"]'. >> >> 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 <avarab@gmail.com> >> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> > > Adding my SOB isn't really appropriate here - I only made a very > very minor contribution. At _most_ you might consider 'Helped-by:', > but even that would probably be overkill. ;-)
You sent a minor patch and I just applied it and squashed into my patch. I'm okay with keeping your SOB, unless it's not appropriate to keep it. (it's my first patch, so advise me. I don't have a strong preference.)
Show 46 quoted lines
>
> Thanks.
>
> ATB,
> Ramsay Jones
>
>
>> Signed-off-by: Sahil Dua <sahildua2305@gmail.com>
>> ---
>> config.c | 13 +++++++++++--
>> 1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/config.c b/config.c
>> index 34a139c..32fd3c8 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)
>> +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);
>>
>>