mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 03:03:32 +01:00
chore(deps): bump github.com/go-git/go-git/v5 from 5.16.5 to 5.17.0
Bumps [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) from 5.16.5 to 5.17.0. - [Release notes](https://github.com/go-git/go-git/releases) - [Commits](https://github.com/go-git/go-git/compare/v5.16.5...v5.17.0) --- updated-dependencies: - dependency-name: github.com/go-git/go-git/v5 dependency-version: 5.17.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
4
go.mod
4
go.mod
@@ -5,7 +5,7 @@ go 1.26
|
|||||||
require (
|
require (
|
||||||
github.com/alecthomas/chroma/v2 v2.23.1
|
github.com/alecthomas/chroma/v2 v2.23.1
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/go-git/go-git/v5 v5.16.5
|
github.com/go-git/go-git/v5 v5.17.0
|
||||||
github.com/mattn/go-isatty v0.0.20
|
github.com/mattn/go-isatty v0.0.20
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/spf13/cobra v1.10.2
|
github.com/spf13/cobra v1.10.2
|
||||||
@@ -21,7 +21,7 @@ require (
|
|||||||
github.com/dlclark/regexp2 v1.11.5 // indirect
|
github.com/dlclark/regexp2 v1.11.5 // indirect
|
||||||
github.com/emirpasic/gods v1.18.1 // indirect
|
github.com/emirpasic/gods v1.18.1 // indirect
|
||||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||||
github.com/go-git/go-billy/v5 v5.7.0 // indirect
|
github.com/go-git/go-billy/v5 v5.8.0 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||||
|
|||||||
8
go.sum
8
go.sum
@@ -33,12 +33,12 @@ github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
|
|||||||
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
|
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
|
||||||
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 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
||||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
|
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
|
||||||
github.com/go-git/go-billy/v5 v5.7.0 h1:83lBUJhGWhYp0ngzCMSgllhUSuoHP1iEWYjsPl9nwqM=
|
github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0=
|
||||||
github.com/go-git/go-billy/v5 v5.7.0/go.mod h1:/1IUejTKH8xipsAcdfcSAlUlo2J7lkYV8GTKxAT/L3E=
|
github.com/go-git/go-billy/v5 v5.8.0/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY=
|
||||||
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 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-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
|
||||||
github.com/go-git/go-git/v5 v5.16.5 h1:mdkuqblwr57kVfXri5TTH+nMFLNUxIj9Z7F5ykFbw5s=
|
github.com/go-git/go-git/v5 v5.17.0 h1:AbyI4xf+7DsjINHMu35quAh4wJygKBKBuXVjV/pxesM=
|
||||||
github.com/go-git/go-git/v5 v5.16.5/go.mod h1:QOMLpNf1qxuSY4StA/ArOdfFR2TrKEjJiye2kel2m+M=
|
github.com/go-git/go-git/v5 v5.17.0/go.mod h1:f82C4YiLx+Lhi8eHxltLeGC5uBTXSFa6PC5WW9o4SjI=
|
||||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
|
||||||
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
|||||||
11
vendor/github.com/go-git/go-billy/v5/helper/polyfill/polyfill.go
generated
vendored
11
vendor/github.com/go-git/go-billy/v5/helper/polyfill/polyfill.go
generated
vendored
@@ -13,7 +13,7 @@ type Polyfill struct {
|
|||||||
c capabilities
|
c capabilities
|
||||||
}
|
}
|
||||||
|
|
||||||
type capabilities struct{ tempfile, dir, symlink, chroot bool }
|
type capabilities struct{ tempfile, dir, symlink, chroot, chmod bool }
|
||||||
|
|
||||||
// New creates a new filesystem wrapping up 'fs' the intercepts all the calls
|
// New creates a new filesystem wrapping up 'fs' the intercepts all the calls
|
||||||
// made and errors if fs doesn't implement any of the billy interfaces.
|
// made and errors if fs doesn't implement any of the billy interfaces.
|
||||||
@@ -28,6 +28,7 @@ func New(fs billy.Basic) billy.Filesystem {
|
|||||||
_, h.c.dir = h.Basic.(billy.Dir)
|
_, h.c.dir = h.Basic.(billy.Dir)
|
||||||
_, h.c.symlink = h.Basic.(billy.Symlink)
|
_, h.c.symlink = h.Basic.(billy.Symlink)
|
||||||
_, h.c.chroot = h.Basic.(billy.Chroot)
|
_, h.c.chroot = h.Basic.(billy.Chroot)
|
||||||
|
_, h.c.chmod = h.Basic.(billy.Chmod)
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +88,14 @@ func (h *Polyfill) Chroot(path string) (billy.Filesystem, error) {
|
|||||||
return h.Basic.(billy.Chroot).Chroot(path)
|
return h.Basic.(billy.Chroot).Chroot(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Polyfill) Chmod(path string, mode os.FileMode) error {
|
||||||
|
if !h.c.chmod {
|
||||||
|
return billy.ErrNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
return h.Basic.(billy.Chmod).Chmod(path, mode)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Polyfill) Root() string {
|
func (h *Polyfill) Root() string {
|
||||||
if !h.c.chroot {
|
if !h.c.chroot {
|
||||||
return string(filepath.Separator)
|
return string(filepath.Separator)
|
||||||
|
|||||||
8
vendor/github.com/go-git/go-billy/v5/osfs/os_bound.go
generated
vendored
8
vendor/github.com/go-git/go-billy/v5/osfs/os_bound.go
generated
vendored
@@ -126,6 +126,14 @@ func (fs *BoundOS) TempFile(dir, prefix string) (billy.File, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = os.Stat(dir)
|
||||||
|
if err != nil && os.IsNotExist(err) {
|
||||||
|
err = os.MkdirAll(dir, defaultDirectoryMode)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tempFile(dir, prefix)
|
return tempFile(dir, prefix)
|
||||||
|
|||||||
2
vendor/github.com/go-git/go-git/v5/plumbing/format/index/index.go
generated
vendored
2
vendor/github.com/go-git/go-git/v5/plumbing/format/index/index.go
generated
vendored
@@ -54,6 +54,8 @@ type Index struct {
|
|||||||
ResolveUndo *ResolveUndo
|
ResolveUndo *ResolveUndo
|
||||||
// EndOfIndexEntry represents the 'End of Index Entry' extension
|
// EndOfIndexEntry represents the 'End of Index Entry' extension
|
||||||
EndOfIndexEntry *EndOfIndexEntry
|
EndOfIndexEntry *EndOfIndexEntry
|
||||||
|
// ModTime is the modification time of the index file
|
||||||
|
ModTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add creates a new Entry and returns it. The caller should first check that
|
// Add creates a new Entry and returns it. The caller should first check that
|
||||||
|
|||||||
6
vendor/github.com/go-git/go-git/v5/repository.go
generated
vendored
6
vendor/github.com/go-git/go-git/v5/repository.go
generated
vendored
@@ -208,6 +208,12 @@ func Open(s storage.Storer, worktree billy.Filesystem) (*Repository, error) {
|
|||||||
return nil, ErrRepositoryNotExists
|
return nil, ErrRepositoryNotExists
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg, err := s.Config()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = verifyExtensions(s, cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
121
vendor/github.com/go-git/go-git/v5/repository_extensions.go
generated
vendored
Normal file
121
vendor/github.com/go-git/go-git/v5/repository_extensions.go
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
package git
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-git/go-git/v5/config"
|
||||||
|
cfgformat "github.com/go-git/go-git/v5/plumbing/format/config"
|
||||||
|
"github.com/go-git/go-git/v5/storage"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// ErrUnsupportedExtensionRepositoryFormatVersion represents when an
|
||||||
|
// extension being used is not compatible with the repository's
|
||||||
|
// core.repositoryFormatVersion.
|
||||||
|
ErrUnsupportedExtensionRepositoryFormatVersion = errors.New("core.repositoryformatversion does not support extension")
|
||||||
|
|
||||||
|
// ErrUnsupportedRepositoryFormatVersion represents when an repository
|
||||||
|
// is using a format version that is not supported.
|
||||||
|
ErrUnsupportedRepositoryFormatVersion = errors.New("core.repositoryformatversion not supported")
|
||||||
|
|
||||||
|
// ErrUnknownExtension represents when a repository has an extension
|
||||||
|
// which is unknown or unsupported by go-git.
|
||||||
|
ErrUnknownExtension = errors.New("unknown extension")
|
||||||
|
|
||||||
|
// builtinExtensions defines the Git extensions that are supported by
|
||||||
|
// the core go-git implementation.
|
||||||
|
//
|
||||||
|
// Some extensions are storage-specific, those are defined by the Storers
|
||||||
|
// themselves by implementing the ExtensionChecker interface.
|
||||||
|
builtinExtensions = map[string]struct{}{
|
||||||
|
// noop does not change git’s behavior at all.
|
||||||
|
// It is useful only for testing format-1 compatibility.
|
||||||
|
//
|
||||||
|
// This extension is respected regardless of the
|
||||||
|
// core.repositoryFormatVersion setting.
|
||||||
|
"noop": {},
|
||||||
|
|
||||||
|
// noop-v1 does not change git’s behavior at all.
|
||||||
|
// It is useful only for testing format-1 compatibility.
|
||||||
|
"noop-v1": {},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Some Git extensions were supported upstream before the introduction
|
||||||
|
// of repositoryformatversion. These are the only extensions that can be
|
||||||
|
// enabled while core.repositoryformatversion is unset or set to 0.
|
||||||
|
extensionsValidForV0 = map[string]struct{}{
|
||||||
|
"noop": {},
|
||||||
|
"partialClone": {},
|
||||||
|
"preciousObjects": {},
|
||||||
|
"worktreeConfig": {},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type extension struct {
|
||||||
|
name string
|
||||||
|
value string
|
||||||
|
}
|
||||||
|
|
||||||
|
func extensions(cfg *config.Config) []extension {
|
||||||
|
if cfg == nil || cfg.Raw == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !cfg.Raw.HasSection("extensions") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
section := cfg.Raw.Section("extensions")
|
||||||
|
out := make([]extension, 0, len(section.Options))
|
||||||
|
for _, opt := range section.Options {
|
||||||
|
out = append(out, extension{name: strings.ToLower(opt.Key), value: strings.ToLower(opt.Value)})
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func verifyExtensions(st storage.Storer, cfg *config.Config) error {
|
||||||
|
needed := extensions(cfg)
|
||||||
|
|
||||||
|
switch cfg.Core.RepositoryFormatVersion {
|
||||||
|
case "", cfgformat.Version_0, cfgformat.Version_1:
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("%w: %q",
|
||||||
|
ErrUnsupportedRepositoryFormatVersion,
|
||||||
|
cfg.Core.RepositoryFormatVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(needed) > 0 {
|
||||||
|
if cfg.Core.RepositoryFormatVersion == cfgformat.Version_0 ||
|
||||||
|
cfg.Core.RepositoryFormatVersion == "" {
|
||||||
|
var unsupported []string
|
||||||
|
for _, ext := range needed {
|
||||||
|
if _, ok := extensionsValidForV0[ext.name]; !ok {
|
||||||
|
unsupported = append(unsupported, ext.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(unsupported) > 0 {
|
||||||
|
return fmt.Errorf("%w: %s",
|
||||||
|
ErrUnsupportedExtensionRepositoryFormatVersion,
|
||||||
|
strings.Join(unsupported, ", "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var missing []string
|
||||||
|
for _, ext := range needed {
|
||||||
|
if _, ok := builtinExtensions[ext.name]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
missing = append(missing, ext.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(missing) > 0 {
|
||||||
|
return fmt.Errorf("%w: %s", ErrUnknownExtension, strings.Join(missing, ", "))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
25
vendor/github.com/go-git/go-git/v5/storage/filesystem/dotgit/writers.go
generated
vendored
25
vendor/github.com/go-git/go-git/v5/storage/filesystem/dotgit/writers.go
generated
vendored
@@ -3,6 +3,7 @@ package dotgit
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
@@ -137,14 +138,22 @@ func (w *PackWriter) save() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := w.encodeIdx(idx); err != nil {
|
if err := w.encodeIdx(idx); err != nil {
|
||||||
|
_ = idx.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := idx.Close(); err != nil {
|
if err := idx.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
fixPermissions(w.fs, fmt.Sprintf("%s.idx", base))
|
||||||
|
|
||||||
return w.fs.Rename(w.fw.Name(), fmt.Sprintf("%s.pack", base))
|
packPath := fmt.Sprintf("%s.pack", base)
|
||||||
|
if err := w.fs.Rename(w.fw.Name(), packPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fixPermissions(w.fs, packPath)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *PackWriter) encodeIdx(writer io.Writer) error {
|
func (w *PackWriter) encodeIdx(writer io.Writer) error {
|
||||||
@@ -281,5 +290,17 @@ func (w *ObjectWriter) save() error {
|
|||||||
hex := w.Hash().String()
|
hex := w.Hash().String()
|
||||||
file := w.fs.Join(objectsPath, hex[0:2], hex[2:hash.HexSize])
|
file := w.fs.Join(objectsPath, hex[0:2], hex[2:hash.HexSize])
|
||||||
|
|
||||||
return w.fs.Rename(w.f.Name(), file)
|
// Loose objects are content addressable, if they already exist
|
||||||
|
// we can safely delete the temporary file and short-circuit the
|
||||||
|
// operation.
|
||||||
|
if _, err := w.fs.Stat(file); err == nil || os.IsExist(err) {
|
||||||
|
return w.fs.Remove(w.f.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := w.fs.Rename(w.f.Name(), file); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fixPermissions(w.fs, file)
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
29
vendor/github.com/go-git/go-git/v5/storage/filesystem/dotgit/writers_unix.go
generated
vendored
Normal file
29
vendor/github.com/go-git/go-git/v5/storage/filesystem/dotgit/writers_unix.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package dotgit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/go-git/go-billy/v5"
|
||||||
|
"github.com/go-git/go-git/v5/utils/trace"
|
||||||
|
)
|
||||||
|
|
||||||
|
func fixPermissions(fs billy.Filesystem, path string) {
|
||||||
|
if chmodFS, ok := fs.(billy.Chmod); ok {
|
||||||
|
if err := chmodFS.Chmod(path, 0o444); err != nil {
|
||||||
|
trace.General.Printf("failed to chmod %s: %v", path, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isReadOnly(fs billy.Filesystem, path string) (bool, error) {
|
||||||
|
fi, err := fs.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if fi.Mode().Perm() == 0o444 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
58
vendor/github.com/go-git/go-git/v5/storage/filesystem/dotgit/writers_windows.go
generated
vendored
Normal file
58
vendor/github.com/go-git/go-git/v5/storage/filesystem/dotgit/writers_windows.go
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package dotgit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/go-git/go-billy/v5"
|
||||||
|
"github.com/go-git/go-git/v5/utils/trace"
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
func fixPermissions(fs billy.Filesystem, path string) {
|
||||||
|
fullpath := filepath.Join(fs.Root(), path)
|
||||||
|
p, err := windows.UTF16PtrFromString(fullpath)
|
||||||
|
if err != nil {
|
||||||
|
trace.General.Printf("failed to chmod %s: %v", fullpath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs, err := windows.GetFileAttributes(p)
|
||||||
|
if err != nil {
|
||||||
|
trace.General.Printf("failed to chmod %s: %v", fullpath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if attrs&windows.FILE_ATTRIBUTE_READONLY != 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = windows.SetFileAttributes(p,
|
||||||
|
attrs|windows.FILE_ATTRIBUTE_READONLY,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
trace.General.Printf("failed to chmod %s: %v", fullpath, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func isReadOnly(fs billy.Filesystem, path string) (bool, error) {
|
||||||
|
fullpath := filepath.Join(fs.Root(), path)
|
||||||
|
p, err := windows.UTF16PtrFromString(fullpath)
|
||||||
|
if err != nil {
|
||||||
|
return false, fmt.Errorf("%w: %q", err, fullpath)
|
||||||
|
}
|
||||||
|
|
||||||
|
attrs, err := windows.GetFileAttributes(p)
|
||||||
|
if err != nil {
|
||||||
|
return false, fmt.Errorf("%w: %q", err, fullpath)
|
||||||
|
}
|
||||||
|
|
||||||
|
if attrs&windows.FILE_ATTRIBUTE_READONLY != 0 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
5
vendor/github.com/go-git/go-git/v5/storage/filesystem/index.go
generated
vendored
5
vendor/github.com/go-git/go-git/v5/storage/filesystem/index.go
generated
vendored
@@ -48,6 +48,11 @@ func (s *IndexStorage) Index() (i *index.Index, err error) {
|
|||||||
|
|
||||||
defer ioutil.CheckClose(f, &err)
|
defer ioutil.CheckClose(f, &err)
|
||||||
|
|
||||||
|
fi, statErr := s.dir.Fs().Stat(f.Name())
|
||||||
|
if statErr == nil {
|
||||||
|
idx.ModTime = fi.ModTime()
|
||||||
|
}
|
||||||
|
|
||||||
d := index.NewDecoder(f)
|
d := index.NewDecoder(f)
|
||||||
err = d.Decode(idx)
|
err = d.Decode(idx)
|
||||||
return idx, err
|
return idx, err
|
||||||
|
|||||||
4
vendor/github.com/go-git/go-git/v5/storage/memory/storage.go
generated
vendored
4
vendor/github.com/go-git/go-git/v5/storage/memory/storage.go
generated
vendored
@@ -69,7 +69,11 @@ type IndexStorage struct {
|
|||||||
index *index.Index
|
index *index.Index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetIndex stores the given index.
|
||||||
|
// Note: this method sets idx.ModTime to simulate filesystem storage behavior.
|
||||||
func (c *IndexStorage) SetIndex(idx *index.Index) error {
|
func (c *IndexStorage) SetIndex(idx *index.Index) error {
|
||||||
|
// Set ModTime to enable racy git detection in the metadata optimization.
|
||||||
|
idx.ModTime = time.Now()
|
||||||
c.index = idx
|
c.index = idx
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
108
vendor/github.com/go-git/go-git/v5/utils/merkletrie/filesystem/node.go
generated
vendored
108
vendor/github.com/go-git/go-git/v5/utils/merkletrie/filesystem/node.go
generated
vendored
@@ -4,9 +4,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5/plumbing"
|
"github.com/go-git/go-git/v5/plumbing"
|
||||||
"github.com/go-git/go-git/v5/plumbing/filemode"
|
"github.com/go-git/go-git/v5/plumbing/filemode"
|
||||||
|
"github.com/go-git/go-git/v5/plumbing/format/index"
|
||||||
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
|
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
|
||||||
|
|
||||||
"github.com/go-git/go-billy/v5"
|
"github.com/go-git/go-billy/v5"
|
||||||
@@ -16,6 +18,14 @@ var ignore = map[string]bool{
|
|||||||
".git": true,
|
".git": true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Options contains configuration for the filesystem node.
|
||||||
|
type Options struct {
|
||||||
|
// Index is used to enable the metadata-first comparison optimization while
|
||||||
|
// correctly handling the "racy git" condition. If no index is provided,
|
||||||
|
// the function works without the optimization.
|
||||||
|
Index *index.Index
|
||||||
|
}
|
||||||
|
|
||||||
// The node represents a file or a directory in a billy.Filesystem. It
|
// The node represents a file or a directory in a billy.Filesystem. It
|
||||||
// implements the interface noder.Noder of merkletrie package.
|
// implements the interface noder.Noder of merkletrie package.
|
||||||
//
|
//
|
||||||
@@ -24,6 +34,8 @@ var ignore = map[string]bool{
|
|||||||
type node struct {
|
type node struct {
|
||||||
fs billy.Filesystem
|
fs billy.Filesystem
|
||||||
submodules map[string]plumbing.Hash
|
submodules map[string]plumbing.Hash
|
||||||
|
idx *index.Index
|
||||||
|
idxMap map[string]*index.Entry
|
||||||
|
|
||||||
path string
|
path string
|
||||||
hash []byte
|
hash []byte
|
||||||
@@ -31,6 +43,7 @@ type node struct {
|
|||||||
isDir bool
|
isDir bool
|
||||||
mode os.FileMode
|
mode os.FileMode
|
||||||
size int64
|
size int64
|
||||||
|
modTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRootNode returns the root node based on a given billy.Filesystem.
|
// NewRootNode returns the root node based on a given billy.Filesystem.
|
||||||
@@ -42,7 +55,41 @@ func NewRootNode(
|
|||||||
fs billy.Filesystem,
|
fs billy.Filesystem,
|
||||||
submodules map[string]plumbing.Hash,
|
submodules map[string]plumbing.Hash,
|
||||||
) noder.Noder {
|
) noder.Noder {
|
||||||
return &node{fs: fs, submodules: submodules, isDir: true}
|
return NewRootNodeWithOptions(fs, submodules, Options{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRootNodeWithOptions returns the root node based on a given billy.Filesystem
|
||||||
|
// with options to set an index. Providing an index enables the metadata-first
|
||||||
|
// comparison optimization while correctly handling the "racy git" condition. If
|
||||||
|
// no index is provided, the function works without the optimization.
|
||||||
|
//
|
||||||
|
// The index's ModTime field is used to detect the racy git condition. When a file's
|
||||||
|
// mtime equals or is newer than the index ModTime, we must hash the file content
|
||||||
|
// even if other metadata matches, because the file may have been modified in the
|
||||||
|
// same second that the index was written.
|
||||||
|
//
|
||||||
|
// Reference: https://git-scm.com/docs/racy-git
|
||||||
|
func NewRootNodeWithOptions(
|
||||||
|
fs billy.Filesystem,
|
||||||
|
submodules map[string]plumbing.Hash,
|
||||||
|
options Options,
|
||||||
|
) noder.Noder {
|
||||||
|
var idxMap map[string]*index.Entry
|
||||||
|
|
||||||
|
if options.Index != nil {
|
||||||
|
idxMap = make(map[string]*index.Entry, len(options.Index.Entries))
|
||||||
|
for _, entry := range options.Index.Entries {
|
||||||
|
idxMap[entry.Name] = entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &node{
|
||||||
|
fs: fs,
|
||||||
|
submodules: submodules,
|
||||||
|
idx: options.Index,
|
||||||
|
idxMap: idxMap,
|
||||||
|
isDir: true,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash the hash of a filesystem is the result of concatenating the computed
|
// Hash the hash of a filesystem is the result of concatenating the computed
|
||||||
@@ -133,11 +180,14 @@ func (n *node) newChildNode(file os.FileInfo) (*node, error) {
|
|||||||
node := &node{
|
node := &node{
|
||||||
fs: n.fs,
|
fs: n.fs,
|
||||||
submodules: n.submodules,
|
submodules: n.submodules,
|
||||||
|
idx: n.idx,
|
||||||
|
idxMap: n.idxMap,
|
||||||
|
|
||||||
path: path,
|
path: path,
|
||||||
isDir: file.IsDir(),
|
isDir: file.IsDir(),
|
||||||
size: file.Size(),
|
size: file.Size(),
|
||||||
mode: file.Mode(),
|
mode: file.Mode(),
|
||||||
|
modTime: file.ModTime(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, isSubmodule := n.submodules[path]; isSubmodule {
|
if _, isSubmodule := n.submodules[path]; isSubmodule {
|
||||||
@@ -161,6 +211,16 @@ func (n *node) calculateHash() {
|
|||||||
n.hash = append(submoduleHash[:], filemode.Submodule.Bytes()...)
|
n.hash = append(submoduleHash[:], filemode.Submodule.Bytes()...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if n.idxMap != nil {
|
||||||
|
if entry, ok := n.idxMap[n.path]; ok {
|
||||||
|
if n.metadataMatches(entry) {
|
||||||
|
n.hash = append(entry.Hash[:], mode.Bytes()...)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var hash plumbing.Hash
|
var hash plumbing.Hash
|
||||||
if n.mode&os.ModeSymlink != 0 {
|
if n.mode&os.ModeSymlink != 0 {
|
||||||
hash = n.doCalculateHashForSymlink()
|
hash = n.doCalculateHashForSymlink()
|
||||||
@@ -170,6 +230,44 @@ func (n *node) calculateHash() {
|
|||||||
n.hash = append(hash[:], mode.Bytes()...)
|
n.hash = append(hash[:], mode.Bytes()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *node) metadataMatches(entry *index.Entry) bool {
|
||||||
|
if entry == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if uint32(n.size) != entry.Size {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if !n.modTime.IsZero() && !n.modTime.Equal(entry.ModifiedAt) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
mode, err := filemode.NewFromOSFileMode(n.mode)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if mode != entry.Mode {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.idx != nil && !n.idx.ModTime.IsZero() && !n.modTime.IsZero() {
|
||||||
|
if !n.modTime.Before(n.idx.ModTime) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we couldn't perform the racy git check (idx is nil or idx.ModTime is zero),
|
||||||
|
// we cannot safely rely on metadata alone — force content hashing.
|
||||||
|
// This can occur with in-memory storage where the index file timestamp is unavailable.
|
||||||
|
if n.idx == nil || n.idx.ModTime.IsZero() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (n *node) doCalculateHashForRegular() plumbing.Hash {
|
func (n *node) doCalculateHashForRegular() plumbing.Hash {
|
||||||
f, err := n.fs.Open(n.path)
|
f, err := n.fs.Open(n.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
33
vendor/github.com/go-git/go-git/v5/worktree.go
generated
vendored
33
vendor/github.com/go-git/go-git/v5/worktree.go
generated
vendored
@@ -385,7 +385,8 @@ func (w *Worktree) resetIndex(t *object.Tree, dirs []string, files []string) ([]
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var removedFiles []string
|
removedFiles := make([]string, 0, len(changes))
|
||||||
|
filesMap := buildFilePathMap(files)
|
||||||
for _, ch := range changes {
|
for _, ch := range changes {
|
||||||
a, err := ch.Action()
|
a, err := ch.Action()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -407,7 +408,7 @@ func (w *Worktree) resetIndex(t *object.Tree, dirs []string, files []string) ([]
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(files) > 0 {
|
if len(files) > 0 {
|
||||||
contains := inFiles(files, name)
|
contains := inFiles(filesMap, name)
|
||||||
if !contains {
|
if !contains {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -436,15 +437,11 @@ func (w *Worktree) resetIndex(t *object.Tree, dirs []string, files []string) ([]
|
|||||||
return removedFiles, w.r.Storer.SetIndex(idx)
|
return removedFiles, w.r.Storer.SetIndex(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func inFiles(files []string, v string) bool {
|
// inFiles checks if the given file is in the list of files. The incoming filepaths in files should be cleaned before calling this function.
|
||||||
|
func inFiles(files map[string]struct{}, v string) bool {
|
||||||
v = filepath.Clean(v)
|
v = filepath.Clean(v)
|
||||||
for _, s := range files {
|
_, exists := files[v]
|
||||||
if filepath.Clean(s) == v {
|
return exists
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Worktree) resetWorktree(t *object.Tree, files []string) error {
|
func (w *Worktree) resetWorktree(t *object.Tree, files []string) error {
|
||||||
@@ -459,6 +456,7 @@ func (w *Worktree) resetWorktree(t *object.Tree, files []string) error {
|
|||||||
}
|
}
|
||||||
b := newIndexBuilder(idx)
|
b := newIndexBuilder(idx)
|
||||||
|
|
||||||
|
filesMap := buildFilePathMap(files)
|
||||||
for _, ch := range changes {
|
for _, ch := range changes {
|
||||||
if err := w.validChange(ch); err != nil {
|
if err := w.validChange(ch); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -476,7 +474,7 @@ func (w *Worktree) resetWorktree(t *object.Tree, files []string) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
contains := inFiles(files, file)
|
contains := inFiles(filesMap, file)
|
||||||
if !contains {
|
if !contains {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -1206,3 +1204,16 @@ func (b *indexBuilder) Add(e *index.Entry) {
|
|||||||
func (b *indexBuilder) Remove(name string) {
|
func (b *indexBuilder) Remove(name string) {
|
||||||
delete(b.entries, filepath.ToSlash(name))
|
delete(b.entries, filepath.ToSlash(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// buildFilePathMap creates a map of cleaned file paths for efficient lookup.
|
||||||
|
// Returns nil if the input slice is empty.
|
||||||
|
func buildFilePathMap(files []string) map[string]struct{} {
|
||||||
|
if len(files) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
filesMap := make(map[string]struct{}, len(files))
|
||||||
|
for _, f := range files {
|
||||||
|
filesMap[filepath.Clean(f)] = struct{}{}
|
||||||
|
}
|
||||||
|
return filesMap
|
||||||
|
}
|
||||||
|
|||||||
2
vendor/github.com/go-git/go-git/v5/worktree_status.go
generated
vendored
2
vendor/github.com/go-git/go-git/v5/worktree_status.go
generated
vendored
@@ -141,7 +141,7 @@ func (w *Worktree) diffStagingWithWorktree(reverse, excludeIgnoredChanges bool)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
to := filesystem.NewRootNode(w.Filesystem, submodules)
|
to := filesystem.NewRootNodeWithOptions(w.Filesystem, submodules, filesystem.Options{Index: idx})
|
||||||
|
|
||||||
var c merkletrie.Changes
|
var c merkletrie.Changes
|
||||||
if reverse {
|
if reverse {
|
||||||
|
|||||||
6
vendor/modules.txt
vendored
6
vendor/modules.txt
vendored
@@ -80,15 +80,15 @@ github.com/go-git/gcfg
|
|||||||
github.com/go-git/gcfg/scanner
|
github.com/go-git/gcfg/scanner
|
||||||
github.com/go-git/gcfg/token
|
github.com/go-git/gcfg/token
|
||||||
github.com/go-git/gcfg/types
|
github.com/go-git/gcfg/types
|
||||||
# github.com/go-git/go-billy/v5 v5.7.0
|
# github.com/go-git/go-billy/v5 v5.8.0
|
||||||
## explicit; go 1.23.0
|
## explicit; go 1.24.0
|
||||||
github.com/go-git/go-billy/v5
|
github.com/go-git/go-billy/v5
|
||||||
github.com/go-git/go-billy/v5/helper/chroot
|
github.com/go-git/go-billy/v5/helper/chroot
|
||||||
github.com/go-git/go-billy/v5/helper/polyfill
|
github.com/go-git/go-billy/v5/helper/polyfill
|
||||||
github.com/go-git/go-billy/v5/memfs
|
github.com/go-git/go-billy/v5/memfs
|
||||||
github.com/go-git/go-billy/v5/osfs
|
github.com/go-git/go-billy/v5/osfs
|
||||||
github.com/go-git/go-billy/v5/util
|
github.com/go-git/go-billy/v5/util
|
||||||
# github.com/go-git/go-git/v5 v5.16.5
|
# github.com/go-git/go-git/v5 v5.17.0
|
||||||
## explicit; go 1.24.0
|
## explicit; go 1.24.0
|
||||||
github.com/go-git/go-git/v5
|
github.com/go-git/go-git/v5
|
||||||
github.com/go-git/go-git/v5/config
|
github.com/go-git/go-git/v5/config
|
||||||
|
|||||||
Reference in New Issue
Block a user