-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
sources/path: if PathSource::list_files fails while using a git repo, retry without it #10313
Conversation
… retry without it Sometimes `discovery_git_repo()` can succeed even though the git repo isn't complete. This resulted in us failing to build in some cases (I noted the case where HEAD is valid but other objects are missing due to alternates not being accessible, and we trigger use of `list_files()` by having a build script). Resolve this by always retrying without a git repo if we fail to list files while using one. This fixes rust-lang#10311.
(rust-highfive has picked a reviewer for you, use r? to override) |
Thanks for the PR! I am wary of the retry mechanism.
Since the file-listing logic in |
It's important to note that in many cases, an invalid git repo already causes us to use the It's my belief that we're using |
I definitely am not comfortable with the silent fallback; at a minimum it should emit a detailed warning (e.g. about a missing object). However, even better, I'd love to see Cargo just emit that as an error and stop, and suggest that the user could pass something like |
@joshtriplett what are your thoughts on the boundary between "fallback" and "detecting a valid git directory" here? In some ways, we're already falling back to not using git in many cases. More generally, I think it's useful to consider the mental model here: It's (from my perspective as a user) somewhat surprising that One option we have is to adopt the mental model that if treating the directory as a git repository fails, then clearly the directory was not actually a git repository. This is essentially the model of this PR. Another option though is for us to reduce our reliance on a fully formed git repository. The cargo documentation for include/exclude (which also documents its use of git to some extent), only indicates that the A related option to the last one is to continue examining the index (with a documentation update), but make the index not being usable result in us just using the gitignore system. |
@jmesmon My thinking here is primarily about consequences: I'm concerned about falling back from git to not-git causing One way to reduce potential harms would be to warn but continue in less consequential situations, such as Another orthogonal improvement would be trying to be more consistent about what information we process, such as always processing I'd prioritize reducing potential harms in the publish/package/etc case, though. |
Sure, it sounds like you're proposing that rather than this fix, we do something more complicated. To do the more complicated thing (if we do decide to go that way), we do need to more definitively define what "inside a git repo" means, as that's part of the reason that this bug occurred in the first place. Don't see any one proposing/clarifying what that might mean (other than myself). It would be very useful to have direct discussion of this point. Some breakdown of conditions as they currently exist vs how this PR would change things:
It will be difficult to make changes to this code without us establishing what this boundary is supposed to be. Is it simply "does |
Oh, also: we're already using the |
@jmesmon At the moment, I think I'd be satisfied if we just turn the warning into a hard error if we're in |
Ping @jmesmon. Just checking in to see if you are still interested in working on this. The comment here telling one of the expected solution. Let us know if you can continue in that way, or have any question. Thank you! |
☔ The latest upstream changes (presumably #12159) made this pull request unmergeable. Please resolve the merge conflicts. |
I'm going to close due to inactivity. We are still interested in some solutions here, specifically #10313 (comment). Feel free to reopen if you have a chance to work on it again. Thank you. |
Sometimes
discover_git_repo()
can succeed even though the git repoisn't complete. This resulted in us failing to build in some cases (I
noted the case where HEAD is valid but other objects are missing due to
alternates not being accessible, and we trigger use of
list_files()
byhaving a build script). Resolve this by always retrying without a git
repo if we fail to list files while using one.
Fixes #10311.
Note: this may cause retries in list_files that are unrelated to git issues. I think these should be minor (if they ever occur). It is possible to structure things as a
loop
rather than a separate function and only trigger retries on git issues, but the separate function seemed cleaner. (It's also possible one of the other alternates solutions in #10311 might be a better choice because of some downside I'm not aware of. Let me know if that's the case).Also, right now this code will never indicate if there was an issue examining the git repo (and silently fall back to the non-git-repo file listing). This makes sense given the issue I reported in #10311, but seems like it might allow us to unknowingly break handling of the git files list (given it will silently fallback). Thoughts here would be useful.