From de8ece9cd4486b9be0c0a15c806e1e737e44792f Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Mon, 21 Aug 2017 12:16:10 +0200 Subject: [PATCH] move `git ls-tree` invocation to git package using gitNoLFSBuffered The only side effect of this refactoring should be that the Git LFS is disabled for the Git subprocess. No other functional changes are intended. --- git/git.go | 11 +++++++++++ lfs/gitscanner_tree.go | 10 ++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/git/git.go b/git/git.go index a9dbe4a3..8437eb56 100644 --- a/git/git.go +++ b/git/git.go @@ -182,6 +182,17 @@ func LsRemote(remote, remoteRef string) (string, error) { return gitNoLFSSimple("ls-remote", remote, remoteRef) } +func LsTree(ref string) (*subprocess.BufferedCmd, error) { + return gitNoLFSBuffered( + "ls-tree", + "-r", // recurse + "-l", // report object size (we'll need this) + "-z", // null line termination + "--full-tree", // start at the root regardless of where we are in it + ref, + ) +} + func ResolveRef(ref string) (*Ref, error) { outp, err := gitNoLFSSimple("rev-parse", ref, "--symbolic-full-name", ref) if err != nil { diff --git a/lfs/gitscanner_tree.go b/lfs/gitscanner_tree.go index 83056871..63a4cb46 100644 --- a/lfs/gitscanner_tree.go +++ b/lfs/gitscanner_tree.go @@ -10,6 +10,7 @@ import ( "strings" "github.com/git-lfs/git-lfs/filepathfilter" + "github.com/git-lfs/git-lfs/git" ) // An entry from ls-tree or rev-list including a blob sha and tree path @@ -94,14 +95,7 @@ func catFileBatchTree(treeblobs *TreeBlobChannelWrapper) (*PointerChannelWrapper // The returned channel will be sent these blobs which should be sent to catFileBatchTree // for final check & conversion to Pointer func lsTreeBlobs(ref string, filter *filepathfilter.Filter) (*TreeBlobChannelWrapper, error) { - cmd, err := startCommand("git", "ls-tree", - "-r", // recurse - "-l", // report object size (we'll need this) - "-z", // null line termination - "--full-tree", // start at the root regardless of where we are in it - ref, - ) - + cmd, err := git.LsTree(ref) if err != nil { return nil, err }