From: Eli Barzilay <eli@barzilay.org>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
Andreas Schwab <schwab@linux-m68k.org>,
git@vger.kernel.org
Subject: Re: Minor bug: git config ignores empty sections
Date: Tue, 16 Aug 2016 00:06:56 -0400 [thread overview]
Message-ID: <CALO-guvVMFitNdGYEonXZ9rh8g8=L9gZojXVUu7FO2_0ki24EQ@mail.gmail.com> (raw)
In-Reply-To: <20160815185500.htgrz3t2wkztg4ww@sigill.intra.peff.net>
On Mon, Aug 15, 2016 at 2:55 PM, Jeff King <peff@peff.net> wrote:
> On Mon, Aug 15, 2016 at 11:28:20AM -0700, Junio C Hamano wrote:
>
>> I notice that we have thought about all the issues when we last
>> discussed it in 2013. Refining a message from the earlier thread,
>> as it illustrates tricky cases in which we have to be careful.
>
> Thanks for digging up the threads that I was too lazy to find.
>
> I agree with most everything here, though I would be happy if somebody
> even wrote a patch to handle the "easy" cases.
So it sounds like removing an empty header is problematic in most cases,
but adding a new variable to an existing empty header should not be...?
I looked at the code, and had a rough sketch that works as follows:
* Make git_parse_source() call the callback in a special way to note
that a section header is seen (I hacked it by passing a special value,
a pointer to a global string, as the second argument)
* Add a new store.last_section_offset field
* In store_aux(), if it's getting the special value, and the section
name matches, save the offset in store.last_section_offset
* In git_config_set_multivar_in_file_gently() right before the "write
the first part of the config" comment, test that
(store.seen == 1 && copy_begin == 0 && copy_end == contents_sz
&& store.last_section_offset > 0)
and if so, write the contents up to that point, and set copy_begin;
if the condition is false, do the same thing it does now
* A bit after that, add "&& store.last_section_offset == 0" to the
condition that decides whether to call store_write_section()
It looks to me like something like this can work, but it's very hacky
because I wanted to see if it can work quickly, and because I don't know
if this kind of a solution will be wanted, and because I don't know
enough about that code in general. Making it be an actual solution
involves a better way to call the callback in a special way (my hack
does the special thing only if `fn==store_aux`, but it shouldn't),
calling it after the last variable in a section is seen so it's added
after that.
So, will something like this be acceptable? If so, is there anyone who
I can ask questions about the code?
--
((x=>x(x))(x=>x(x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
next prev parent reply other threads:[~2016-08-16 4:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-15 1:29 Minor bug: git config ignores empty sections Eli Barzilay
2016-08-15 12:09 ` Jeff King
2016-08-15 17:34 ` Andreas Schwab
2016-08-15 18:09 ` Jeff King
2016-08-15 18:28 ` Junio C Hamano
2016-08-15 18:54 ` Andreas Schwab
2016-08-15 18:55 ` Jeff King
2016-08-15 20:49 ` Junio C Hamano
2016-08-16 4:06 ` Eli Barzilay [this message]
2016-08-16 12:36 ` Jeff King
2016-08-21 17:09 ` Jakub Narębski
2016-08-15 17:46 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CALO-guvVMFitNdGYEonXZ9rh8g8=L9gZojXVUu7FO2_0ki24EQ@mail.gmail.com' \
--to=eli@barzilay.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).