-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
@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) { |
There was a problem hiding this comment.
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?
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! |
b793016
to
9223905
Compare
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 |
9223905
to
980c199
Compare
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? |
I guess that I should probably add it in this PR so that I don't forget it. I'll add it soon. |
980c199
to
de43efc
Compare
I added the flag. I also made another small drive-by fix to the version used in the update options initializer. |
Good catch on that one. 👌 Thanks! |
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.