Merge pull request #115 from actions/dependabot/go_modules/github.com/go-git/go-git/v5-5.12.0

Bump github.com/go-git/go-git/v5 from 5.11.0 to 5.12.0
This commit is contained in:
Shawn Hartsell
2024-04-04 14:31:19 -05:00
committed by GitHub
94 changed files with 593 additions and 321 deletions

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/bitcurves
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/bitcurves

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/brainpool
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package brainpool implements Brainpool elliptic curves.
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/brainpool

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/eax
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: 'Package eax provides an implementation of the EAX (encrypt-authenticate-translate)
mode of operation, as described in Bellare, Rogaway, and Wagner "THE EAX MODE OF

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/internal/byteutil
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/internal/byteutil

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/ocb
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: 'Package ocb provides an implementation of the OCB (offset codebook) mode
of operation, as described in RFC-7253 of the IRTF and in Rogaway, Bellare, Black

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package openpgp implements high level operations on OpenPGP messages.
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/openpgp

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/aes/keywrap
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package keywrap is an implementation of the RFC 3394 AES key wrapping algorithm.
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/openpgp/aes/keywrap

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/armor
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package armor implements OpenPGP ASCII Armor, see RFC 4880.
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/openpgp/armor

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/ecdh
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package ecdh implements ECDH encryption, suitable for OpenPGP, as specified
in RFC 6637, section 8.

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/ecdsa
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package ecdsa implements ECDSA signature, suitable for OpenPGP, as specified
in RFC 6637, section 5.

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/eddsa
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package eddsa implements EdDSA signature, suitable for OpenPGP, as specified
in https://datatracker.ietf.org/doc/html/draft-ietf-openpgp-crypto-refresh-06#section-13.7

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/elgamal
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package elgamal implements ElGamal encryption, suitable for OpenPGP, as specified
in "A Public-Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms,"

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/errors
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package errors contains common error types for the OpenPGP packages.
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/openpgp/errors

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/internal/algorithm
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/openpgp/internal/algorithm

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/internal/ecc
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package ecc implements a generic interface for ECDH, ECDSA, and EdDSA.
homepage: https://pkg.go.dev/github.com/ProtonMail/go-crypto/openpgp/internal/ecc

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/internal/encoding
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package encoding implements openpgp packet field encodings as specified in
RFC 4880 and 6637.

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/packet
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package packet implements parsing and serialization of OpenPGP packets, as
specified in RFC 4880.

View File

@@ -1,6 +1,6 @@
---
name: github.com/ProtonMail/go-crypto/openpgp/s2k
version: v0.0.0-20230828082145-3c4c8a2d2371
version: v1.0.0
type: go
summary: Package s2k implements the various OpenPGP string-to-key transforms as specified
in RFC 4800 section 3.7.1, and Argon2 specified in draft-ietf-openpgp-crypto-refresh-08

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5
version: v5.11.0
version: v5.12.0
type: go
summary: A highly extensible git implementation in pure Go.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/config
version: v5.11.0
version: v5.12.0
type: go
summary: Package config contains the abstraction of multiple config files
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/config

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/internal/path_util
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/internal/path_util

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/internal/revision
version: v5.11.0
version: v5.12.0
type: go
summary: 'Package revision extracts git revision from string More information about
revision : https://www.kernel.org/pub/software/scm/git/docs/gitrevisions.html'

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/internal/url
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/internal/url

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing
version: v5.11.0
version: v5.12.0
type: go
summary: package plumbing implement the core interfaces and structs used by go-git
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/cache
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/cache

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/color
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/color

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/filemode
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/filemode

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/config
version: v5.11.0
version: v5.12.0
type: go
summary: Package config implements encoding and decoding of git config files.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/config

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/diff
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/diff

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/gitignore
version: v5.11.0
version: v5.12.0
type: go
summary: Package gitignore implements matching file system paths to gitignore patterns
that can be automatically read from a git repository tree in the order of definition

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/idxfile
version: v5.11.0
version: v5.12.0
type: go
summary: Package idxfile implements encoding and decoding of packfile idx files.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/idxfile

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/index
version: v5.11.0
version: v5.12.0
type: go
summary: Package index implements encoding and decoding of index format files.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/index

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/objfile
version: v5.11.0
version: v5.12.0
type: go
summary: Package objfile implements encoding and decoding of object files.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/objfile

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/packfile
version: v5.11.0
version: v5.12.0
type: go
summary: Package packfile implements encoding and decoding of packfile format.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/format/packfile

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/format/pktline
version: v5.11.0
version: v5.12.0
type: go
summary: Package pktline implements reading payloads form pkt-lines and encoding pkt-lines
from payloads.

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/hash
version: v5.11.0
version: v5.12.0
type: go
summary: package hash provides a way for managing the underlying hash implementations
used across go-git.

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/object
version: v5.11.0
version: v5.12.0
type: go
summary: Package object contains implementations of all Git objects and utility functions
to work with them.

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/protocol/packp
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/protocol/packp

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/protocol/packp/capability
version: v5.11.0
version: v5.12.0
type: go
summary: Package capability defines the server and client capabilities.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/protocol/packp/capability

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband
version: v5.11.0
version: v5.12.0
type: go
summary: Package sideband implements a sideband mutiplex/demultiplexer
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/protocol/packp/sideband

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/revlist
version: v5.11.0
version: v5.12.0
type: go
summary: Package revlist provides support to access the ancestors of commits, in a
similar way as the git-rev-list command.

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/storer
version: v5.11.0
version: v5.12.0
type: go
summary: Package storer defines the interfaces to store objects, references, etc.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/storer

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport
version: v5.11.0
version: v5.12.0
type: go
summary: Package transport includes the implementation for different transport protocols.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/client
version: v5.11.0
version: v5.12.0
type: go
summary: Package client contains helper function to deal with the different client
protocols.

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/file
version: v5.11.0
version: v5.12.0
type: go
summary: Package file implements the file transport protocol.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport/file

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/git
version: v5.11.0
version: v5.12.0
type: go
summary: Package git implements the git transport protocol.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport/git

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/http
version: v5.11.0
version: v5.12.0
type: go
summary: Package http implements the HTTP transport protocol.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport/http

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/internal/common
version: v5.11.0
version: v5.12.0
type: go
summary: Package common implements the git pack protocol with a pluggable transport.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport/internal/common

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/server
version: v5.11.0
version: v5.12.0
type: go
summary: Package server implements the git server protocol.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport/server

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/plumbing/transport/ssh
version: v5.11.0
version: v5.12.0
type: go
summary: Package ssh implements the SSH transport protocol.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/plumbing/transport/ssh

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/storage
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/storage

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/storage/filesystem
version: v5.11.0
version: v5.12.0
type: go
summary: Package filesystem is a storage backend base on filesystems
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/storage/filesystem

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/storage/filesystem/dotgit
version: v5.11.0
version: v5.12.0
type: go
summary: https://github.com/git/git/blob/master/Documentation/gitrepository-layout.txt
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/storage/filesystem/dotgit

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/storage/memory
version: v5.11.0
version: v5.12.0
type: go
summary: Package memory is a storage backend base on memory
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/storage/memory

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/binary
version: v5.11.0
version: v5.12.0
type: go
summary: Package binary implements syntax-sugar functions on top of the standard library
binary package

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/diff
version: v5.11.0
version: v5.12.0
type: go
summary: Package diff implements line oriented diffs, similar to the ancient Unix
diff command.

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/ioutil
version: v5.11.0
version: v5.12.0
type: go
summary: Package ioutil implements some I/O utility functions.
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/utils/ioutil

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/merkletrie
version: v5.11.0
version: v5.12.0
type: go
summary: Package merkletrie provides support for n-ary trees that are at the same
time Merkle trees and Radix trees (tries).

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/merkletrie/filesystem
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/utils/merkletrie/filesystem

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/merkletrie/index
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/utils/merkletrie/index

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/merkletrie/internal/frame
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/utils/merkletrie/internal/frame

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/merkletrie/noder
version: v5.11.0
version: v5.12.0
type: go
summary: Package noder provide an interface for defining nodes in a merkletrie, their
hashes and their paths (a noders and its ancestors).

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/sync
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/utils/sync

