From e09b7b07fee4d85856919a581ed928f4a2ee9aa8 Mon Sep 17 00:00:00 2001 From: Brian Camacho Date: Tue, 22 Aug 2023 01:47:53 -0700 Subject: [PATCH] add test for normal clone --- t/t-no-remote.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/t/t-no-remote.sh b/t/t-no-remote.sh index b1ad9d5d..12b5a321 100755 --- a/t/t-no-remote.sh +++ b/t/t-no-remote.sh @@ -27,5 +27,40 @@ begin_test "fetch lfs-tracked file despite no remote" # Verify archive contains our file grep "test_file.dat" archive.out + +) +end_test + +reponame_src_A="$(basename "$0" ".sh")-src-A" +reponame_src_B="$(basename "$0" ".sh")-src-B" +reponame_dst_2="$(basename "$0" ".sh")-dst-2" +begin_test "fallback ignored when remote present" +( + set -e + + # Initialize 2 repos with different files + setup_remote_repo_with_file "$reponame_src_A" "test_file_A.dat" + rev=$(git rev-parse HEAD) + cd .. + setup_remote_repo_with_file "$reponame_src_B" "test_file_B.dat" + cd .. + + mkdir $reponame_dst_2 + cd $reponame_dst_2 + git init . --bare + echo $(pwd) + # This part is subtle + # Add repo A as a remote and fetch from it + # But then fetch from repo B. This points FETCH_HEAD to repo B + # We're testing that git-lfs will ignore FETCH_HEAD, since FETCH_HEAD is + # a fallback, only used when no remote is set + git remote add origin "$GITSERVER/$reponame_src_A" + git fetch + git fetch "$GITSERVER/$reponame_src_B" refs/heads/main:refs/heads/main + git archive $rev -o archive.out + + # Verify archive contains file from second repo, but not first repo + grep "test_file_A.dat" archive.out + grep -v "test_file_B.dat" archive.out ) end_test