-
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
Fix benchsuite issue with newer versions of git #15069
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
benches/benchsuite/src/lib.rs
Outdated
@@ -127,9 +127,12 @@ impl Fixtures { | |||
fs::create_dir_all(&index).unwrap(); | |||
git("init --bare"); | |||
git("remote add origin https://github.com/rust-lang/crates.io-index-archive"); | |||
// git 2.48.0 changed the behavior of setting HEAD, so let's just |
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.
Thanks. Tested it locally and this fixes the issue.
However, I don't understand it. On my machine git is 2.47.0, and still failed. Maybe switching from main
to master
is enough?
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.
Do you have init.defaultBranch
set? That will also cause this problem.
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.
I pushed an update to drop the explicit ref update, and instead use --initial-branch
which essentially does the same thing.
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.
Confirmed that only with both init --bare --initial-branch=main
and branch -f main FETCH_HEAD
it works, regardless what is set in init.defaultBranch
.
14f34e1
to
5ac521c
Compare
benches/benchsuite/src/lib.rs
Outdated
@@ -127,9 +127,12 @@ impl Fixtures { | |||
fs::create_dir_all(&index).unwrap(); | |||
git("init --bare"); | |||
git("remote add origin https://github.com/rust-lang/crates.io-index-archive"); | |||
// git 2.48.0 changed the behavior of setting HEAD, so let's just |
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.
Confirmed that only with both init --bare --initial-branch=main
and branch -f main FETCH_HEAD
it works, regardless what is set in init.defaultBranch
.
This fixes a problem introduced with git 2.48.0 where the benchsuite would fail to run. The problem is that 2.48 changed the behavior so that HEAD would get changed to follow the remote. crates.io-index's default branch is "main". The benchsuite uses git to initialize the bare repo with a HEAD of "refs/heads/master" (the default of
init.defaultBranch
). Older versions of git would leave HEAD untouched, but newer versions update it to "refs/heads/main" after fetching to match the remote. This causes cargo to try to clone a branch called "main" which is empty.The solution here is to just force HEAD to be main, and use that as the branch for our time-travelling snapshot.
Tested with git 2.47.0 and 2.48.1. Test is roughly:
(Run it twice to verify it can do an incremental fetch.)