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

Re: [PATCH 6/6] submodule: refactor logic to determine changed submodules

From
BWBrandon Williams <bmwill@google.com>
Date
May 1, 2017, 16:49 UTC
Message-ID
<20170501164951.GD39135@google.com>
In-Reply-To
<CAGZ79kYqiSyxtpux77RSGx56Bzj3YA7Tu180=oFbPb1fMgEMkA@mail.gmail.com>
On 04/28, Stefan Beller wrote:
Show 30 quoted lines
> + Heiko, who touched the pushing code end of last year.
> 
> On Fri, Apr 28, 2017 at 4:54 PM, Brandon Williams <bmwill@google.com> wrote:
> > There are currently two instances (fetch and push) where we want to
> > determine if submodules have changed given some revision specification.
> > These two instances don't use the same logic to generate a list of
> > changed submodules and as a result there is a fair amount of code
> > duplication.
> >
> > This patch refactors these two code paths such that they both use the
> > same logic to generate a list of changed submodules.  This also makes it
> > easier for future callers to be able to reuse this logic as they only
> > need to create an argv_array with the revision specification to be using
> > during the revision walk.
> 
> Thanks for doing some refactoring. :)
> 
> > -static struct oid_array *submodule_commits(struct string_list *submodules,
> > -                                           const char *path)
> > ...
> 
> > -static void free_submodules_oids(struct string_list *submodules)
> > -{
> > ...
> 
> These are just moved north, no change in code.
> If you want to be extra nice to reviewers this could have been an extra patch,
> as it makes reviewing easier if you just have to look at the lines of code with
> one goal ("shuffling code around, no change intended" vs "make a change
> to improve things with no bad side effects")

Yeah I suppose, I was having a difficult time breaking this largest patch into multiple.

Show 9 quoted lines
> 
> > +
> > +static void collect_changed_submodules_cb(struct diff_queue_struct *q,
> > +                                         struct diff_options *options,
> > +                                         void *data)
> > +{
> 
> This one combines both collect_submodules_from_diff and
> submodule_collect_changed_cb ?
Yep.
Show 27 quoted lines
> 
> > @@ -921,61 +948,6 @@ int push_unpushed_submodules(struct oid_array *commits,
> >         return ret;
> >  }
> >
> > -static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
> > -{
> > -       int is_present = 0;
> > -       if (!add_submodule_odb(path) && lookup_commit_reference(sha1)) {
> > -               /* Even if the submodule is checked out and the commit is
> > -                * present, make sure it is reachable from a ref. */
> > -               struct child_process cp = CHILD_PROCESS_INIT;
> > -               const char *argv[] = {"rev-list", "-n", "1", NULL, "--not", "--all", NULL};
> > -               struct strbuf buf = STRBUF_INIT;
> > -
> > -               argv[3] = sha1_to_hex(sha1);
> > -               cp.argv = argv;
> > -               prepare_submodule_repo_env(&cp.env_array);
> > -               cp.git_cmd = 1;
> > -               cp.no_stdin = 1;
> > -               cp.dir = path;
> > -               if (!capture_command(&cp, &buf, 1024) && !buf.len)
> > -                       is_present = 1;
> 
> Oh, I see where the nit in patch 5/6 is coming from. Another note
> on that: The hint is way off. The hint should be on the order of
> GIT_SHA1_HEXSZ
Yeah agreed.  I make this change in the earlier patch.
Show 12 quoted lines
> 
> >  int find_unpushed_submodules(struct oid_array *commits,
> >                 const char *remotes_name, struct string_list *needs_pushing)
> > ...
> 
> >  static void calculate_changed_submodule_paths(void)
> > ...
> 
> These are both nicely clean now.
> 
> Thanks,
> Stefan
-- 
Brandon Williams
Previous: Stefan BellerNext: Junio C Hamano
Message 18 of 33 in “changed submodules”
  1. 0/6 changed submodulesBrandon Williams, Apr 28, 2017
  2. 1/6 submodule: rename add_sha1_to_arrayBrandon Williams, Apr 28, 2017
  3. Junio C HamanoMay 1, 2017
  4. 4/6 submodule: change string_list changed_submodule_pathsBrandon Williams, Apr 28, 2017
  5. Junio C HamanoMay 1, 2017
  6. Brandon WilliamsMay 1, 2017
  7. 3/6 submodule: remove add_oid_to_argvBrandon Williams, Apr 28, 2017
  8. 2/6 submodule: rename free_submodules_sha1sBrandon Williams, Apr 28, 2017
  9. 5/6 submodule: improve submodule_has_commitsBrandon Williams, Apr 28, 2017
  10. Stefan BellerApr 29, 2017
  11. Brandon WilliamsApr 30, 2017
  12. Stefan BellerMay 1, 2017
  13. Brandon WilliamsMay 1, 2017
  14. Junio C HamanoMay 1, 2017
  15. Brandon WilliamsMay 1, 2017
  16. 6/6 submodule: refactor logic to determine changed submodulesBrandon Williams, Apr 28, 2017
  17. Stefan BellerApr 29, 2017
  18. Brandon WilliamsMay 1, 2017
  19. Junio C HamanoMay 1, 2017
  20. 0/6 changed submodulesBrandon Williams, May 2, 2017
  21. 1/6 submodule: rename add_sha1_to_arrayBrandon Williams, May 2, 2017
  22. Stefan BellerMay 2, 2017
  23. Brandon WilliamsMay 2, 2017
  24. 2/6 submodule: rename free_submodules_sha1sBrandon Williams, May 2, 2017
  25. 3/6 submodule: remove add_oid_to_argvBrandon Williams, May 2, 2017
  26. 5/6 submodule: improve submodule_has_commitsBrandon Williams, May 2, 2017
  27. Stefan BellerMay 2, 2017
  28. Brandon WilliamsMay 2, 2017
  29. Stefan BellerMay 2, 2017
  30. Brandon WilliamsMay 2, 2017
  31. Brandon WilliamsMay 2, 2017
  32. 6/6 submodule: refactor logic to determine changed submodulesBrandon Williams, May 2, 2017
  33. 4/6 submodule: change string_list changed_submodule_pathsBrandon Williams, May 2, 2017

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.