View File

@@ -1,6 +1,6 @@
---
name: github.com/go-git/go-git/v5/utils/trace
version: v5.11.0
version: v5.12.0
type: go
summary:
homepage: https://pkg.go.dev/github.com/go-git/go-git/v5/utils/trace

View File

@@ -1,6 +1,6 @@
---
name: github.com/sergi/go-diff/diffmatchpatch
version: v1.2.0
version: v1.3.2-0.20230802210424-5b0b94c5c0d3
type: go
summary: Package diffmatchpatch offers robust algorithms to perform the operations
required for synchronizing plain text.

View File

@@ -1,6 +1,6 @@
---
name: github.com/skeema/knownhosts
version: v1.2.1
version: v1.2.2
type: go
summary: Package knownhosts is a thin wrapper around golang.org/x/crypto/ssh/knownhosts,
adding the ability to obtain the list of host key algorithms for a known host.
@@ -212,7 +212,7 @@ licenses:
limitations under the License.
- sources: README.md
text: |-
**Source code copyright 2023 Skeema LLC and the Skeema Knownhosts authors**
**Source code copyright 2024 Skeema LLC and the Skeema Knownhosts authors**
```text
Licensed under the Apache License, Version 2.0 (the "License");
@@ -230,7 +230,7 @@ licenses:
notices:
- sources: NOTICE
text: |-
Copyright 2023 Skeema LLC and the Skeema Knownhosts authors
Copyright 2024 Skeema LLC and the Skeema Knownhosts authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

8
go.mod
View File

@@ -3,7 +3,7 @@ module github.com/actions/actions-sync
go 1.21
require (
github.com/go-git/go-git/v5 v5.11.0
github.com/go-git/go-git/v5 v5.12.0
github.com/google/go-github/v43 v43.0.0
github.com/gorilla/mux v1.8.1
github.com/pkg/errors v0.9.1
@@ -15,7 +15,7 @@ require (
require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
@@ -30,8 +30,8 @@ require (
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.21.0 // indirect

22
go.sum
View File

@@ -3,8 +3,8 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg=
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
@@ -23,16 +23,16 @@ github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcej
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY=
github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4=
github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY=
github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys=
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -73,11 +73,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -171,6 +171,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -73,7 +73,9 @@ func (c *x448) GenerateECDH(rand io.Reader) (point []byte, secret []byte, err er
func (c *x448) Encaps(rand io.Reader, point []byte) (ephemeral, sharedSecret []byte, err error) {
var pk, ss x448lib.Key
seed, e, err := c.generateKeyPairBytes(rand)
if err != nil {
return nil, nil, err
}
copy(pk[:], point)
x448lib.Shared(&ss, &seed, &pk)

View File

@@ -27,14 +27,14 @@ compatibility status with go-git.
## Branching and merging
| Feature | Sub-feature | Status | Notes | Examples |
| ----------- | ----------- | ------ | --------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `branch` | | ✅ | | - [branch](_examples/branch/main.go) |
| `checkout` | | ✅ | Basic usages of checkout are supported. | - [checkout](_examples/checkout/main.go) |
| `merge` | | ❌ | | |
| `mergetool` | | ❌ | | |
| `stash` | | ❌ | | |
| `tag` | | ✅ | | - [tag](_examples/tag/main.go) <br/> - [tag create and push](_examples/tag-create-push/main.go) |
| Feature | Sub-feature | Status | Notes | Examples |
| ----------- | ----------- | ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `branch` | | ✅ | | - [branch](_examples/branch/main.go) |
| `checkout` | | ✅ | Basic usages of checkout are supported. | - [checkout](_examples/checkout/main.go) |
| `merge` | | ⚠️ (partial) | Fast-forward only | |
| `mergetool` | | ❌ | | |
| `stash` | | ❌ | | |
| `tag` | | ✅ | | - [tag](_examples/tag/main.go) <br/> - [tag create and push](_examples/tag-create-push/main.go) |
## Sharing and updating projects

View File

@@ -28,6 +28,7 @@ build-git:
test:
@echo "running against `git version`"; \
$(GOTEST) -race ./...
$(GOTEST) -v _examples/common_test.go _examples/common.go --examples
TEMP_REPO := $(shell mktemp)
test-sha256:

View File

@@ -89,6 +89,25 @@ type CloneOptions struct {
Shared bool
}
// MergeOptions describes how a merge should be performed.
type MergeOptions struct {
// Strategy defines the merge strategy to be used.
Strategy MergeStrategy
}
// MergeStrategy represents the different types of merge strategies.
type MergeStrategy int8
const (
// FastForwardMerge represents a Git merge strategy where the current
// branch can be simply updated to point to the HEAD of the branch being
// merged. This is only possible if the history of the branch being merged
// is a linear descendant of the current branch, with no conflicting commits.
//
// This is the default option.
FastForwardMerge MergeStrategy = iota
)
// Validate validates the fields and sets the default values.
func (o *CloneOptions) Validate() error {
if o.URL == "" {
@@ -166,7 +185,7 @@ const (
// AllTags fetch all tags from the remote (i.e., fetch remote tags
// refs/tags/* into local tags with the same name)
AllTags
//NoTags fetch no tags from the remote at all
// NoTags fetch no tags from the remote at all
NoTags
)
@@ -198,6 +217,9 @@ type FetchOptions struct {
CABundle []byte
// ProxyOptions provides info required for connecting to a proxy.
ProxyOptions transport.ProxyOptions
// Prune specify that local refs that match given RefSpecs and that do
// not exist remotely will be removed.
Prune bool
}
// Validate validates the fields and sets the default values.
@@ -324,9 +346,9 @@ var (
// CheckoutOptions describes how a checkout operation should be performed.
type CheckoutOptions struct {
// Hash is the hash of the commit to be checked out. If used, HEAD will be
// in detached mode. If Create is not used, Branch and Hash are mutually
// exclusive.
// Hash is the hash of a commit or tag to be checked out. If used, HEAD
// will be in detached mode. If Create is not used, Branch and Hash are
// mutually exclusive.
Hash plumbing.Hash
// Branch to be checked out, if Branch and Hash are empty is set to `master`.
Branch plumbing.ReferenceName
@@ -405,6 +427,11 @@ func (o *ResetOptions) Validate(r *Repository) error {
}
o.Commit = ref.Hash()
} else {
_, err := r.CommitObject(o.Commit)
if err != nil {
return fmt.Errorf("invalid reset option: %w", err)
}
}
return nil
@@ -474,6 +501,11 @@ type AddOptions struct {
// Glob adds all paths, matching pattern, to the index. If pattern matches a
// directory path, all directory contents are added to the index recursively.
Glob string
// SkipStatus adds the path with no status check. This option is relevant only
// when the `Path` option is specified and does not apply when the `All` option is used.
// Notice that when passing an ignored path it will be added anyway.
// When true it can speed up adding files to the worktree in very large repositories.
SkipStatus bool
}
// Validate validates the fields and sets the default values.
@@ -507,6 +539,10 @@ type CommitOptions struct {
// commit will not be signed. The private key must be present and already
// decrypted.
SignKey *openpgp.Entity
// Signer denotes a cryptographic signer to sign the commit with.
// A nil value here means the commit will not be signed.
// Takes precedence over SignKey.
Signer Signer
// Amend will create a new commit object and replace the commit that HEAD currently
// points to. Cannot be used with All nor Parents.
Amend bool

View File

@@ -116,7 +116,7 @@ func loadPatterns(fs billy.Filesystem, path string) (ps []Pattern, err error) {
return
}
// LoadGlobalPatterns loads gitignore patterns from from the gitignore file
// LoadGlobalPatterns loads gitignore patterns from the gitignore file
// declared in a user's ~/.gitconfig file. If the ~/.gitconfig file does not
// exist the function will return nil. If the core.excludesfile property
// is not declared, the function will return nil. If the file pointed to by
@@ -132,7 +132,7 @@ func LoadGlobalPatterns(fs billy.Filesystem) (ps []Pattern, err error) {
return loadPatterns(fs, fs.Join(home, gitconfigFile))
}
// LoadSystemPatterns loads gitignore patterns from from the gitignore file
// LoadSystemPatterns loads gitignore patterns from the gitignore file
// declared in a system's /etc/gitconfig file. If the /etc/gitconfig file does
// not exist the function will return nil. If the core.excludesfile property
// is not declared, the function will return nil. If the file pointed to by

View File

@@ -27,7 +27,7 @@ const (
// the commit with the "mergetag" header.
headermergetag string = "mergetag"
defaultUtf8CommitMesageEncoding MessageEncoding = "UTF-8"
defaultUtf8CommitMessageEncoding MessageEncoding = "UTF-8"
)
// Hash represents the hash of an object
@@ -189,7 +189,7 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) {
}
c.Hash = o.Hash()
c.Encoding = defaultUtf8CommitMesageEncoding
c.Encoding = defaultUtf8CommitMessageEncoding
reader, err := o.Reader()
if err != nil {
@@ -335,7 +335,7 @@ func (c *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
}
}
if string(c.Encoding) != "" && c.Encoding != defaultUtf8CommitMesageEncoding {
if string(c.Encoding) != "" && c.Encoding != defaultUtf8CommitMessageEncoding {
if _, err = fmt.Fprintf(w, "\n%s %s", headerencoding, c.Encoding); err != nil {
return err
}

View File

@@ -57,6 +57,8 @@ func (c *commitPathIter) Next() (*Commit, error) {
}
func (c *commitPathIter) getNextFileCommit() (*Commit, error) {
var parentTree, currentTree *Tree
for {
// Parent-commit can be nil if the current-commit is the initial commit
parentCommit, parentCommitErr := c.sourceIter.Next()
@@ -68,13 +70,17 @@ func (c *commitPathIter) getNextFileCommit() (*Commit, error) {
parentCommit = nil
}
// Fetch the trees of the current and parent commits
currentTree, currTreeErr := c.currentCommit.Tree()
if currTreeErr != nil {
return nil, currTreeErr
if parentTree == nil {
var currTreeErr error
currentTree, currTreeErr = c.currentCommit.Tree()
if currTreeErr != nil {
return nil, currTreeErr
}
} else {
currentTree = parentTree
parentTree = nil
}
var parentTree *Tree
if parentCommit != nil {
var parentTreeErr error
parentTree, parentTreeErr = parentCommit.Tree()
@@ -115,7 +121,8 @@ func (c *commitPathIter) hasFileChange(changes Changes, parent *Commit) bool {
// filename matches, now check if source iterator contains all commits (from all refs)
if c.checkParent {
if parent != nil && isParentHash(parent.Hash, c.currentCommit) {
// Check if parent is beyond the initial commit
if parent == nil || isParentHash(parent.Hash, c.currentCommit) {
return true
}
continue

View File

@@ -6,7 +6,7 @@ import (
"errors"
"fmt"
"io"
"math"
"strconv"
"strings"
"github.com/go-git/go-git/v5/plumbing"
@@ -234,69 +234,56 @@ func (fileStats FileStats) String() string {
return printStat(fileStats)
}
// printStat prints the stats of changes in content of files.
// Original implementation: https://github.com/git/git/blob/1a87c842ece327d03d08096395969aca5e0a6996/diff.c#L2615
// Parts of the output:
// <pad><filename><pad>|<pad><changeNumber><pad><+++/---><newline>
// example: " main.go | 10 +++++++--- "
func printStat(fileStats []FileStat) string {
padLength := float64(len(" "))
newlineLength := float64(len("\n"))
separatorLength := float64(len("|"))
// Soft line length limit. The text length calculation below excludes
// length of the change number. Adding that would take it closer to 80,
// but probably not more than 80, until it's a huge number.
lineLength := 72.0
maxGraphWidth := uint(53)
maxNameLen := 0
maxChangeLen := 0
scaleLinear := func(it, width, max uint) uint {
if it == 0 || max == 0 {
return 0
}
return 1 + (it * (width - 1) / max)
}
// Get the longest filename and longest total change.
var longestLength float64
var longestTotalChange float64
for _, fs := range fileStats {
if int(longestLength) < len(fs.Name) {
longestLength = float64(len(fs.Name))
if len(fs.Name) > maxNameLen {
maxNameLen = len(fs.Name)
}
totalChange := fs.Addition + fs.Deletion
if int(longestTotalChange) < totalChange {
longestTotalChange = float64(totalChange)
changes := strconv.Itoa(fs.Addition + fs.Deletion)
if len(changes) > maxChangeLen {
maxChangeLen = len(changes)
}
}
// Parts of the output:
// <pad><filename><pad>|<pad><changeNumber><pad><+++/---><newline>
// example: " main.go | 10 +++++++--- "
// <pad><filename><pad>
leftTextLength := padLength + longestLength + padLength
// <pad><number><pad><+++++/-----><newline>
// Excluding number length here.
rightTextLength := padLength + padLength + newlineLength
totalTextArea := leftTextLength + separatorLength + rightTextLength
heightOfHistogram := lineLength - totalTextArea
// Scale the histogram.
var scaleFactor float64
if longestTotalChange > heightOfHistogram {
// Scale down to heightOfHistogram.
scaleFactor = longestTotalChange / heightOfHistogram
} else {
scaleFactor = 1.0
}
finalOutput := ""
result := ""
for _, fs := range fileStats {
addn := float64(fs.Addition)
deln := float64(fs.Deletion)
addc := int(math.Floor(addn/scaleFactor))
delc := int(math.Floor(deln/scaleFactor))
if addc < 0 {
addc = 0
}
if delc < 0 {
delc = 0
}
adds := strings.Repeat("+", addc)
dels := strings.Repeat("-", delc)
finalOutput += fmt.Sprintf(" %s | %d %s%s\n", fs.Name, (fs.Addition + fs.Deletion), adds, dels)
}
add := uint(fs.Addition)
del := uint(fs.Deletion)
np := maxNameLen - len(fs.Name)
cp := maxChangeLen - len(strconv.Itoa(fs.Addition+fs.Deletion))
return finalOutput
total := add + del
if total > maxGraphWidth {
add = scaleLinear(add, maxGraphWidth, total)
del = scaleLinear(del, maxGraphWidth, total)
}
adds := strings.Repeat("+", int(add))
dels := strings.Repeat("-", int(del))
namePad := strings.Repeat(" ", np)
changePad := strings.Repeat(" ", cp)
result += fmt.Sprintf(" %s%s | %s%d %s%s\n", fs.Name, namePad, changePad, total, adds, dels)
}
return result
}
func getFileStatsFromFilePatches(filePatches []fdiff.FilePatch) FileStats {

View File

@@ -7,6 +7,7 @@ import (
"io"
"path"
"path/filepath"
"sort"
"strings"
"github.com/go-git/go-git/v5/plumbing"
@@ -27,6 +28,7 @@ var (
ErrFileNotFound = errors.New("file not found")
ErrDirectoryNotFound = errors.New("directory not found")
ErrEntryNotFound = errors.New("entry not found")
ErrEntriesNotSorted = errors.New("entries in tree are not sorted")
)
// Tree is basically like a directory - it references a bunch of other trees
@@ -270,6 +272,28 @@ func (t *Tree) Decode(o plumbing.EncodedObject) (err error) {
return nil
}
type TreeEntrySorter []TreeEntry
func (s TreeEntrySorter) Len() int {
return len(s)
}
func (s TreeEntrySorter) Less(i, j int) bool {
name1 := s[i].Name
name2 := s[j].Name
if s[i].Mode == filemode.Dir {
name1 += "/"
}
if s[j].Mode == filemode.Dir {
name2 += "/"
}
return name1 < name2
}
func (s TreeEntrySorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Encode transforms a Tree into a plumbing.EncodedObject.
func (t *Tree) Encode(o plumbing.EncodedObject) (err error) {
o.SetType(plumbing.TreeObject)
@@ -279,7 +303,15 @@ func (t *Tree) Encode(o plumbing.EncodedObject) (err error) {
}
defer ioutil.CheckClose(w, &err)
if !sort.IsSorted(TreeEntrySorter(t.Entries)) {
return ErrEntriesNotSorted
}
for _, entry := range t.Entries {
if strings.IndexByte(entry.Name, 0) != -1 {
return fmt.Errorf("malformed filename %q", entry.Name)
}
if _, err = fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil {
return err
}

View File

@@ -88,7 +88,9 @@ func (t *treeNoder) Children() ([]noder.Noder, error) {
}
}
return transformChildren(parent)
var err error
t.children, err = transformChildren(parent)
return t.children, err
}
// Returns the children of a tree as treenoders.

View File

@@ -91,9 +91,9 @@ func advertisedReferences(ctx context.Context, s *session, serviceName string) (
}
type client struct {
c *http.Client
client *http.Client
transports *lru.Cache
m sync.RWMutex
mutex sync.RWMutex
}
// ClientOptions holds user configurable options for the client.
@@ -147,7 +147,7 @@ func NewClientWithOptions(c *http.Client, opts *ClientOptions) transport.Transpo
}
}
cl := &client{
c: c,
client: c,
}
if opts != nil {
@@ -234,10 +234,10 @@ func newSession(c *client, ep *transport.Endpoint, auth transport.AuthMethod) (*
// if the client wasn't configured to have a cache for transports then just configure
// the transport and use it directly, otherwise try to use the cache.
if c.transports == nil {
tr, ok := c.c.Transport.(*http.Transport)
tr, ok := c.client.Transport.(*http.Transport)
if !ok {
return nil, fmt.Errorf("expected underlying client transport to be of type: %s; got: %s",
reflect.TypeOf(transport), reflect.TypeOf(c.c.Transport))
reflect.TypeOf(transport), reflect.TypeOf(c.client.Transport))
}
transport = tr.Clone()
@@ -258,7 +258,7 @@ func newSession(c *client, ep *transport.Endpoint, auth transport.AuthMethod) (*
transport, found = c.fetchTransport(transportOpts)
if !found {
transport = c.c.Transport.(*http.Transport).Clone()
transport = c.client.Transport.(*http.Transport).Clone()
configureTransport(transport, ep)
c.addTransport(transportOpts, transport)
}
@@ -266,12 +266,12 @@ func newSession(c *client, ep *transport.Endpoint, auth transport.AuthMethod) (*
httpClient = &http.Client{
Transport: transport,
CheckRedirect: c.c.CheckRedirect,
Jar: c.c.Jar,
Timeout: c.c.Timeout,
CheckRedirect: c.client.CheckRedirect,
Jar: c.client.Jar,
Timeout: c.client.Timeout,
}
} else {
httpClient = c.c
httpClient = c.client
}
s := &session{

View File

@@ -14,21 +14,21 @@ type transportOptions struct {
}
func (c *client) addTransport(opts transportOptions, transport *http.Transport) {
c.m.Lock()
c.mutex.Lock()
c.transports.Add(opts, transport)
c.m.Unlock()
c.mutex.Unlock()
}
func (c *client) removeTransport(opts transportOptions) {
c.m.Lock()
c.mutex.Lock()
c.transports.Remove(opts)
c.m.Unlock()
c.mutex.Unlock()
}
func (c *client) fetchTransport(opts transportOptions) (*http.Transport, bool) {
c.m.RLock()
c.mutex.RLock()
t, ok := c.transports.Get(opts)
c.m.RUnlock()
c.mutex.RUnlock()
if !ok {
return nil, false
}

View File

@@ -49,7 +49,9 @@ type runner struct {
func (r *runner) Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
c := &command{command: cmd, endpoint: ep, config: r.config}
if auth != nil {
c.setAuth(auth)
if err := c.setAuth(auth); err != nil {
return nil, err
}
}
if err := c.connect(); err != nil {

View File

@@ -470,6 +470,14 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (sto storer.Referen
}
}
var updatedPrune bool
if o.Prune {
updatedPrune, err = r.pruneRemotes(o.RefSpecs, localRefs, remoteRefs)
if err != nil {
return nil, err
}
}
updated, err := r.updateLocalReferenceStorage(o.RefSpecs, refs, remoteRefs, specToRefs, o.Tags, o.Force)
if err != nil {
return nil, err
@@ -482,7 +490,7 @@ func (r *Remote) fetch(ctx context.Context, o *FetchOptions) (sto storer.Referen
}
}
if !updated {
if !updated && !updatedPrune {
return remoteRefs, NoErrAlreadyUpToDate
}
@@ -574,6 +582,27 @@ func (r *Remote) fetchPack(ctx context.Context, o *FetchOptions, s transport.Upl
return err
}
func (r *Remote) pruneRemotes(specs []config.RefSpec, localRefs []*plumbing.Reference, remoteRefs memory.ReferenceStorage) (bool, error) {
var updatedPrune bool
for _, spec := range specs {
rev := spec.Reverse()
for _, ref := range localRefs {
if !rev.Match(ref.Name()) {
continue
}
_, err := remoteRefs.Reference(rev.Dst(ref.Name()))
if errors.Is(err, plumbing.ErrReferenceNotFound) {
updatedPrune = true
err := r.s.RemoveReference(ref.Name())
if err != nil {
return false, err
}
}
}
}
return updatedPrune, nil
}
func (r *Remote) addReferencesToUpdate(
refspecs []config.RefSpec,
localRefs []*plumbing.Reference,
@@ -1099,7 +1128,7 @@ func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earlies
}
found := false
// stop iterating at the earlist shallow commit, ignoring its parents
// stop iterating at the earliest shallow commit, ignoring its parents
// note: when pull depth is smaller than the number of new changes on the remote, this fails due to missing parents.
// as far as i can tell, without the commits in-between the shallow pull and the earliest shallow, there's no
// real way of telling whether it will be a fast-forward merge.

View File

@@ -51,19 +51,21 @@ var (
// ErrFetching is returned when the packfile could not be downloaded
ErrFetching = errors.New("unable to fetch packfile")
ErrInvalidReference = errors.New("invalid reference, should be a tag or a branch")
ErrRepositoryNotExists = errors.New("repository does not exist")
ErrRepositoryIncomplete = errors.New("repository's commondir path does not exist")
ErrRepositoryAlreadyExists = errors.New("repository already exists")
ErrRemoteNotFound = errors.New("remote not found")
ErrRemoteExists = errors.New("remote already exists")
ErrAnonymousRemoteName = errors.New("anonymous remote name must be 'anonymous'")
ErrWorktreeNotProvided = errors.New("worktree should be provided")
ErrIsBareRepository = errors.New("worktree not available in a bare repository")
ErrUnableToResolveCommit = errors.New("unable to resolve commit")
ErrPackedObjectsNotSupported = errors.New("packed objects not supported")
ErrSHA256NotSupported = errors.New("go-git was not compiled with SHA256 support")
ErrAlternatePathNotSupported = errors.New("alternate path must use the file scheme")
ErrInvalidReference = errors.New("invalid reference, should be a tag or a branch")
ErrRepositoryNotExists = errors.New("repository does not exist")
ErrRepositoryIncomplete = errors.New("repository's commondir path does not exist")
ErrRepositoryAlreadyExists = errors.New("repository already exists")
ErrRemoteNotFound = errors.New("remote not found")
ErrRemoteExists = errors.New("remote already exists")
ErrAnonymousRemoteName = errors.New("anonymous remote name must be 'anonymous'")
ErrWorktreeNotProvided = errors.New("worktree should be provided")
ErrIsBareRepository = errors.New("worktree not available in a bare repository")
ErrUnableToResolveCommit = errors.New("unable to resolve commit")
ErrPackedObjectsNotSupported = errors.New("packed objects not supported")
ErrSHA256NotSupported = errors.New("go-git was not compiled with SHA256 support")
ErrAlternatePathNotSupported = errors.New("alternate path must use the file scheme")
ErrUnsupportedMergeStrategy = errors.New("unsupported merge strategy")
ErrFastForwardMergeNotPossible = errors.New("not possible to fast-forward merge changes")
)
// Repository represents a git repository
@@ -1769,8 +1771,43 @@ func (r *Repository) RepackObjects(cfg *RepackConfig) (err error) {
return nil
}
// Merge merges the reference branch into the current branch.
//
// If the merge is not possible (or supported) returns an error without changing
// the HEAD for the current branch. Possible errors include:
// - The merge strategy is not supported.
// - The specific strategy cannot be used (e.g. using FastForwardMerge when one is not possible).
func (r *Repository) Merge(ref plumbing.Reference, opts MergeOptions) error {
if opts.Strategy != FastForwardMerge {
return ErrUnsupportedMergeStrategy
}
// Ignore error as not having a shallow list is optional here.
shallowList, _ := r.Storer.Shallow()
var earliestShallow *plumbing.Hash
if len(shallowList) > 0 {
earliestShallow = &shallowList[0]
}
head, err := r.Head()
if err != nil {
return err
}
ff, err := isFastForward(r.Storer, head.Hash(), ref.Hash(), earliestShallow)
if err != nil {
return err
}
if !ff {
return ErrFastForwardMergeNotPossible
}
return r.Storer.SetReference(plumbing.NewHashReference(head.Name(), ref.Hash()))
}
// createNewObjectPack is a helper for RepackObjects taking care
// of creating a new pack. It is used so the the PackfileWriter
// of creating a new pack. It is used so the PackfileWriter
// deferred close has the right scope.
func (r *Repository) createNewObjectPack(cfg *RepackConfig) (h plumbing.Hash, err error) {
ow := newObjectWalker(r.Storer)

33
vendor/github.com/go-git/go-git/v5/signer.go generated vendored Normal file
View File

@@ -0,0 +1,33 @@
package git
import (
"io"
"github.com/go-git/go-git/v5/plumbing"
)
// signableObject is an object which can be signed.
type signableObject interface {
EncodeWithoutSignature(o plumbing.EncodedObject) error
}
// Signer is an interface for signing git objects.
// message is a reader containing the encoded object to be signed.
// Implementors should return the encoded signature and an error if any.
// See https://git-scm.com/docs/gitformat-signature for more information.
type Signer interface {
Sign(message io.Reader) ([]byte, error)
}
func signObject(signer Signer, obj signableObject) ([]byte, error) {
encoded := &plumbing.MemoryObject{}
if err := obj.EncodeWithoutSignature(encoded); err != nil {
return nil, err
}
r, err := encoded.Reader()
if err != nil {
return nil, err
}
return signer.Sign(r)
}

View File

@@ -29,6 +29,8 @@ type node struct {
hash []byte
children []noder.Noder
isDir bool
mode os.FileMode
size int64
}
// NewRootNode returns the root node based on a given billy.Filesystem.
@@ -48,8 +50,15 @@ func NewRootNode(
// difftree algorithm will detect changes in the contents of files and also in
// their mode.
//
// Please note that the hash is calculated on first invocation of Hash(),
// meaning that it will not update when the underlying file changes
// between invocations.
//
// The hash of a directory is always a 24-bytes slice of zero values
func (n *node) Hash() []byte {
if n.hash == nil {
n.calculateHash()
}
return n.hash
}
@@ -121,81 +130,74 @@ func (n *node) calculateChildren() error {
func (n *node) newChildNode(file os.FileInfo) (*node, error) {
path := path.Join(n.path, file.Name())
hash, err := n.calculateHash(path, file)
if err != nil {
return nil, err
}
node := &node{
fs: n.fs,
submodules: n.submodules,
path: path,
hash: hash,
isDir: file.IsDir(),
size: file.Size(),
mode: file.Mode(),
}
if hash, isSubmodule := n.submodules[path]; isSubmodule {
node.hash = append(hash[:], filemode.Submodule.Bytes()...)
if _, isSubmodule := n.submodules[path]; isSubmodule {
node.isDir = false
}
return node, nil
}
func (n *node) calculateHash(path string, file os.FileInfo) ([]byte, error) {
if file.IsDir() {
return make([]byte, 24), nil
func (n *node) calculateHash() {
if n.isDir {
n.hash = make([]byte, 24)
return
}
mode, err := filemode.NewFromOSFileMode(n.mode)
if err != nil {
n.hash = plumbing.ZeroHash[:]
return
}
if submoduleHash, isSubmodule := n.submodules[n.path]; isSubmodule {
n.hash = append(submoduleHash[:], filemode.Submodule.Bytes()...)
return
}
var hash plumbing.Hash
var err error
if file.Mode()&os.ModeSymlink != 0 {
hash, err = n.doCalculateHashForSymlink(path, file)
if n.mode&os.ModeSymlink != 0 {
hash = n.doCalculateHashForSymlink()
} else {
hash, err = n.doCalculateHashForRegular(path, file)
hash = n.doCalculateHashForRegular()
}
if err != nil {
return nil, err
}
mode, err := filemode.NewFromOSFileMode(file.Mode())
if err != nil {
return nil, err
}
return append(hash[:], mode.Bytes()...), nil
n.hash = append(hash[:], mode.Bytes()...)
}
func (n *node) doCalculateHashForRegular(path string, file os.FileInfo) (plumbing.Hash, error) {
f, err := n.fs.Open(path)
func (n *node) doCalculateHashForRegular() plumbing.Hash {
f, err := n.fs.Open(n.path)
if err != nil {
return plumbing.ZeroHash, err
return plumbing.ZeroHash
}
defer f.Close()
h := plumbing.NewHasher(plumbing.BlobObject, file.Size())
h := plumbing.NewHasher(plumbing.BlobObject, n.size)
if _, err := io.Copy(h, f); err != nil {
return plumbing.ZeroHash, err
return plumbing.ZeroHash
}
return h.Sum(), nil
return h.Sum()
}
func (n *node) doCalculateHashForSymlink(path string, file os.FileInfo) (plumbing.Hash, error) {
target, err := n.fs.Readlink(path)
func (n *node) doCalculateHashForSymlink() plumbing.Hash {
target, err := n.fs.Readlink(n.path)
if err != nil {
return plumbing.ZeroHash, err
return plumbing.ZeroHash
}
h := plumbing.NewHasher(plumbing.BlobObject, file.Size())
h := plumbing.NewHasher(plumbing.BlobObject, n.size)
if _, err := h.Write([]byte(target)); err != nil {
return plumbing.ZeroHash, err
return plumbing.ZeroHash
}
return h.Sum(), nil
return h.Sum()
}
func (n *node) String() string {

View File

@@ -227,20 +227,17 @@ func (w *Worktree) createBranch(opts *CheckoutOptions) error {
}
func (w *Worktree) getCommitFromCheckoutOptions(opts *CheckoutOptions) (plumbing.Hash, error) {
if !opts.Hash.IsZero() {
return opts.Hash, nil
hash := opts.Hash
if hash.IsZero() {
b, err := w.r.Reference(opts.Branch, true)
if err != nil {
return plumbing.ZeroHash, err
}
hash = b.Hash()
}
b, err := w.r.Reference(opts.Branch, true)
if err != nil {
return plumbing.ZeroHash, err
}
if !b.Name().IsTag() {
return b.Hash(), nil
}
o, err := w.r.Object(plumbing.AnyObject, b.Hash())
o, err := w.r.Object(plumbing.AnyObject, hash)
if err != nil {
return plumbing.ZeroHash, err
}
@@ -248,7 +245,7 @@ func (w *Worktree) getCommitFromCheckoutOptions(opts *CheckoutOptions) (plumbing
switch o := o.(type) {
case *object.Tag:
if o.TargetType != plumbing.CommitObject {
return plumbing.ZeroHash, fmt.Errorf("unsupported tag object target %q", o.TargetType)
return plumbing.ZeroHash, fmt.Errorf("%w: tag target %q", object.ErrUnsupportedObject, o.TargetType)
}
return o.Target, nil
@@ -256,7 +253,7 @@ func (w *Worktree) getCommitFromCheckoutOptions(opts *CheckoutOptions) (plumbing
return o.Hash, nil
}
return plumbing.ZeroHash, fmt.Errorf("unsupported tag target %q", o.Type())
return plumbing.ZeroHash, fmt.Errorf("%w: %q", object.ErrUnsupportedObject, o.Type())
}
func (w *Worktree) setHEADToCommit(commit plumbing.Hash) error {
@@ -431,6 +428,10 @@ var worktreeDeny = map[string]struct{}{
func validPath(paths ...string) error {
for _, p := range paths {
parts := strings.FieldsFunc(p, func(r rune) bool { return (r == '\\' || r == '/') })
if len(parts) == 0 {
return fmt.Errorf("invalid path: %q", p)
}
if _, denied := worktreeDeny[strings.ToLower(parts[0])]; denied {
return fmt.Errorf("invalid path prefix: %q", p)
}

View File

@@ -3,6 +3,7 @@ package git
import (
"bytes"
"errors"
"io"
"path"
"sort"
"strings"
@@ -14,6 +15,7 @@ import (
"github.com/go-git/go-git/v5/storage"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/ProtonMail/go-crypto/openpgp/packet"
"github.com/go-git/go-billy/v5"
)
@@ -43,29 +45,30 @@ func (w *Worktree) Commit(msg string, opts *CommitOptions) (plumbing.Hash, error
if err != nil {
return plumbing.ZeroHash, err
}
t, err := w.r.getTreeFromCommitHash(head.Hash())
headCommit, err := w.r.CommitObject(head.Hash())
if err != nil {
return plumbing.ZeroHash, err
}
treeHash = t.Hash
opts.Parents = []plumbing.Hash{head.Hash()}
} else {
idx, err := w.r.Storer.Index()
if err != nil {
return plumbing.ZeroHash, err
opts.Parents = nil
if len(headCommit.ParentHashes) != 0 {
opts.Parents = []plumbing.Hash{headCommit.ParentHashes[0]}
}
}
h := &buildTreeHelper{
fs: w.Filesystem,
s: w.r.Storer,
}
idx, err := w.r.Storer.Index()
if err != nil {
return plumbing.ZeroHash, err
}
treeHash, err = h.BuildTree(idx, opts)
if err != nil {
return plumbing.ZeroHash, err
}
h := &buildTreeHelper{
fs: w.Filesystem,
s: w.r.Storer,
}
treeHash, err = h.BuildTree(idx, opts)
if err != nil {
return plumbing.ZeroHash, err
}
commit, err := w.buildCommitObject(msg, opts, treeHash)
@@ -125,12 +128,17 @@ func (w *Worktree) buildCommitObject(msg string, opts *CommitOptions, tree plumb
ParentHashes: opts.Parents,
}
if opts.SignKey != nil {
sig, err := w.buildCommitSignature(commit, opts.SignKey)
// Convert SignKey into a Signer if set. Existing Signer should take priority.
signer := opts.Signer
if signer == nil && opts.SignKey != nil {
signer = &gpgSigner{key: opts.SignKey}
}
if signer != nil {
sig, err := signObject(signer, commit)
if err != nil {
return plumbing.ZeroHash, err
}
commit.PGPSignature = sig
commit.PGPSignature = string(sig)
}
obj := w.r.Storer.NewEncodedObject()
@@ -140,20 +148,17 @@ func (w *Worktree) buildCommitObject(msg string, opts *CommitOptions, tree plumb
return w.r.Storer.SetEncodedObject(obj)
}
func (w *Worktree) buildCommitSignature(commit *object.Commit, signKey *openpgp.Entity) (string, error) {
encoded := &plumbing.MemoryObject{}
if err := commit.Encode(encoded); err != nil {
return "", err
}
r, err := encoded.Reader()
if err != nil {
return "", err
}
type gpgSigner struct {
key *openpgp.Entity
cfg *packet.Config
}
func (s *gpgSigner) Sign(message io.Reader) ([]byte, error) {
var b bytes.Buffer
if err := openpgp.ArmoredDetachSign(&b, signKey, r, nil); err != nil {
return "", err
if err := openpgp.ArmoredDetachSign(&b, s.key, message, s.cfg); err != nil {
return nil, err
}
return b.String(), nil
return b.Bytes(), nil
}
// buildTreeHelper converts a given index.Index file into multiple git objects
@@ -263,4 +268,4 @@ func (h *buildTreeHelper) copyTreeToStorageRecursive(parent string, t *object.Tr
return hash, nil
}
return h.s.SetEncodedObject(o)
}
}

View File

@@ -271,7 +271,7 @@ func diffTreeIsEquals(a, b noder.Hasher) bool {
// no error is returned. When path is a file, the blob.Hash is returned.
func (w *Worktree) Add(path string) (plumbing.Hash, error) {
// TODO(mcuadros): deprecate in favor of AddWithOption in v6.
return w.doAdd(path, make([]gitignore.Pattern, 0))
return w.doAdd(path, make([]gitignore.Pattern, 0), false)
}
func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string, ignorePattern []gitignore.Pattern) (added bool, err error) {
@@ -321,7 +321,7 @@ func (w *Worktree) AddWithOptions(opts *AddOptions) error {
}
if opts.All {
_, err := w.doAdd(".", w.Excludes)
_, err := w.doAdd(".", w.Excludes, false)
return err
}
@@ -329,16 +329,11 @@ func (w *Worktree) AddWithOptions(opts *AddOptions) error {
return w.AddGlob(opts.Glob)
}
_, err := w.Add(opts.Path)
_, err := w.doAdd(opts.Path, make([]gitignore.Pattern, 0), opts.SkipStatus)
return err
}
func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern) (plumbing.Hash, error) {
s, err := w.Status()
if err != nil {
return plumbing.ZeroHash, err
}
func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern, skipStatus bool) (plumbing.Hash, error) {
idx, err := w.r.Storer.Index()
if err != nil {
return plumbing.ZeroHash, err
@@ -348,6 +343,17 @@ func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern) (plumbi
var added bool
fi, err := w.Filesystem.Lstat(path)
// status is required for doAddDirectory
var s Status
var err2 error
if !skipStatus || fi == nil || fi.IsDir() {
s, err2 = w.Status()
if err2 != nil {
return plumbing.ZeroHash, err2
}
}
if err != nil || !fi.IsDir() {
added, h, err = w.doAddFile(idx, s, path, ignorePattern)
} else {
@@ -421,8 +427,9 @@ func (w *Worktree) AddGlob(pattern string) error {
// doAddFile create a new blob from path and update the index, added is true if
// the file added is different from the index.
// if s status is nil will skip the status check and update the index anyway
func (w *Worktree) doAddFile(idx *index.Index, s Status, path string, ignorePattern []gitignore.Pattern) (added bool, h plumbing.Hash, err error) {
if s.File(path).Worktree == Unmodified {
if s != nil && s.File(path).Worktree == Unmodified {
return false, h, nil
}
if len(ignorePattern) > 0 {

View File

@@ -34,8 +34,6 @@ const (
DiffInsert Operation = 1
// DiffEqual item represents an equal diff.
DiffEqual Operation = 0
//IndexSeparator is used to seperate the array indexes in an index string
IndexSeparator = ","
)
// Diff represents one diff operation
@@ -406,14 +404,11 @@ func (dmp *DiffMatchPatch) DiffLinesToRunes(text1, text2 string) ([]rune, []rune
func (dmp *DiffMatchPatch) DiffCharsToLines(diffs []Diff, lineArray []string) []Diff {
hydrated := make([]Diff, 0, len(diffs))
for _, aDiff := range diffs {
chars := strings.Split(aDiff.Text, IndexSeparator)
text := make([]string, len(chars))
runes := []rune(aDiff.Text)
text := make([]string, len(runes))
for i, r := range chars {
i1, err := strconv.Atoi(r)
if err == nil {
text[i] = lineArray[i1]
}
for i, r := range runes {
text[i] = lineArray[runeToInt(r)]
}
aDiff.Text = strings.Join(text, "")
@@ -1313,17 +1308,17 @@ func (dmp *DiffMatchPatch) diffLinesToStrings(text1, text2 string) (string, stri
// '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character.
lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n'
lineHash := make(map[string]int)
//Each string has the index of lineArray which it points to
strIndexArray1 := dmp.diffLinesToStringsMunge(text1, &lineArray)
strIndexArray2 := dmp.diffLinesToStringsMunge(text2, &lineArray)
strIndexArray1 := dmp.diffLinesToStringsMunge(text1, &lineArray, lineHash)
strIndexArray2 := dmp.diffLinesToStringsMunge(text2, &lineArray, lineHash)
return intArrayToString(strIndexArray1), intArrayToString(strIndexArray2), lineArray
}
// diffLinesToStringsMunge splits a text into an array of strings, and reduces the texts to a []string.
func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string) []uint32 {
func (dmp *DiffMatchPatch) diffLinesToStringsMunge(text string, lineArray *[]string, lineHash map[string]int) []uint32 {
// Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect.
lineHash := map[string]int{} // e.g. lineHash['Hello\n'] == 4
lineStart := 0
lineEnd := -1
strs := []uint32{}

View File

@@ -9,11 +9,16 @@
package diffmatchpatch
import (
"strconv"
"fmt"
"strings"
"unicode/utf8"
)
const UNICODE_INVALID_RANGE_START = 0xD800
const UNICODE_INVALID_RANGE_END = 0xDFFF
const UNICODE_INVALID_RANGE_DELTA = UNICODE_INVALID_RANGE_END - UNICODE_INVALID_RANGE_START + 1
const UNICODE_RANGE_MAX = 0x10FFFF
// unescaper unescapes selected chars for compatibility with JavaScript's encodeURI.
// In speed critical applications this could be dropped since the receiving application will certainly decode these fine. Note that this function is case-sensitive. Thus "%3F" would not be unescaped. But this is ok because it is only called with the output of HttpUtility.UrlEncode which returns lowercase hex. Example: "%3f" -> "?", "%24" -> "$", etc.
var unescaper = strings.NewReplacer(
@@ -93,14 +98,93 @@ func intArrayToString(ns []uint32) string {
return ""
}
indexSeparator := IndexSeparator[0]
// Appr. 3 chars per num plus the comma.
b := []byte{}
b := []rune{}
for _, n := range ns {
b = strconv.AppendInt(b, int64(n), 10)
b = append(b, indexSeparator)
b = append(b, intToRune(n))
}
b = b[:len(b)-1]
return string(b)
}
// These constants define the number of bits representable
// in 1,2,3,4 byte utf8 sequences, respectively.
const ONE_BYTE_BITS = 7
const TWO_BYTE_BITS = 11
const THREE_BYTE_BITS = 16
const FOUR_BYTE_BITS = 21
// Helper for getting a sequence of bits from an integer.
func getBits(i uint32, cnt byte, from byte) byte {
return byte((i >> from) & ((1 << cnt) - 1))
}
// Converts an integer in the range 0~1112060 into a rune.
// Based on the ranges table in https://en.wikipedia.org/wiki/UTF-8
func intToRune(i uint32) rune {
if i < (1 << ONE_BYTE_BITS) {
return rune(i)
}
if i < (1 << TWO_BYTE_BITS) {
r, size := utf8.DecodeRune([]byte{0b11000000 | getBits(i, 5, 6), 0b10000000 | getBits(i, 6, 0)})
if size != 2 || r == utf8.RuneError {
panic(fmt.Sprintf("Error encoding an int %d with size 2, got rune %v and size %d", size, r, i))
}
return r
}
// Last -3 here needed because for some reason 3rd to last codepoint 65533 in this range
// was returning utf8.RuneError during encoding.
if i < ((1 << THREE_BYTE_BITS) - UNICODE_INVALID_RANGE_DELTA - 3) {
if i >= UNICODE_INVALID_RANGE_START {
i += UNICODE_INVALID_RANGE_DELTA
}
r, size := utf8.DecodeRune([]byte{0b11100000 | getBits(i, 4, 12), 0b10000000 | getBits(i, 6, 6), 0b10000000 | getBits(i, 6, 0)})
if size != 3 || r == utf8.RuneError {
panic(fmt.Sprintf("Error encoding an int %d with size 3, got rune %v and size %d", size, r, i))
}
return r
}
if i < (1<<FOUR_BYTE_BITS - UNICODE_INVALID_RANGE_DELTA - 3) {
i += UNICODE_INVALID_RANGE_DELTA + 3
r, size := utf8.DecodeRune([]byte{0b11110000 | getBits(i, 3, 18), 0b10000000 | getBits(i, 6, 12), 0b10000000 | getBits(i, 6, 6), 0b10000000 | getBits(i, 6, 0)})
if size != 4 || r == utf8.RuneError {
panic(fmt.Sprintf("Error encoding an int %d with size 4, got rune %v and size %d", size, r, i))
}
return r
}
panic(fmt.Sprintf("The integer %d is too large for runeToInt()", i))
}
// Converts a rune generated by intToRune back to an integer
func runeToInt(r rune) uint32 {
i := uint32(r)
if i < (1 << ONE_BYTE_BITS) {
return i
}
bytes := []byte{0, 0, 0, 0}
size := utf8.EncodeRune(bytes, r)
if size == 2 {
return uint32(bytes[0]&0b11111)<<6 | uint32(bytes[1]&0b111111)
}
if size == 3 {
result := uint32(bytes[0]&0b1111)<<12 | uint32(bytes[1]&0b111111)<<6 | uint32(bytes[2]&0b111111)
if result >= UNICODE_INVALID_RANGE_END {
return result - UNICODE_INVALID_RANGE_DELTA
}
return result
}
if size == 4 {
result := uint32(bytes[0]&0b111)<<18 | uint32(bytes[1]&0b111111)<<12 | uint32(bytes[2]&0b111111)<<6 | uint32(bytes[3]&0b111111)
return result - UNICODE_INVALID_RANGE_DELTA - 3
}
panic(fmt.Sprintf("Unexpected state decoding rune=%v size=%d", r, size))
}

View File

@@ -1,4 +1,4 @@
Copyright 2023 Skeema LLC and the Skeema Knownhosts authors
Copyright 2024 Skeema LLC and the Skeema Knownhosts authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@@ -100,7 +100,7 @@ config := &ssh.ClientConfig{
## License
**Source code copyright 2023 Skeema LLC and the Skeema Knownhosts authors**
**Source code copyright 2024 Skeema LLC and the Skeema Knownhosts authors**
```text
Licensed under the Apache License, Version 2.0 (the "License");

