Re: [PATCH 3/5] fetch-pack: introduce `fetch_pack_options`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 22, 2024, 03:46 UTC
- Message-ID
- <xmqq5xogaq2u.fsf@gitster.g>
- In-Reply-To
- <xmqqjzcwca74.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 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.