3 . "$(dirname "$0")/testlib.sh"
9 # no need to setup a remote repo, since this test doesn't need to push or pull
16 git lfs track "*.jpg" | grep "Tracking \"\*.jpg\""
17 echo "* annex.backend=SHA512E" >> .gitattributes
19 git lfs untrack "*.jpg"
21 expected="* annex.backend=SHA512E"
22 [ "$expected" = "$(cat .gitattributes)" ]
26 begin_test "untrack outside git repo"
34 git lfs untrack "*.foo" || {
35 # this fails if it's run outside of a git repo using GIT_LFS_TEST_DIR
37 # git itself returns an exit status of 128
39 # fatal: Not a git repository (or any of the parent directories): .git
47 if [ -n "$GIT_LFS_TEST_DIR" ]; then
48 echo "GIT_LFS_TEST_DIR should be set outside of any Git repository"
54 begin_test "untrack removes escape sequences"
58 reponame="untrack-remove-escape-sequence"
62 git lfs track " " | grep "Tracking \" \""
63 assert_attributes_count "[[:space:]]" "filter=lfs" 1
65 git lfs untrack " " | grep "Untracking \" \""
66 assert_attributes_count "[[:space:]]" "filter=lfs" 0
68 git lfs track "#" | grep "Tracking \"#\""
69 assert_attributes_count "\\#" "filter=lfs" 1
71 git lfs untrack "#" | grep "Untracking \"#\""
72 assert_attributes_count "\\#" "filter=lfs" 0
76 begin_test "untrack removes prefixed patterns (legacy)"
80 reponame="untrack-removes-prefix-patterns-legacy"
84 echo "./a.dat filter=lfs diff=lfs merge=lfs" > .gitattributes
86 git add .gitattributes a.dat
87 git commit -m "initial commit"
89 git lfs untrack "./a.dat"
91 if [ ! -z "$(cat .gitattributes)" ]; then
92 echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes"
96 git checkout -- .gitattributes
98 git lfs untrack "a.dat"
100 if [ ! -z "$(cat .gitattributes)" ]; then
101 echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes"
107 begin_test "untrack removes prefixed patterns (modern)"
111 reponame="untrack-removes-prefix-patterns-modern"
115 echo "a.dat filter=lfs diff=lfs merge=lfs" > .gitattributes
117 git add .gitattributes a.dat
118 git commit -m "initial commit"
120 git lfs untrack "./a.dat"
122 if [ ! -z "$(cat .gitattributes)" ]; then
123 echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes"
127 git checkout -- .gitattributes
129 git lfs untrack "a.dat"
131 if [ ! -z "$(cat .gitattributes)" ]; then
132 echo &>2 "fatal: expected 'git lfs untrack' to clear .gitattributes"