Skip to content

Repository: require mutable references to change the workdir - #1344

Open
DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:repo-mut-set-workdir
Open

DanielEScherzer wants to merge 1 commit into
rust-lang:mainfrom
DanielEScherzer:repo-mut-set-workdir

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Contributor

Require a mutable reference to self because the workdir is being changed, which is a mutable operation. If allowed on just a &self immutable reference, the existing workdir (read with workdir()) can be used after libgit2 has already freed it.

Affects:

  • Repository::set_workdir()

Work towards #1330

@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Nov 14, 2026
@DanielEScherzer

Copy link
Copy Markdown
Contributor Author

@rustbot label +semver-breaking-change

@rustbot rustbot added the semver-breaking-change A SemVer breaking change that will require a new SemVer-incompatible version number bump. label Nov 14, 2026
@rustbot

This comment has been minimized.

Require a mutable reference to `self` because the workdir is being changed,
which is a mutable operation. If allowed on just a `&self` immutable reference,
the existing workdir (read with `workdir()`) can be used after libgit2 has
already freed it.

Affects:

- `Repository::set_workdir()`

Work towards rust-lang#1330
@rustbot

rustbot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Waiting on review semver-breaking-change A SemVer breaking change that will require a new SemVer-incompatible version number bump.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants