Re: [PATCH 8/9] git_config_set: use do_config_from_file() directly
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Mar 30, 2018, 13:02 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1803301500560.5026@qfpub.tvgsbejvaqbjf.bet>
- In-Reply-To
- <20180329213823.GH2939@sigill.intra.peff.net>
Hi Peff,
On Thu, 29 Mar 2018, Jeff King wrote:
Show 25 quoted lines
> On Thu, Mar 29, 2018 at 05:19:04PM +0200, Johannes Schindelin wrote: > > > Technically, it is the git_config_set_multivar_in_file_gently() > > function that we modify here (but the oneline would get too long if we > > were that precise). > > > > This change prepares the git_config_set machinery to allow reusing empty > > sections, by using the file-local function do_config_from_file() > > directly (whose signature can then be changed without any effect outside > > of config.c). > > > > An incidental benefit is that we avoid a level of indirection, and we > > also avoid calling flockfile()/funlockfile() when we already know that > > we are not operating on stdin/stdout here. > > I'm not sure I understand that last paragraph. What does flockfile() have > to do with stdin/stdout? > > The point of those calls is that we're locking the FILE handle, so that > it's safe for the lower-level config code to run getc_unlocked(), which > is faster. > > So without those, we're calling getc_unlocked() without holding the > lock. I think it probably works in practice because we know that we're > single-threaded, but it seems a bit sketchy.
Oops. I misunderstood the purpose of flockfile(), then. I thought it was only about multiple users of stdin/stdout.
Will have a look whether flockfile()/funlockfile() can be moved into do_config_from_file() instead.
Ciao, Dscho