Re: [GSoC][PATCH v2 2/4] submodule--helper: introduce for_each_submodule()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 23, 2017, 19:13 UTC
- Message-ID
- <xmqqbmn6yu5u.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170823181506.8557-3-pc44800@gmail.com>
Prathamesh Chavan <pc44800@gmail.com> writes:
Show 13 quoted lines
> +typedef void (*submodule_list_func_t)(const struct cache_entry *list_item,
> + void *cb_data);
> +
> static char *get_default_remote(void)
> {
> char *dest = NULL, *ret;
> @@ -353,17 +356,30 @@ static int module_list(int argc, const char **argv, const char *prefix)
> return 0;
> }
>
> -static void init_submodule(const char *path, const char *prefix, int quiet)
> +static void for_each_submodule(const struct module_list *list,
> + submodule_list_func_t fn, void *cb_data)In the output from
$ git grep for_each \*.h
we find that the convention is that an interator over a group of X is for_each_X, the callback function that is given to for_each_X is of type each_X_fn. An interator over a subset of group of X that has trait Y, for_each_Y_X() iterates and calls back a function of type each_X_fn (e.g. for_each_tag_ref() still calls each_ref_fn).
I do not offhand think of a reason why the above code need to deviate from that pattern.