diff --git a/test/test-clone.sh b/test/test-clone.sh index ecaec141..0aa6059f 100755 --- a/test/test-clone.sh +++ b/test/test-clone.sh @@ -443,3 +443,40 @@ begin_test "clone with submodules" ) end_test + +begin_test "clone in current directory" +( + set -e + + reponame="clone_in_current_dir" + setup_remote_repo "$reponame" + clone_repo "$reponame" $reponame + + git lfs track "*.dat" 2>&1 | tee track.log + grep "Tracking \*.dat" track.log + + contents="contents" + contents_oid="$(calc_oid "$contents")" + + printf "$contents" > a.dat + + git add .gitattributes a.dat + + git commit -m "initial commit" 2>&1 | tee commit.log + grep "master (root-commit)" commit.log + grep "2 files changed" commit.log + grep "create mode 100644 a.dat" commit.log + grep "create mode 100644 .gitattributes" commit.log + + git push origin master 2>&1 | tee push.log + + pushd $TRASHDIR + mkdir "$reponame-clone" + cd "$reponame-clone" + + git lfs clone $GITSERVER/$reponame "." 2>&1 | grep "Git LFS" + + assert_local_object "$contents_oid" 8 + popd +) +end_test diff --git a/test/testutils.go b/test/testutils.go index bbc0a1c2..94c60bf9 100644 --- a/test/testutils.go +++ b/test/testutils.go @@ -17,6 +17,7 @@ import ( "os/exec" "path/filepath" "strings" + "sync" "time" "github.com/github/git-lfs/git" @@ -243,6 +244,8 @@ func commitAtDate(atDate time.Time, committerName, committerEmail, msg string) e } func (repo *Repo) AddCommits(inputs []*CommitInput) []*CommitOutput { + var storageOnce sync.Once + if repo.Settings.RepoType == RepoTypeBare { repo.callback.Fatalf("Cannot use AddCommits on a bare repo; clone it & push changes instead") } @@ -298,6 +301,7 @@ func (repo *Repo) AddCommits(inputs []*CommitInput) []*CommitOutput { } // this only created the temp file, move to final location tmpfile := cleaned.Filename + storageOnce.Do(localstorage.ResolveDirs) mediafile, err := lfs.LocalMediaPath(cleaned.Oid) if err != nil { repo.callback.Errorf("Unable to get local media path: %v", err)