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

Re: Fetch on submodule update

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 6, 2018, 15:41 UTC
Message-ID
<20180806154122.GB105466@aiede.svl.corp.google.com>
In-Reply-To
<CAHd499CFHUwpNdYp2sMjChi_WWzSihi5VRzLMQbKsGrKf_Ktcg@mail.gmail.com>
Robert Dailey wrote:
Show 9 quoted lines
>                                                  Automatic would be
> great if submodules were treated as integrated in a similar manner to
> subtree, but it's not there. I wasn't aware that `submodule update`
> did a fetch, because sometimes if I do that, I get errors saying SHA1
> is not present (because the submodule did not get fetched). Granted I
> haven't seen this in a while, so maybe the fetch on submodule update
> is a newer feature. Do you know what triggers the fetch on update
> without --remote? Is it the missing SHA1 that triggers it, or is it
> fetching unconditionally?

Thanks for this and the rest of the context you sent. It's very helpful.

The relevant code in git-submodule.sh is
	# Run fetch only if $sha1 isn't present or it
	# is not reachable from a ref.
	is_tip_reachable "$sm_path" "$sha1" ||
	fetch_in_submodule "$sm_path" $depth ||
	say "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
	# Now we tried the usual fetch, but $sha1 may
	# not be reachable from any of the refs
	is_tip_reachable "$sm_path" "$sha1" ||
	fetch_in_submodule "$sm_path" $depth "$sha1" ||
	die "$(eval_gettext "Fetched in submodule path '\$displaypath', but it did not contain \$sha1. Direct fetching of that commit failed.")"

The fallback to fetching by SHA-1 was introduced in v2.8.0-rc0~9^2 (submodule: try harder to fetch needed sha1 by direct fetching sha1, 2018-02-23).

Jonathan
Previous: Robert DaileyNext: Robert Dailey
Message 5 of 6 in “Fetch on submodule update”
  1. Robert DaileyAug 1, 2018
  2. Jonathan NiederAug 1, 2018
  3. Jonathan NiederAug 2, 2018
  4. Robert DaileyAug 6, 2018
  5. Jonathan NiederAug 6, 2018
  6. Robert DaileyAug 6, 2018

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.