IsTagExist uses got ref existence in both builds. GetTagID resolves the
tag ref via got, GetTagNameBySHA lists refs/tags/ via got ref -l. GetTagInfos
and annotated-tag body parsing still use git for-each-ref/cat-file.
Verified: GOTMPDIR=/home/lotherk/.cache/gotmp go test ./modules/got ./modules/git -count=1
Resolve ref names through got ref -l instead of CatFileBatch/gogit ref
lookups. Plain object hashes are returned directly, as before. Missing
refs still map to ErrNotExist.
Verified: GOTMPDIR=/home/lotherk/.cache/gotmp go test ./modules/got ./modules/git -count=1
Use got log -c <rev> -l1 to resolve short/full commit IDs and refs to a
full commit ID. This keeps the call on got for the commit-resolution path
used by pull/merge/compare flows; unknown revisions still map to
ErrNotExist.
Verified: GOTMPDIR=/home/lotherk/.cache/gotmp go test ./modules/got ./modules/git -count=1
Route package-level and Repository.IsReferenceExist through
modules/got.ObjectExists, which probes `got cat -r` without -P. got cat
resolves full/abbreviated object IDs, refs and tags but not path names,
matching the commit_checker/merge_tree callers that pass commit IDs and
the ref callers that pass ref names.
This also removes the gogit/nogogit inconsistency where gogit rejected
blob hashes and short hashes for IsReferenceExist; the got-backed path
accepts them in both builds. IsObjectExist is left alone: its nogogit
CatFileBatch implementation has different semantics and its only caller
is marked FIXME.
Verified: GOTMPDIR=/home/lotherk/.cache/gotmp go test ./modules/got ./modules/git -count=1
IsBranchExist and IsTagExist now ask got.RefExists instead of git's cat-file
batch. got's exit status is useless here: `got ref -l <unknown>` exits 0 with
no output, and an empty repository reports "HEAD: refs/heads/main" for a branch
that does not exist yet. The wrapper therefore parses the "<name>: <value>"
line and follows symbolic entries with a bounded depth.
IsReferenceExist/IsObjectExist keep the cat-file batch: they answer "is this
object present" for bare and short commit IDs, which got ref cannot, and
`got cat` resolves unknown arguments as paths in HEAD's tree, so it would
report file names as existing objects. That gap is documented, not silent.
Verified: go test ./modules/got ./modules/git (ref_test.go covers both ref
behaviours, the empty repository, and the enclosing-repository escape;
ref_got_test.go covers true/false branches and tags plus a missing got binary).
Full go test ./modules/... ./services/... ./models/... ./routers/... and
make -C cgi check pass.
Assisted-by: splinter:claude-opus-4
Add got.Branches and route both GetBranchNames implementations through it,
so branch listing no longer runs git for-each-ref.
Names come from `got ref -l refs/heads/`, not `got branch -l`: the latter
also reports refs/remotes copies and can print a name twice. Order comes
from `got branch -lt`; names that pass misses are appended, so a failure
there degrades to lexical order instead of failing the listing.
Two got behaviours needed guarding:
- `-r` searches upwards. A path that is not a repository made got answer
for the enclosing one, so a broken fixture silently returned the parent
repository's refs. run now validates the target first.
- got refuses a repository without objects/pack or refs/. Those are empty
directories, so a fixture checked into git loses them. run recreates the
layout, content-free and idempotent.
repo2_empty carried .gitkeep files under refs/heads and refs/tags; got reads
them as references and fails with "bad reference name". Dropped both, the
layout is now created on demand.
Tests: go test ./modules/got ./modules/git ./modules/git -tags gogit
./services/repository/... ./modules/repository/... ./models/git/...
./routers/web/repo/... ./services/context/... - all pass. New tests cover
ordering, paging, remote-copy filtering, the missing-directory repair, the
enclosing-repository refusal, and absence of a git fallback.
Assisted-by: OpenCode:DeepSeek-V4.1-Flash
Add BranchCommitID to modules/got and route GetBranchCommitID through it. Cover existing and missing branches and the no-fallback case.
Assisted-by: OpenCode:DeepSeek-V4.1-Flash
Use got ref -s when the target branch exists and write HEAD atomically for unborn branches, where got ref -s cannot operate. Route git.SetDefaultBranch through the got wrapper and cover both paths plus the no-bypass case in tests.
Assisted-by: OpenCode:DeepSeek-V4.1-Flash
Add IsEmpty and DefaultBranch to modules/got and route Repository.IsEmpty and GetDefaultBranch through them. Keep SetDefaultBranch on git because got ref -s requires the target branch to exist, which excludes unborn branches. Cover the wiring and the no-fallback behaviour with tests.
Assisted-by: OpenCode:DeepSeek-V4.1-Flash
Add modules/got with a got runner, version check, repository detection, and idempotent bare init. Route bare repository creation from InitRepositoryLocal through got; non-bare temp worktrees keep git. Add [git] GOT_PATH and tests, including an explicit no-fallback test.
Assisted-by: OpenCode:DeepSeek-V4.1-Flash