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

Re: [PATCH 1/2] submodule: Include check for objects when fetching

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 22, 2016, 23:06 UTC
Message-ID
<xmqqk2lw4a6p.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqoab84apu.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> Junio wrote:
>>> To be complete, the rev-list command line should also run with
>>> "--objects"; after all, a commit walker fetch may have downloaded
>>> commit chain completely but haven't fetched necessary trees and
>>> blobs when it was killed, and "rev-list $sha1 --not --all" would not
>>> catch such a breakage without "--objects".
>>
>> By adding the --objects switch to rev-list we make sure to do a complete
>> check.
>
> You also need to drop "-n1" for the command to be equivalent to
> quickfetch, I think.
Ahh, I think I need to take it back.

As the existing code relies not just on the exit status of rev-list but also checks if anything comes out of it, having "-n1" would not hurt.

The case I was worried about was that we have all commits to connect $sha1 to what are reachable from refs, but some tree/blob objects referenced by these commits were missing. By cutting the displaying with "-n1", rev-list may happily exit successfully after showing $sha1, without even realizing that some trees/blobs are missing and the history leading to $sha1 cannot be considered complete.

But because the code checks the empty-ness of $rev, this case is diagnosed as "$sha1 is not reachable from any of the refs" correctly anyway, so it should be OK.

Show 18 quoted lines
>> Signed-off-by: Stefan Beller <sbeller@google.com>
>> ---
>>  git-submodule.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/git-submodule.sh b/git-submodule.sh
>> index 9bc5c5f..f5d6675 100755
>> --- a/git-submodule.sh
>> +++ b/git-submodule.sh
>> @@ -746,7 +746,7 @@ Maybe you want to use 'update --init'?")"
>>  				# Run fetch only if $sha1 isn't present or it
>>  				# is not reachable from a ref.
>>  				(clear_local_git_env; cd "$sm_path" &&
>> -					( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
>> +					( (rev=$(git rev-list --objects -n 1 $sha1 --not --all 2>/dev/null) &&
>>  					 test -z "$rev") || git-fetch)) ||
>>  				die "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
>>  			fi
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 10 in “Submodule harden fetches (WAS: submodule: Fetch the direct sha1 first)”
  1. 0/2 Submodule harden fetches (WAS: submodule: Fetch the direct sha1 first)Stefan Beller, Feb 22, 2016
  2. 1/2 submodule: Include check for objects when fetchingStefan Beller, Feb 22, 2016
  3. Junio C HamanoFeb 22, 2016
  4. Junio C HamanoFeb 22, 2016
  5. Junio C HamanoFeb 22, 2016
  6. 2/2 submodule: Try harder to fetch needed sha1 by direct fetching sha1Stefan Beller, Feb 22, 2016
  7. Junio C HamanoFeb 23, 2016
  8. Stefan BellerFeb 23, 2016
  9. Junio C HamanoFeb 23, 2016
  10. submodule: Try harder to fetch needed sha1 by direct fetching sha1Stefan Beller, Feb 24, 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.