3 . "$(dirname "$0")/testlib.sh"
5 begin_test "uninstall outside repository"
12 smudge="$(git config filter.lfs.smudge)"
13 clean="$(git config filter.lfs.clean)"
14 filter="$(git config filter.lfs.process)"
16 printf "$smudge" | grep "git-lfs smudge"
17 printf "$clean" | grep "git-lfs clean"
18 printf "$filter" | grep "git-lfs filter-process"
20 # uninstall multiple times to trigger https://github.com/git-lfs/git-lfs/issues/529
26 git lfs uninstall | tee uninstall.log
27 grep "configuration has been removed" uninstall.log
29 [ "" = "$(git config --global filter.lfs.smudge)" ]
30 [ "" = "$(git config --global filter.lfs.clean)" ]
31 [ "" = "$(git config --global filter.lfs.process)" ]
34 [ "$(grep 'filter "lfs"' $HOME/.gitconfig -c)" = "0" ]
38 begin_test "uninstall outside repository without access to .git/lfs"
42 mkdir uninstall-no-lfs
49 [ "" != "$(git config --global filter.lfs.smudge)" ]
50 [ "" != "$(git config --global filter.lfs.clean)" ]
51 [ "" != "$(git config --global filter.lfs.process)" ]
55 [ "" = "$(git config --global filter.lfs.smudge)" ]
56 [ "" = "$(git config --global filter.lfs.clean)" ]
57 [ "" = "$(git config --global filter.lfs.process)" ]
60 begin_test "uninstall inside repository with default pre-push hook"
64 reponame="$(basename "$0" ".sh")-hook"
70 [ -f .git/hooks/pre-push ]
71 grep "git-lfs" .git/hooks/pre-push
73 [ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
74 [ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
75 [ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
79 [ -f .git/hooks/pre-push ] && {
80 echo "expected .git/hooks/pre-push to be deleted"
83 [ "" = "$(git config filter.lfs.smudge)" ]
84 [ "" = "$(git config filter.lfs.clean)" ]
85 [ "" = "$(git config filter.lfs.process)" ]
89 begin_test "uninstall inside repository without lfs pre-push hook"
93 reponame="$(basename "$0" ".sh")-no-hook"
98 echo "something something git-lfs" > .git/hooks/pre-push
101 [ -f .git/hooks/pre-push ]
102 [ "something something git-lfs" = "$(cat .git/hooks/pre-push)" ]
104 [ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
105 [ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
106 [ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
110 [ -f .git/hooks/pre-push ]
111 [ "" = "$(git config filter.lfs.smudge)" ]
112 [ "" = "$(git config filter.lfs.clean)" ]
113 [ "" = "$(git config filter.lfs.process)" ]
117 begin_test "uninstall hooks inside repository"
121 reponame="$(basename "$0" ".sh")-only-hook"
127 [ -f .git/hooks/pre-push ]
128 grep "git-lfs" .git/hooks/pre-push
130 [ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
131 [ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
132 [ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
134 git lfs uninstall hooks
136 [ -f .git/hooks/pre-push ] && {
137 echo "expected .git/hooks/pre-push to be deleted"
141 [ "git-lfs smudge -- %f" = "$(git config filter.lfs.smudge)" ]
142 [ "git-lfs clean -- %f" = "$(git config filter.lfs.clean)" ]
143 [ "git-lfs filter-process" = "$(git config filter.lfs.process)" ]
147 begin_test "uninstall --local"
151 # old values that should be ignored by `uninstall --local`
152 git config --global filter.lfs.smudge "global smudge"
153 git config --global filter.lfs.clean "global clean"
154 git config --global filter.lfs.process "global filter"
156 reponame="$(basename "$0" ".sh")-local"
160 git lfs install --local
162 # local configs are correct
163 [ "git-lfs smudge -- %f" = "$(git config --local filter.lfs.smudge)" ]
164 [ "git-lfs clean -- %f" = "$(git config --local filter.lfs.clean)" ]
165 [ "git-lfs filter-process" = "$(git config --local filter.lfs.process)" ]
168 [ "global smudge" = "$(git config --global filter.lfs.smudge)" ]
169 [ "global clean" = "$(git config --global filter.lfs.clean)" ]
170 [ "global filter" = "$(git config --global filter.lfs.process)" ]
172 git lfs uninstall --local 2>&1 | tee uninstall.log
173 if [ ${PIPESTATUS[0]} -ne 0 ]; then
174 echo >&2 "fatal: expected 'git lfs uninstall --local' to succeed"
177 grep -v "Global Git LFS configuration has been removed." uninstall.log
180 [ "global smudge" = "$(git config --global filter.lfs.smudge)" ]
181 [ "global clean" = "$(git config --global filter.lfs.clean)" ]
182 [ "global filter" = "$(git config --global filter.lfs.process)" ]
184 # local configs are empty
185 [ "" = "$(git config --local filter.lfs.smudge)" ]
186 [ "" = "$(git config --local filter.lfs.clean)" ]
187 [ "" = "$(git config --local filter.lfs.process)" ]