From f6f931be87f3a5299ca3e0779d14ad5eaf5de232 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 23 Jan 2020 10:21:26 +0200 Subject: [PATCH] hooks: checkout: fix incorrect dvc repo detection When running from non-root directory `git ls-files .dvc` will treat it as a relative path to the current location, so if you run `git checkout` from a directory that is not a git/dvc root, our hook will think that it is being run in a non-dvc repo and will do nothing. To fix that, need to use `--full-name` flag. --- dvc/scm/git/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py index 3872c8e72..2d334a649 100644 --- a/dvc/scm/git/__init__.py +++ b/dvc/scm/git/__init__.py @@ -250,7 +250,7 @@ class Git(Base): def _install_hook(self, name, cmd): command = ( '[ "$3" = "0" ]' - ' || [ -z "$(git ls-files .dvc)" ]' + ' || [ -z "$(git ls-files --full-name .dvc)" ]' " || exec dvc {}".format(cmd) )