Skip to content

Commit f9ddeb0

Browse files
committed
Fix hash type switch statement
Signed-off-by: Philip Laine <[email protected]>
1 parent 6b3d96e commit f9ddeb0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/git/libgit2/transport.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,16 @@ func (k knownKey) matches(host string, hostkey git2go.HostkeyCertificate) bool {
205205

206206
var fingerprint []byte
207207
var hasher hash.Hash
208-
switch hostkey.Kind {
209-
case git2go.HostkeyMD5:
210-
fingerprint = hostkey.HashMD5[:]
211-
hasher = md5.New()
212-
case git2go.HostkeySHA1:
213-
fingerprint = hostkey.HashSHA1[:]
214-
hasher = sha1.New()
215-
case git2go.HostkeySHA256:
208+
switch {
209+
case hostkey.Kind&git2go.HostkeySHA256 > 0:
216210
fingerprint = hostkey.HashSHA256[:]
217211
hasher = sha256.New()
212+
case hostkey.Kind&git2go.HostkeySHA1 > 0:
213+
fingerprint = hostkey.HashSHA1[:]
214+
hasher = sha1.New()
215+
case hostkey.Kind&git2go.HostkeyMD5 > 0:
216+
fingerprint = hostkey.HashMD5[:]
217+
hasher = md5.New()
218218
default:
219219
return false
220220
}

0 commit comments

Comments
 (0)