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

Re: [PATCH] fetch: Get submodule paths from index and not from .gitmodules

From
Kevin Ballard <kevin@sb.org>
Date
Sep 16, 2010, 19:29 UTC
Message-ID
<AF9B7F7E-0956-4814-A3A8-BAD7619A043D@sb.org>
In-Reply-To
<4C9221B6.7070807@web.de>
Unfortunately, the only effect this had was to change the order of fetches (it now appears to be case-sensitive alphabetical). After applying this patch, this is what I saw (using the same terms as my previous email):

Fetching submodule G Fetching submodule B Fetching submodule F Fetching submodule C Fetching submodule H Fetching submodule E Fetching submodule A Fetching submodule D

Note that it's still telling me that it's fetching submodule H even though this inside of submodule C rather than at the root level. I also verified this by running `git ls-tree -r HEAD | grep commit` and observed that only submodules A-G show up in that list.
-Kevin Ballard
On Sep 16, 2010, at 6:55 AM, Jens Lehmann wrote:
Show 84 quoted lines
> In the first version the .gitmodules file was parsed and all submodules
> found there were recursively fetched. This lead to problems when the
> .gitmodules file was not properly set up. "git submodule update" gets
> this information from the index via "git ls-files", lets do the same here.
> 
> Reported-by: Kevin Ballard <kevin@sb.org>
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
> 
> Could it be that the information in your .gitmodules files is not
> quite right? Then this patch should fix your problems with the
> recursion. Please test it and let me know if the submodules are
> now recursively fetched as they should.
> 
> 
> submodule.c |   25 +++++++++++++++++++------
> 1 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/submodule.c b/submodule.c
> index 05661e2..13a694b 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -240,7 +240,7 @@ void show_submodule_summary(FILE *f, const char *path,
> 
> int fetch_populated_submodules(int forced)
> {
> -	int result = 0;
> +	int i, result = 0;
> 	struct child_process cp;
> 	const char *argv[] = {
> 		"fetch",
> @@ -251,6 +251,10 @@ int fetch_populated_submodules(int forced)
> 	if (!work_tree)
> 		return 0;
> 
> +	if (!the_index.initialized)
> +		if (read_cache() < 0)
> +			die("index file corrupt");
> +
> 	memset(&cp, 0, sizeof(cp));
> 	cp.argv = argv;
> 	cp.env = local_repo_env;
> @@ -258,25 +262,34 @@ int fetch_populated_submodules(int forced)
> 	cp.no_stdin = 1;
> 	cp.out = -1;
> 
> -	for_each_string_list_item(name_for_path, &config_name_for_path) {
> +	for (i = 0; i < active_nr; i++) {
> 		struct strbuf submodule_path = STRBUF_INIT;
> 		struct strbuf submodule_git_dir = STRBUF_INIT;
> -		const char *git_dir;
> +		struct cache_entry *ce = active_cache[i];
> +		const char *git_dir, *name;
> +
> +		if (!S_ISGITLINK(ce->ce_mode))
> +			continue;
> +
> +		name = ce->name;
> +		name_for_path = unsorted_string_list_lookup(&config_name_for_path, ce->name);
> +		if (name_for_path)
> +			name = name_for_path->util;
> 
> 		if (!forced) {
> 			struct string_list_item *fetch_option;
> -			fetch_option = unsorted_string_list_lookup(&config_fetch_for_name, name_for_path->util);
> +			fetch_option = unsorted_string_list_lookup(&config_fetch_for_name, name);
> 			if (fetch_option && !fetch_option->util)
> 				continue;
> 		}
> 
> -		strbuf_addf(&submodule_path, "%s/%s", work_tree, name_for_path->string);
> +		strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
> 		strbuf_addf(&submodule_git_dir, "%s/.git", submodule_path.buf);
> 		git_dir = read_gitfile_gently(submodule_git_dir.buf);
> 		if (!git_dir)
> 			git_dir = submodule_git_dir.buf;
> 		if (is_directory(git_dir)) {
> -			printf("Fetching submodule %s\n", name_for_path->string);
> +			printf("Fetching submodule %s\n", ce->name);
> 			cp.dir = submodule_path.buf;
> 			if (run_command(&cp))
> 				result = 1;
> -- 
> 1.7.3.rc2.232.g3328
Previous: Jens LehmannNext: Jens Lehmann
Message 13 of 55 in “Teach fetch and pull to recursively fetch submodules too”
  1. 0/2 Teach fetch and pull to recursively fetch submodules tooJens Lehmann, Aug 29, 2010
  2. 1/2 fetch/pull: Recursively fetch populated submodulesJens Lehmann, Aug 29, 2010
  3. 2/2 Submodules: Add the new "fetch" config optionJens Lehmann, Aug 29, 2010
  4. Junio C HamanoAug 30, 2010
  5. 2/2 Submodules: Add the new "fetch" config option for fetch and pullJens Lehmann, Aug 30, 2010
  6. Ævar Arnfjörð BjarmasonAug 29, 2010
  7. Jens LehmannAug 29, 2010
  8. Junio C HamanoAug 30, 2010
  9. Jens LehmannAug 30, 2010
  10. Kevin BallardSep 15, 2010
  11. Kevin BallardSep 15, 2010
  12. fetch: Get submodule paths from index and not from .gitmodulesJens Lehmann, Sep 16, 2010
  13. Kevin BallardSep 16, 2010
  14. Jens LehmannSep 17, 2010
  15. Johannes SixtSep 17, 2010
  16. Jens LehmannSep 17, 2010
  17. Johannes SixtSep 17, 2010
  18. Jens LehmannSep 17, 2010
  19. Johannes SixtSep 17, 2010
  20. Kevin BallardSep 18, 2010
  21. 0/2 fix problems with recursive submodule fetchingJens Lehmann, Sep 18, 2010
  22. 1/2 fetch: Fix a bug swallowing the output of recursive submodule fetchingJens Lehmann, Sep 18, 2010
  23. 2/2 fetch: Get submodule paths from index and not from .gitmodulesJens Lehmann, Sep 18, 2010
  24. Kevin BallardSep 19, 2010
  25. Jens LehmannSep 19, 2010
  26. Kevin BallardSep 20, 2010
  27. 0/3 Teach fetch and pull to recursively fetch submodules tooJens Lehmann, Oct 5, 2010
  28. 1/3 fetch/pull: Recursively fetch populated submodulesJens Lehmann, Oct 5, 2010
  29. 2/3 Submodules: Add the new "fetch" config option for fetch and pullJens Lehmann, Oct 5, 2010
  30. Jon SeymourOct 7, 2010
  31. Jens LehmannOct 9, 2010
  32. Jonathan NiederOct 9, 2010
  33. Jens LehmannOct 9, 2010
  34. 3/3 Add the 'fetch.recursive' config settingJens Lehmann, Oct 5, 2010
  35. Junio C HamanoOct 5, 2010
  36. Kevin BallardOct 6, 2010
  37. Jonathan NiederOct 6, 2010
  38. Jens LehmannOct 9, 2010
  39. Jonathan NiederOct 9, 2010
  40. Jens LehmannOct 9, 2010
  41. Jonathan NiederOct 21, 2010
  42. Jens LehmannOct 21, 2010
  43. Jens LehmannOct 9, 2010
  44. Marc BranchaudOct 13, 2010
  45. Jens LehmannOct 13, 2010
  46. Kevin BallardOct 13, 2010
  47. Jens LehmannOct 13, 2010
  48. Kevin BallardOct 13, 2010
  49. Chris PackhamOct 14, 2010
  50. Jens LehmannOct 14, 2010
  51. Chris PackhamOct 14, 2010
  52. Marc BranchaudOct 13, 2010
  53. Kevin BallardOct 13, 2010
  54. Jens LehmannSep 15, 2010
  55. Kevin BallardSep 15, 2010

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.