gitfs

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gitfs provides pure-Go helpers for inspecting on-disk git repositories. It does NOT shell out to the git binary and does NOT depend on any third-party git library. It only handles the narrow problems arc needs: locating .git entries and following linked worktree pointers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectMainRepo

func DetectMainRepo(dir string) string

DetectMainRepo returns the canonical path of the main repository if dir is inside a linked git worktree. Returns "" if dir is in the main worktree, has no reachable .git entry, or the .git pointer is malformed.

Two layouts are supported:

  1. Worktree of a normal repo: .git is a file like "gitdir: /abs/path/main/.git/worktrees/<name>". This function returns the main repo's working directory (parent of the .git directory).

  2. Worktree of a bare repo: .git is a file like "gitdir: /abs/path/repo.git/worktrees/<name>". A bare repo has no working directory; this function returns the bare repo path itself (validated by checking for HEAD and objects/).

func FindGitEntry

func FindGitEntry(dir string) string

FindGitEntry walks up from dir to locate a .git entry (file or directory). Returns the absolute path to the .git entry, or "" if none is found before reaching the filesystem root.

Types

This section is empty.

Jump to

Keyboard shortcuts

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