Skip to content

build_helper: handle emails containing square brackets #140675

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

japaric
Copy link
Member

@japaric japaric commented May 5, 2025

The git API shells out to git rev-list and was directly passing an email string to the command's --author flag. That flag interprets its arguments as a regular expression, meaning that characters like square brackets ([]) in the email string made the command fail to find a commit matching the author e-mail

This commit escapes the email string prior to passing it to git rev-list.

The change is tested in the bootstrap crate because it contains the testing infrastructure to create temporary git repositories.

fixes #140669

@rustbot
Copy link
Collaborator

rustbot commented May 5, 2025

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 5, 2025
@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Contributor

Kobzol commented May 5, 2025

r? @Kobzol

@rustbot rustbot assigned Kobzol and unassigned Mark-Simulacrum May 5, 2025
@jieyouxu
Copy link
Member

function `get_closest_upstream_commit` is private

@rustbot author

@rustbot rustbot 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 May 14, 2025
The `git` API shells out to `git rev-list` and was directly passing an
email string to the command's `--author` flag. That flag interprets its
arguments as a regular expression, meaning that characters like square
brackets (`[]`) in the email string made the command fail to find a
commit matching the author e-mail

This commit escapes the email string prior to passing it to `git
rev-list`.

The change is tested in the `bootstrap` crate because it contains the
testing infrastructure to create temporary git repositories.

fixes rust-lang#140669
@japaric japaric force-pushed the ja/gh140669-stage0-square-brackets branch from b2ae2d2 to 7753ce7 Compare May 16, 2025 13:12
Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Thanks, left one nit, but otherwise looks fine. I wonder if this escaping works on Windows.

@@ -9,6 +9,16 @@ pub struct GitConfig<'a> {
pub git_merge_commit_email: &'a str,
}

impl GitConfig<'_> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: could you move this to a free function, such as cli_escape_author_email? To make it clear from the name what it does.

@bors
Copy link
Collaborator

bors commented Jun 2, 2025

☔ The latest upstream changes (presumably #119899) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

Bootstrap tests fail when git_merge_commit_email in src/stage0 contains square brackets
7 participants