gittuf/pkg/gitinterface
Andrew Nesbitt 12ab1b37ac
pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead
LoadRepository did os.Chdir(repositoryPath) to run 'git rev-parse
--git-dir', and Status/RestoreWorktree/tree-restore did the same to run
worktree-relative commands. os.Chdir is process-global; concurrent
LoadRepository calls for different paths could each resolve the wrong
gitDirPath.

Adds executor.withDir(dir) which sets cmd.Dir. LoadRepository now runs
'git rev-parse --absolute-git-dir' with cmd.Dir set to the repository
path (and EvalSymlinks the result to match prior behaviour). The
worktree commands use withDir(worktree).

TestLoadRepositoryConcurrent runs 20 pairs of LoadRepository for two
distinct repos in parallel under -race and asserts each gets its own
gitDirPath.

Signed-off-by: Andrew Nesbitt <andrewnez@gmail.com>
2026-06-29 17:13:31 +01:00
..
blob.go
blob_test.go test: improve pkg/gitinterface coverage from 69.4% to 76.2% 2026-04-25 02:44:19 +05:30
changes.go
changes_test.go pkg/gitinterface: Add and refactor tests for coverage 2026-04-30 02:47:33 +05:30
commit.go Bump go-git to v6 2026-06-17 20:39:04 -04:00
commit_test.go Bump go-git to v6 2026-06-17 20:39:04 -04:00
common.go
config.go
config_test.go test: improve pkg/gitinterface coverage from 69.4% to 76.2% 2026-04-25 02:44:19 +05:30
hash.go
hash_test.go
log.go
log_test.go pkg/gitinterface: Remove unnecessary error return from createTestTrees 2026-05-01 23:50:02 +05:30
object.go
object_test.go test: improve pkg/gitinterface coverage from 69.4% to 76.2% 2026-04-25 02:44:19 +05:30
README.md
references.go
references_test.go pkg/gitinterface: Add and refactor tests for coverage 2026-04-30 02:47:33 +05:30
remote.go
remote_test.go
repository.go pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead 2026-06-29 17:13:31 +01:00
repository_test.go pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead 2026-06-29 17:13:31 +01:00
signature.go sigstore: Drop support for online verification 2026-02-19 12:39:22 -05:00
signature_test.go pkg/gitinterface: Add and refactor tests for coverage 2026-04-30 02:47:33 +05:30
status.go pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead 2026-06-29 17:13:31 +01:00
status_test.go Merge pull request #1273 from ayuxsh009/fix/status-rename-parser 2026-04-29 20:24:55 +00:00
sync.go
sync_test.go pkg: Increase testing coverage 2026-06-11 12:16:43 -04:00
tag.go Bump go-git to v6 2026-06-17 20:39:04 -04:00
tag_test.go pkg/gitinterface: Add and refactor tests for coverage 2026-04-30 02:47:33 +05:30
tree.go pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead 2026-06-29 17:13:31 +01:00
tree_test.go pkg/gitinterface: Add and refactor tests for coverage 2026-04-30 02:47:33 +05:30
utils.go pkg/gitinterface: remove os.Chdir; set cmd.Dir on the executor instead 2026-06-29 17:13:31 +01:00
utils_test.go test: improve pkg/gitinterface coverage from 69.4% to 76.2% 2026-04-25 02:44:19 +05:30

gittuf's gitinterface Package

gittuf's gitinterface package is a lightweight Go API for interacting with Git repositories. It is similar to go-git in its goal, but differs as, unlike go-git, gitinterface uses the Git binary for its operations.

To operate correctly, gitinterface requires a Git binary version of 2.34 or higher.