Skip to content

Repository: require mutable references to change the namespace - #1343

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

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

Conversation

@DanielEScherzer

@DanielEScherzer DanielEScherzer commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Affects:

  • Repository::set_namespace()
  • Repository::set_namespace_bytes()
  • Repository::remove_namespace()

Since the error messages are different on different versions of Rust, update the GitHub actions setup to use the correct expected output based on the tested version.

Work towards #1330

@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Nov 14, 2026
@DanielEScherzer DanielEScherzer changed the title Repository: mark set_namespace() and set_namespace_bytes() as mutating Repository: require mutable references to change the namespace 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 namespace is being changed,
which is a mutable operation. If allowed on just a `&self` immutable reference,
the existing namespace (read with `get_namespace()` or `get_namespace_bytes()`)
can be used after libgit2 has already freed it.

Affects:

- `Repository::set_namespace()`
- `Repository::set_namespace_bytes()`
- `Repository::remove_namespace()`

Since the error messages are different on different versions of Rust, update the
GitHub actions setup to use the correct expected output based on the tested
version.

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