Re: [PATCH 8/9] git_config_set: use do_config_from_file() directly
- From
Jeff King <peff@peff.net>
- Date
- Mar 30, 2018, 14:08 UTC
- Message-ID
- <20180330140840.GA5869@sigill.intra.peff.net>
- In-Reply-To
- <nycvar.QRO.7.76.6.1803301558360.5026@qfpub.tvgsbejvaqbjf.bet>
On Fri, Mar 30, 2018 at 04:01:56PM +0200, Johannes Schindelin wrote:
Show 25 quoted lines
> You know what is *really* funny?
>
> -- snip --
> static int git_config_from_stdin(config_fn_t fn, void *data)
> {
> return do_config_from_file(fn, CONFIG_ORIGIN_STDIN, "", NULL, stdin, data, 0);
> }
>
> int git_config_from_file(config_fn_t fn, const char *filename, void *data)
> {
> int ret = -1;
> FILE *f;
>
> f = fopen_or_warn(filename, "r");
> if (f) {
> flockfile(f);
> ret = do_config_from_file(fn, CONFIG_ORIGIN_FILE, filename, filename, f, data, 0);
> funlockfile(f);
> fclose(f);
> }
> return ret;
> }
> -- snap --
>
> So the _stdin variant *goes out of its way not to flockfile()*...*facepalm* That's probably my fault, since git_config_from_stdin() existed already when I did the flockfile stuff.
Probably the flockfile should go into do_config_from_file(), where we specify to use the unlocked variants.
Show 6 quoted lines
> But I guess all this will become moot when I start handing down the config > options. It does mean that I have to change the signatures in header > files, oh well ;-) > > But then I can drop this here patch and we can stop musing about > flockfile() ;-)
Yeah, I'll wait to see how your refactor turns out.
-Peff