Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch-submodules fallback; add remove-submodules #7788

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

dhalbert
Copy link
Collaborator

Fixes #7786.

The partial clone method of fetching submodules introduced in #7763 does not work for git older than version 2.36.0. (I had hoped it was earlier than that.)

  • Add a fallback to the older method, which does a shallow clone of depth 1 for each submodule.
  • Add a new target make remove-submodules, which cleans out the currently fetch submodules, so you can start from scratch and do make fetch-submodules again. This is useful to switch between fetch-submodule methods, and also to recover from changes in submodules, such as the replacement of one submodule for another.

Tested with git 2.30.0 (depth 1 shallow clone) and 2.40.0 (blobless partial clone).

@RetiredWizard
Copy link

RetiredWizard commented Mar 25, 2023

Does placing the || between the statements cause the statements to be executed until one is successful (i.e. not False)? If so, I'm curious how the old method executes both statement 2 and statement 3 in the cases that the new method (statement 1) fails? I'm sure I don't understand how make processes the new line but I would have expected statement 1 || (statement 2 && statement 3) || echo Error Message

Also, for the last month or so I've been having to run the fetch-submodules multiples times because cloning one or more of the submodules fails, will that cause a failover to the old method if it happens during the execution of the new fetch method? That's probably not a terrible thing if the answer is yes...

@RetiredWizard
Copy link

RetiredWizard commented Mar 25, 2023

Oh nevermind, I think your statement 2 is a new method and I see the && on the third method....

Well I was getting closer 😁 Thanks as always @dhalbert

@dhalbert
Copy link
Collaborator Author

The old way was this:

# This update will fail because the commits we need aren't the latest on the
# branch. We can ignore that though because we fix it with the second command.
# (Only works for git servers that allow sha fetches.)
.PHONY: fetch-submodules
fetch-submodules:
	git submodule update --init -N --depth 1 || true
	git submodule foreach 'git fetch --tags --depth 1 origin $$sha1 && git checkout -q $$sha1'

Note that there is an expectation that the first line will fail, hence the || true, so that the make target will continue. If by chance it succeeds, that git submodule update --init was sufficient for all of the fetches.

I just got it all to be on one line so I didn't have to use \ or write a script.

Also, for the last month or so I've been having to run the fetch-submodules multiples times because cloning one or more of the submodules fails, will that cause a failover to the old method if it happens during the execution of the new fetch method? That's probably not a terrible thing if the answer is yes...

That would be true, I was assuming it would not fail due to external causes. But the new remove-submodules target will help you start over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Git] Latest master cannot make fetch-submodules
3 participants