| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | . "$(dirname "$0")/testlib.sh" |
| 4 | |
| 5 | reponame="$(basename "$0" ".sh")" |
| 6 | contents="a" |
| 7 | contents_oid=$(calc_oid "$contents") |
| 8 | |
| 9 | begin_test "init fetch unclean paths" |
| 10 | ( |
| 11 | set -e |
| 12 | |
| 13 | setup_remote_repo $reponame |
| 14 | clone_repo $reponame repo |
| 15 | |
| 16 | git lfs track "*.dat" 2>&1 | tee track.log |
| 17 | grep "Tracking \"\*.dat\"" track.log |
| 18 | |
| 19 | mkdir dir |
| 20 | printf "%s" "$contents" > dir/a.dat |
| 21 | |
| 22 | git add dir/a.dat |
| 23 | git add .gitattributes |
| 24 | git commit -m "add dir/a.dat" 2>&1 | tee commit.log |
| 25 | grep "main (root-commit)" commit.log |
| 26 | grep "2 files changed" commit.log |
| 27 | grep "create mode 100644 dir/a.dat" commit.log |
| 28 | grep "create mode 100644 .gitattributes" commit.log |
| 29 | |
| 30 | [ "a" = "$(cat dir/a.dat)" ] |
| 31 | |
| 32 | assert_local_object "$contents_oid" 1 |
| 33 | refute_server_object "$reponame" "$contents_oid" |
| 34 | |
| 35 | git push origin main 2>&1 | tee push.log |
| 36 | grep "Uploading LFS objects: 100% (1/1), 1 B" push.log |
| 37 | grep "main -> main" push.log |
| 38 | |
| 39 | assert_server_object "$reponame" "$contents_oid" |
| 40 | |
| 41 | # This clone is used for subsequent tests |
| 42 | clone_repo "$reponame" clone |
| 43 | ) |
| 44 | end_test |
| 45 | |
| 46 | begin_test "fetch unclean paths with include filter in gitconfig" |
| 47 | ( |
| 48 | set -e |
| 49 | cd clone |
| 50 | rm -rf .git/lfs/objects |
| 51 | |
| 52 | git config "lfs.fetchinclude" "dir/" |
| 53 | git lfs fetch |
| 54 | assert_local_object "$contents_oid" 1 |
| 55 | ) |
| 56 | end_test |
| 57 | |
| 58 | begin_test "fetch unclean paths with exclude filter in gitconfig" |
| 59 | ( |
| 60 | set -e |
| 61 | cd clone |
| 62 | rm -rf .git/lfs/objects |
| 63 | git config --unset "lfs.fetchinclude" |
| 64 | |
| 65 | git config "lfs.fetchexclude" "dir/" |
| 66 | git lfs fetch |
| 67 | refute_local_object "$contents_oid" |
| 68 | ) |
| 69 | end_test |
| 70 | |
| 71 | begin_test "fetch unclean paths with include filter in cli" |
| 72 | ( |
| 73 | set -e |
| 74 | cd clone |
| 75 | rm -rf .git/lfs/objects |
| 76 | |
| 77 | git config --unset "lfs.fetchexclude" |
| 78 | |
| 79 | rm -rf .git/lfs/objects |
| 80 | git lfs fetch -I="dir/" |
| 81 | assert_local_object "$contents_oid" 1 |
| 82 | ) |
| 83 | end_test |
| 84 | |
| 85 | begin_test "fetch unclean paths with exclude filter in cli" |
| 86 | ( |
| 87 | set -e |
| 88 | cd clone |
| 89 | rm -rf .git/lfs/objects |
| 90 | |
| 91 | git lfs fetch -X="dir/" |
| 92 | refute_local_object "$contents_oid" |
| 93 | ) |
| 94 | end_test |