gitfs

package
v0.0.0-...-089b6a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: MIT, BSD-3-Clause Imports: 17 Imported by: 0

README

Local gitfs fork

This directory is a local fork of rsc.io/gitfs v1.0.0, whose upstream revision is 284116d826c0bc751ebac57c87fd01eb2ea95240. It presents a file tree downloaded from a remote Git repository as an in-memory fs.FS.

Within this repository it is part of the root module and is imported as blake.io/git-lfs/gitfs.

This is not a release of upstream rsc.io/gitfs. Its API differs from upstream, including the changed Clone and CloneHash signatures. Consumers outside this repository should import blake.io/git-lfs/gitfs only when they intentionally depend on this fork.

Local extensions

  • NewRepoWithClient accepts a caller-provided HTTP client.
  • Clone, CloneHash, and the new CloneTree accept CloneParams, which can send Git object-filter specifications and require server support for them. CloneParams.MaxPackSize is required and positive; it limits received pack bytes and decoded object data. They return *Tree, a concrete fs.FS.
  • Tree.WritePack and Tree.PackID expose the fetched pack, and Tree.ReadEntry exposes a tree entry's Git mode and object hash.
  • Parsed tree entries are memoized for later lookups and directory reads.
  • Malformed fetch sidebands return errors; server-progress sidebands are not written to standard output.

See NOTICE for provenance and LICENSE for the license that applies to this directory. The upstream API reference is available at pkg.go.dev/rsc.io/gitfs.

Documentation

Overview

Package gitfs presents a file tree downloaded from a remote Git repo as an in-memory fs.FS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloneParams

type CloneParams struct {
	// MaxPackSize is the positive maximum size of the received pack. It also
	// bounds the decoded objects and deltas retained while unpacking. It has no
	// default.
	MaxPackSize int64

	Filters []string // Git object filter specifications.
}

CloneParams controls a clone. MaxPackSize must be positive.

type Entry

type Entry struct {
	Mode int
	Hash Hash
}

An Entry identifies a Git tree entry.

type Hash

type Hash [20]byte

A Hash is a SHA-1 Hash identifying a particular Git object.

func (Hash) String

func (h Hash) String() string

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

A Repo is a connection to a remote repository served over HTTP or HTTPS.

func NewRepo

func NewRepo(url string) (*Repo, error)

NewRepo connects to a Git repository at the given http:// or https:// URL.

func NewRepoWithClient

func NewRepoWithClient(url string, client *http.Client) (*Repo, error)

NewRepoWithClient connects to a Git repository using client. A nil client uses http.DefaultClient.

func (*Repo) Clone

func (r *Repo) Clone(ref string, params *CloneParams) (Hash, *Tree, error)

Clone resolves the given ref to a hash and returns the corresponding Tree.

func (*Repo) CloneHash

func (r *Repo) CloneHash(h Hash, params *CloneParams) (*Tree, error)

CloneHash returns the Tree for the given hash.

func (*Repo) CloneTree

func (r *Repo) CloneTree(ref string, params *CloneParams) (Hash, *Tree, error)

CloneTree resolves the given ref and returns a Tree rooted at that tree.

func (*Repo) Resolve

func (r *Repo) Resolve(ref string) (Hash, error)

Resolve looks up the given ref and returns the corresponding Hash.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

A Tree is an fs.FS serving a Git file system tree rooted at a given tree object hash.

func (*Tree) Open

func (t *Tree) Open(name string) (f fs.File, err error)

Open opens the given file or directory, implementing the fs.FS Open method.

func (*Tree) PackID

func (t *Tree) PackID() (string, error)

PackID reports the checksum that names the Git pack supplying t.

func (*Tree) ReadEntry

func (t *Tree) ReadEntry(name string) (entry Entry, err error)

ReadEntry reports the Git tree entry for name.

func (*Tree) WritePack

func (t *Tree) WritePack(output io.Writer) error

WritePack writes the Git pack that supplied t to output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL