From d62fb1442bc300dcee2a7c6a9c374201ba1c7ae6 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Sun, 11 Dec 2022 12:29:33 +0530 Subject: git: fetch files only using ref --- git/git.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'git/git.go') diff --git a/git/git.go b/git/git.go index 46ec357..13e703c 100644 --- a/git/git.go +++ b/git/git.go @@ -31,17 +31,8 @@ type NiceTree struct { IsFile bool } -func FilesAtHead(r *git.Repository, path string) ([]NiceTree, error) { - head, err := r.Head() - if err != nil { - return nil, fmt.Errorf("getting head: %w", err) - } - - return FilesAtRef(r, head, path) -} - -func FilesAtRef(r *git.Repository, ref *plumbing.Reference, path string) ([]NiceTree, error) { - c, err := r.CommitObject(ref.Hash()) +func FilesAtRef(r *git.Repository, hash plumbing.Hash, path string) ([]NiceTree, error) { + c, err := r.CommitObject(hash) if err != nil { return nil, fmt.Errorf("commit object: %w", err) } -- cgit