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

Fix benchsuite issue with newer versions of git #15069

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Jan 15, 2025

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:

rm -rf target/tmp/bench ; cargo test -p benchsuite --all-targets -- cargo && cargo test -p benchsuite --all-targets -- cargo`

(Run it twice to verify it can do an incremental fetch.)

@rustbot
Copy link
Collaborator

rustbot commented Jan 15, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 15, 2025
@@ -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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

@weihanglo weihanglo Jan 15, 2025

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.

@ehuss ehuss force-pushed the fix-benchsuite-init-main branch from 14f34e1 to 5ac521c Compare January 15, 2025 21:43
@@ -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
Copy link
Member

@weihanglo weihanglo Jan 15, 2025

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.

@weihanglo weihanglo enabled auto-merge January 15, 2025 21:49
@weihanglo weihanglo added this pull request to the merge queue Jan 15, 2025
Merged via the queue into rust-lang:master with commit ac22fd3 Jan 15, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants