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

Improve SSHKit::Host comparison methods #205

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

Conversation

FooBarWidget
Copy link
Contributor

This pull request improves SSHKit::Host comparison in the following ways.

  • #equal? should test for object identity, not whether the contents are equal, as per the Ruby documentation.
  • #eql? and #== should check the contents directly instead of comparing the hash. This prevents false positives.

 * #equal? should test for object identity, not whether the contents
   are equal, as per the Ruby documentation.
 * #eql? and #== should check the contents directly instead of comparing
   the hash. This prevents false positives.
@leehambley
Copy link
Member

Thanks @FooBarWidget good call. I'll look at your other PR as well today/tomorrow time permitting. Thanks for taking the time to contribute to SSHKit, I respect you Phusion guys massively, and it's a pleasure to receive code from you :)

@mattbrictson
Copy link
Member

I'm in the process of closing old/inactive PRs; pardon the noise. This PR seems to have been abandoned. Please comment if you'd like it to be reconsidered.

@FooBarWidget
Copy link
Contributor Author

Hey @mattbrictson, why is this patch considered abandoned? There was no feedback on whether the patch is acceptable or not. So at the very least, the patch was not abandoned on my side.

@will-in-wi
Copy link
Contributor

@FooBarWidget: This was just cleanup due to age. Sorry about that. If you don't mind, could you rebase against master, and then we'll try and get this resolved.

Thanks!

@mattbrictson
Copy link
Member

Looks like we dropped the ball on this PR, then. Sorry about that! Thanks for sticking around. I will try to review this and make a decision whether to merge by the end of the week.

Re-opening.

@mattbrictson mattbrictson reopened this Sep 14, 2016
Copy link
Member

@mattbrictson mattbrictson left a comment

Choose a reason for hiding this comment

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

I agree with all the proposed changes, thanks!

However, per the Ruby documentation:

The hash function must have the property that a.eql?(b) implies a.hash == b.hash.

Right now this is not the case because Host#hash is using port, but Host#eql? is using port_with_default. That means that two hosts could be eql but have different hash values.

Do you agree that the hash implementation should be changed to use port_with_default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants