Re: [PATCH v2 15/18] test-reach: test commit_contains
- From
Derrick Stolee <stolee@gmail.com>
- Date
- Jul 25, 2018, 18:30 UTC
- Message-ID
- <0c8b2860-3de7-e7fd-da07-9f2ae27e2e8f@gmail.com>
- In-Reply-To
- <xmqqr2jrur1m.fsf@gitster-ct.c.googlers.com>
On 7/25/2018 2:08 PM, Junio C Hamano wrote:
Show 16 quoted lines
> Jonathan Tan <jonathantanmy@google.com> writes:
>
>>> + } else if (!strcmp(av[1], "commit_contains")) {
>>> + struct ref_filter filter;
>>> + struct contains_cache cache;
>>> + init_contains_cache(&cache);
>>> +
>>> + if (ac > 2 && !strcmp(av[2], "--tag"))
>>> + filter.with_commit_tag_algo = 1;
>>> + else
>>> + filter.with_commit_tag_algo = 0;
>>> +
>>> + printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
>> Should we initialize filter (with {NULL} or some equivalent)?
> Sounds like a sensible suggestion. Wouldn't we segfault otherwise
> depending on what garbage bytes are on the stack?It's a good idea to initialize the struct properly, but the only part of the 'filter' struct that is accessed by that method is the 'with_commit_tag_algo' member. Everything else is read from A, X, and cache.
Thanks, -Stolee