Skip to content

Change connected() to take &self instead of &mut self#1257

Open
cuishuang wants to merge 2 commits into
rust-lang:mainfrom
cuishuang:main
Open

Change connected() to take &self instead of &mut self#1257
cuishuang wants to merge 2 commits into
rust-lang:mainfrom
cuishuang:main

Conversation

@cuishuang
Copy link
Copy Markdown

The connected method only reads the connection status without mutating state, so &self is sufficient and avoids unnecessary mutable borrow.

Signed-off-by: cuishuang <imcusg@gmail.com>
@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label May 17, 2026
Copy link
Copy Markdown
Contributor

@DanielEScherzer DanielEScherzer left a comment

Choose a reason for hiding this comment

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

Looking at the various git_remote_connected callbacks in libgit2 there are none that mutate the remote, so looks good to me (once CI passes)

View changes since this review

Signed-off-by: cuishuang <imcusg@gmail.com>
@cuishuang
Copy link
Copy Markdown
Author

Looking at the various git_remote_connected callbacks in libgit2 there are none that mutate the remote, so looks good to me (once CI passes)

View changes since this review

Thanks.

I resubmitted the changes and modified the test cases to pass the CI

@ehuss
Copy link
Copy Markdown
Contributor

ehuss commented May 18, 2026

Is this safe even with a custom transport? The transport vtable does not seem to enforce this as const or have any comments or contracts around that.

@ehuss ehuss added S-waiting-on-author Status: Waiting on PR author and removed S-waiting-on-review Status: Waiting on review labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: Waiting on PR author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants