Thanks to visit codestin.com
Credit goes to github.com

Skip to content

submodule: Try to fetch when update fails to find the target commit. #3813

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

Merged
merged 1 commit into from
Jun 29, 2016

Conversation

hackhaslam
Copy link
Contributor

@hackhaslam hackhaslam commented Jun 7, 2016

This fixes #3783. When submodule update doesn't find the target commit in the submodule, fetch from the default remote and then try to lookup the commit again.

@ethomson
Copy link
Member

@jamill Would you have a moment to spare a second set of eyes here? I realize that you're not spending as much time with submodules these days, but you certainly still know more about them than I do. :)

* Look up the target commit in the submodule.
* If it isn't found then fetch and try again.
*/
if ((error = git_object_lookup(&target_commit, sub_repo, git_submodule_index_id(sm), GIT_OBJ_COMMIT)) < 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific error code that is returned when the target commit could not be found? Could we be more selective and only attempt to fetch for the not found error?

@jamill
Copy link
Member

jamill commented Jun 14, 2016

Looks OK to me - and I think this matches the expected behavior. I might also suggest updating the comments for this function to clarify that this will fetch if there are missing commits. Thanks!

@hackhaslam hackhaslam force-pushed the submodule-update-fetch branch from b793016 to 9223905 Compare June 16, 2016 01:48
@hackhaslam
Copy link
Contributor Author

Thanks for the review! I restricted the fetch logic to the not found error, and changed the documenation comment to mention the new behavior. I also made a slight drive-by fix for a duplicate check in the clone side.

I'm noticing now that submodule update has a -no-fetch flag. Maybe there should be a no_fetch flag in the submodule update options? Probably not a big deal though.

@hackhaslam hackhaslam force-pushed the submodule-update-fetch branch from 9223905 to 980c199 Compare June 16, 2016 16:40
@ethomson
Copy link
Member

I'm noticing now that submodule update has a -no-fetch flag. Maybe there should be a no_fetch flag in the submodule update options? Probably not a big deal though.

I agree, that would be a really nice option. Is this something you want to tackle in this PR or do you want me to merge this and tackle this later?

@hackhaslam
Copy link
Contributor Author

I guess that I should probably add it in this PR so that I don't forget it. I'll add it soon.

@hackhaslam hackhaslam force-pushed the submodule-update-fetch branch from 980c199 to de43efc Compare June 29, 2016 04:30
@hackhaslam
Copy link
Contributor Author

I added the flag. I also made another small drive-by fix to the version used in the update options initializer.

@ethomson
Copy link
Member

I also made another small drive-by fix to the version used in the update options initializer.

Good catch on that one. 👌 Thanks!

@ethomson ethomson merged commit 59a0005 into libgit2:master Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

git_submodule_update doesn't fetch
3 participants