commands: allow $GIT_LFS_TRACK_NO_INSTALL_HOOKS to disable hook installation

This commit is contained in:
Taylor Blau 2017-09-14 12:45:46 -04:00
parent 5c8c8512a5
commit df76acf33b
2 changed files with 25 additions and 1 deletions

@ -42,7 +42,9 @@ func trackCommand(cmd *cobra.Command, args []string) {
os.Exit(128) os.Exit(128)
} }
lfs.InstallHooks(false) if !cfg.Os.Bool("GIT_LFS_TRACK_NO_INSTALL_HOOKS", false) {
lfs.InstallHooks(false)
}
if len(args) == 0 { if len(args) == 0 {
listPatterns() listPatterns()

@ -488,3 +488,25 @@ begin_test "track (symlinked repository)"
popd > /dev/null popd > /dev/null
) )
end_test end_test
begin_test "track (\$GIT_LFS_TRACK_NO_INSTALL_HOOKS)"
(
set -e
reponame="track-no-setup-hooks"
git init "$reponame"
cd "$reponame"
[ ! -f .git/hooks/pre-push ]
[ ! -f .git/hooks/post-checkout ]
[ ! -f .git/hooks/post-commit ]
[ ! -f .git/hooks/post-merge ]
GIT_LFS_TRACK_NO_INSTALL_HOOKS=1 git lfs track
[ ! -f .git/hooks/pre-push ]
[ ! -f .git/hooks/post-checkout ]
[ ! -f .git/hooks/post-commit ]
[ ! -f .git/hooks/post-merge ]
)
end_test