Thread (1 message) 1 message, 1 author, 2024-11-22

Re: [PATCH 3/5] fetch-pack: introduce `fetch_pack_options`

From: Junio C Hamano <hidden>
Date: 2024-11-22 03:46:04

Junio C Hamano [off-list ref] writes:
Assuming that the shell structure is necessary around it, the code
changes in this patch looks sensible to me.
Ah, another thing.  It would make more sense to do

    good_example(args, struct foo *opt)
    {
	struct foo opt_fallback = { ... init ... };

	if (!opt)
		opt = &opt_fallback;
	...
	use opt->foo and opt->bar
    }

instead of what the patch did with structure assignment, i.e.

    bad_example(args, struct foo *opt_)
    {
	struct foo opt = { ... init ... };

	if (opt_)
		opt = *opt_;
	...
	use opt.foo and opt.bar
    }

because the latter, via structure assignment, always raises "who
owns this piece of data?" question once you start adding more
complex things in the "struct foo", like a strbuf that holds the
fsck configuration data.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help