Fix lint issues and sparse checkout for empty repos
- Handle empty repos in ConfigureSparseCheckout (skip read-tree when no HEAD) - Fix errcheck: wrap fileLock.Unlock() error in defer - Fix unparam: remove unused *rig.Rig return from getWitnessManager - Fix unparam: mark unused agentType parameter with blank identifier 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -644,6 +644,14 @@ func ConfigureSparseCheckout(repoPath string) error {
|
||||
return fmt.Errorf("writing sparse-checkout: %w", err)
|
||||
}
|
||||
|
||||
// Check if HEAD exists (repo has commits) before running read-tree
|
||||
// Empty repos (no commits) don't need read-tree and it would fail
|
||||
checkHead := exec.Command("git", "-C", repoPath, "rev-parse", "--verify", "HEAD")
|
||||
if err := checkHead.Run(); err != nil {
|
||||
// No commits yet, sparse checkout config is set up for future use
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reapply to remove excluded files
|
||||
cmd = exec.Command("git", "-C", repoPath, "read-tree", "-mu", "HEAD")
|
||||
stderr.Reset()
|
||||
|
||||
Reference in New Issue
Block a user