git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 3/3] batch check whether submodule needs pushing into one call

From
Stefan Beller <sbeller@google.com>
Date
Oct 7, 2016, 18:30 UTC
Message-ID
<CAGZ79kYZbkXFLABdiQwTLLJ42CnV5OPWA5ESe0VfZLvrkQRWfA@mail.gmail.com>
In-Reply-To
<67d4c48dc0129f20041c88d27a49c7a21188c882.1475851621.git.hvoigt@hvoigt.net>
On Fri, Oct 7, 2016 at 8:06 AM, Heiko Voigt <hvoigt@hvoigt.net> wrote:
Show 44 quoted lines
> We run a command for each sha1 change in a submodule. This is
> unnecessary since we can simply batch all sha1's we want to check into
> one command. Lets do it so we can speedup the check when many submodule
> changes are in need of checking.
>
> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
> ---
>  submodule.c | 63 +++++++++++++++++++++++++++++++++----------------------------
>  1 file changed, 34 insertions(+), 29 deletions(-)
>
> diff --git a/submodule.c b/submodule.c
> index 5044afc2f8..a05c2a34b1 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -529,27 +529,49 @@ static int append_hash_to_argv(const unsigned char sha1[20], void *data)
>         return 0;
>  }
>
> -static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
> +static int check_has_hash(const unsigned char sha1[20], void *data)
>  {
> -       if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
> +       int *has_hash = (int *) data;
> +
> +       if (!lookup_commit_reference(sha1))
> +               *has_hash = 0;
> +
> +       return 0;
> +}
> +
> +static int submodule_has_hashes(const char *path, struct sha1_array *hashes)
> +{
> +       int has_hash = 1;
> +
> +       if (add_submodule_odb(path))
> +               return 0;
> +
> +       sha1_array_for_each_unique(hashes, check_has_hash, &has_hash);
> +       return has_hash;
> +}
> +
> +static int submodule_needs_pushing(const char *path, struct sha1_array *hashes)
> +{
> +       if (!submodule_has_hashes(path, hashes))

So the above is an implicit lookup already, but we did that before, too, so it's fine.

Show 16 quoted lines
> @@ -658,13 +665,11 @@ int find_unpushed_submodules(struct sha1_array *hashes,
>         argv_array_clear(&argv);
>
>         for (i = 0; i < submodules.nr; i++) {
> -               struct string_list_item *item = &submodules.items[i];
> -               struct collect_submodule_from_sha1s_data data;
> -               data.submodule_path = item->string;
> -               data.needs_pushing = needs_pushing;
> -               sha1_array_for_each_unique((struct sha1_array *) item->util,
> -                               collect_submodules_from_sha1s,
> -                               &data);
> +               struct string_list_item *submodule = &submodules.items[i];
> +               struct sha1_array *hashes = (struct sha1_array *) submodule->util;
> +
> +               if (submodule_needs_pushing(submodule->string, hashes))
> +                       string_list_insert(needs_pushing, submodule->string);
That makes sense.

Thanks! Stefan

Previous: Heiko VoigtNext: Junio C Hamano
Message 15 of 19 in “Speedup finding of unpushed submodules”
  1. 0/3 Speedup finding of unpushed submodulesHeiko Voigt, Oct 7, 2016
  2. 1/3 serialize collection of changed submodulesHeiko Voigt, Oct 7, 2016
  3. Stefan BellerOct 7, 2016
  4. Junio C HamanoOct 10, 2016
  5. Heiko VoigtOct 12, 2016
  6. Junio C HamanoOct 12, 2016
  7. Heiko VoigtOct 13, 2016
  8. Heiko VoigtOct 12, 2016
  9. 2/3 serialize collection of refs that contain submodule changesHeiko Voigt, Oct 7, 2016
  10. Stefan BellerOct 7, 2016
  11. Heiko VoigtOct 12, 2016
  12. Stefan BellerOct 20, 2016
  13. Junio C HamanoOct 10, 2016
  14. 3/3 batch check whether submodule needs pushing into one callHeiko Voigt, Oct 7, 2016
  15. Stefan BellerOct 7, 2016
  16. Junio C HamanoOct 10, 2016
  17. Heiko VoigtOct 12, 2016
  18. Junio C HamanoOct 12, 2016
  19. Heiko VoigtOct 13, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.