View File

@@ -76,13 +76,23 @@ func (hkcb HostKeyCallback) HostKeyAlgorithms(hostWithPort string) (algos []stri
// example by https://github.com/golang/crypto/pull/254.
hostKeys := hkcb.HostKeys(hostWithPort)
seen := make(map[string]struct{}, len(hostKeys))
for _, key := range hostKeys {
typ := key.Type()
addAlgo := func(typ string) {
if _, already := seen[typ]; !already {
algos = append(algos, typ)
seen[typ] = struct{}{}
}
}
for _, key := range hostKeys {
typ := key.Type()
if typ == ssh.KeyAlgoRSA {
// KeyAlgoRSASHA256 and KeyAlgoRSASHA512 are only public key algorithms,
// not public key formats, so they can't appear as a PublicKey.Type.
// The corresponding PublicKey.Type is KeyAlgoRSA. See RFC 8332, Section 2.
addAlgo(ssh.KeyAlgoRSASHA512)
addAlgo(ssh.KeyAlgoRSASHA256)
}
addAlgo(typ)
}
return algos
}

10
vendor/modules.txt generated vendored
View File

@@ -8,7 +8,7 @@ github.com/Microsoft/go-winio/internal/fs
github.com/Microsoft/go-winio/internal/socket
github.com/Microsoft/go-winio/internal/stringbuffer
github.com/Microsoft/go-winio/pkg/guid
# github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371
# github.com/ProtonMail/go-crypto v1.0.0
## explicit; go 1.13
github.com/ProtonMail/go-crypto/bitcurves
github.com/ProtonMail/go-crypto/brainpool
@@ -70,7 +70,7 @@ github.com/go-git/go-billy/v5/helper/polyfill
github.com/go-git/go-billy/v5/memfs
github.com/go-git/go-billy/v5/osfs
github.com/go-git/go-billy/v5/util
# github.com/go-git/go-git/v5 v5.11.0
# github.com/go-git/go-git/v5 v5.12.0
## explicit; go 1.19
github.com/go-git/go-git/v5
github.com/go-git/go-git/v5/config
@@ -153,10 +153,10 @@ github.com/pkg/errors
# github.com/pmezard/go-difflib v1.0.0
## explicit
github.com/pmezard/go-difflib/difflib
# github.com/sergi/go-diff v1.2.0
## explicit; go 1.12
# github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3
## explicit; go 1.13
github.com/sergi/go-diff/diffmatchpatch
# github.com/skeema/knownhosts v1.2.1
# github.com/skeema/knownhosts v1.2.2
## explicit; go 1.17
github.com/skeema/knownhosts
# github.com/spf13/cobra v1.8.0