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

Handle non-existent upstream master branches in x fmt #106415

Merged
merged 2 commits into from
Jan 7, 2023

Conversation

Noratrieb
Copy link
Member

People who do have a remote for rust-lang/rust but don't have the master branch checked out there used to get this error when running x fmt:

fatal: ambiguous argument 'rust/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
rust/master

Which is not exactly helpful.

Now, we fall back to origin/master (hoping that at least that remote exists) for that case. If there is still some error, we just fall back to x fmt . and print a warning.

r? @jyn514

@rustbot rustbot added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2023
@Mark-Simulacrum
Copy link
Member

I don't think we should fallback on an arbitrary remote, if your origin is way behind the current HEAD we'll do a bunch of work trying to figure out what the right delta is, but really just formatting all files in that case seems better to me.

I don't think we should allow for our heuristics being wrong by using arbitrary remotes.

@jyn514
Copy link
Member

jyn514 commented Jan 3, 2023

@Mark-Simulacrum we already hardcode origin for download-ci-llvm, which IMO is a lot more important to get correct. I'm not sure why we would hold formatting to a higher standard (especially since it's already going to be caught in CI by x fmt --check).

@Mark-Simulacrum
Copy link
Member

Hm, that seems like a problem there - I would probably not do that. But anyway, will leave it up to you.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Hm, that seems like a problem there - I would probably not do that. But anyway, will leave it up to you.

Yeah it's a little unfortunate. But people have been using it for 2+ years and no one has complained, so I think it's ok in practice.

r=me with the nit fixed

src/tools/build_helper/src/git.rs Outdated Show resolved Hide resolved
@Noratrieb
Copy link
Member Author

I agree that hardcoding remotes isn't a great idea, but I think it's fine here. This path will only be hit on fairly nonstandard setups that don't have the upstream master fetched, and also if it fails it will just be a warning and it will work just fine (albeit a little slower).

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2023
@Noratrieb Noratrieb force-pushed the where-is-my-master-branch branch from 21947c9 to d5e5762 Compare January 6, 2023 19:19
@Noratrieb Noratrieb changed the title Handle non-existant upstream master branches in x fmt Handle non-existent upstream master branches in x fmt Jan 6, 2023
@Noratrieb
Copy link
Member Author

@bors r=jyn514

@bors
Copy link
Contributor

bors commented Jan 6, 2023

📌 Commit d5e5762 has been approved by jyn514

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 6, 2023
@bors
Copy link
Contributor

bors commented Jan 6, 2023

⌛ Testing commit d5e5762 with merge 7ac9572...

@bors
Copy link
Contributor

bors commented Jan 7, 2023

☀️ Test successful - checks-actions
Approved by: jyn514
Pushing 7ac9572 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 7, 2023
@bors bors merged commit 7ac9572 into rust-lang:master Jan 7, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 7, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ac9572): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.6% [0.6%, 0.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.4% [-1.4%, -1.4%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.2% [-1.5%, -1.0%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.2% [-1.5%, -1.0%] 3

@Noratrieb Noratrieb deleted the where-is-my-master-branch branch January 7, 2023 08:17
Falling back to formatting all files."
);
// Something went wrong when getting the version. Just format all the files.
paths.push(".".into());
Copy link
Member

@RalfJung RalfJung Sep 1, 2023

Choose a reason for hiding this comment

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

I've stared at this for quite a while now, but I don't think I get it... why does this push . to the path list? We have other error cases below ("could not find usable git"), and they don't do that. Why is this different? I think for ./x.py fmt it is unnecessary since we're anyway searching everything, and for ./x.py fmt compiler/ this s actively buggy since it formats not just the files in the compiler dir. Am I missing something?

Copy link
Member Author

Choose a reason for hiding this comment

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

you're probably right. i don't remember the details of this change though, but this does look sus

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 11, 2023
…ulacrum

bootstrap/format: remove unnecessary paths.push

Cc rust-lang#106415 (review)
I verified that this still formats all fileds when `get_modified_rs_files` is made to return an error.

r? `@Nilstrieb`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 11, 2023
…ulacrum

bootstrap/format: remove unnecessary paths.push

Cc rust-lang#106415 (review)
I verified that this still formats all fileds when `get_modified_rs_files` is made to return an error.

r? ``@Nilstrieb``
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Sep 11, 2023
Rollup merge of rust-lang#115440 - RalfJung:bootstrap-fmt, r=Mark-Simulacrum

bootstrap/format: remove unnecessary paths.push

Cc rust-lang#106415 (review)
I verified that this still formats all fileds when `get_modified_rs_files` is made to return an error.

r? ``@Nilstrieb``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants