3 . "$(dirname "$0")/testlib.sh"
5 # HACK(taylor): git uses ".g<hash>" in the version name to signal that it is
6 # from the "next" branch, which is the only (current) version of Git that has
7 # support for the filter protocol.
9 ensure_git_version_isnt $VERSION_LOWER "2.11.0"
11 begin_test "filter process: checking out a branch"
15 reponame="filter_process_checkout"
16 setup_remote_repo "$reponame"
17 clone_repo "$reponame" repo
20 git add .gitattributes
21 git commit -m "initial commit"
23 contents_a="contents_a"
24 contents_a_oid="$(calc_oid $contents_a)"
25 printf "$contents_a" > a.dat
28 git commit -m "add a.dat"
32 contents_b="contents_b"
33 contents_b_oid="$(calc_oid $contents_b)"
34 printf "$contents_b" > b.dat
37 git commit -m "add b.dat"
42 # Git will choose filter.lfs.process over `filter.lfs.clean` and
44 GIT_TRACE_PACKET=1 git \
45 -c "filter.lfs.process=git-lfs filter-process" \
46 -c "filter.lfs.clean=false"\
47 -c "filter.lfs.smudge=false" \
48 -c "filter.lfs.required=true" \
49 clone "$GITSERVER/$reponame" "$reponame-assert"
53 # Assert that we are on the "master" branch, and have a.dat
54 [ "master" = "$(git rev-parse --abbrev-ref HEAD)" ]
55 [ "$contents_a" = "$(cat a.dat)" ]
56 assert_pointer "master" "a.dat" "$contents_a_oid" 10
60 # Assert that we are on the "b" branch, and have b.dat
61 [ "b" = "$(git rev-parse --abbrev-ref HEAD)" ]
62 [ "$contents_b" = "$(cat b.dat)" ]
63 assert_pointer "b" "b.dat" "$contents_b_oid" 10
68 begin_test "filter process: adding a file"
72 reponame="filter_process_add"
73 setup_remote_repo "$reponame"
74 clone_repo "$reponame" "$reponame"
77 git add .gitattributes
78 git commit -m "initial commit"
81 contents_oid="$(calc_oid "$contents")"
82 printf "$contents" > a.dat
86 expected="$(pointer "$contents_oid" "${#contents}")"
87 got="$(git cat-file -p :a.dat)"
89 diff -u <(echo "$expected") <(echo "$got")
93 # https://github.com/git-lfs/git-lfs/issues/1697
94 begin_test "filter process: add a file with 1024 bytes"
101 git lfs track "*.dat"
102 dd if=/dev/zero of=first.dat bs=1024 count=1
103 printf "any contents" > second.dat