diff --git a/lib/spack/spack/cmd/pkg.py b/lib/spack/spack/cmd/pkg.py index 7b668586b51..12dcb817924 100644 --- a/lib/spack/spack/cmd/pkg.py +++ b/lib/spack/spack/cmd/pkg.py @@ -73,13 +73,16 @@ def setup_parser(subparser): help="revision to compare to rev1 (default is HEAD)") -def get_git(): +def get_git(fatal=True): # cd to spack prefix to do git operations os.chdir(spack.prefix) # If this is a non-git version of spack, give up. if not os.path.isdir('.git'): - tty.die("No git repo in %s. Can't use 'spack pkg'" % spack.prefix) + if fatal: + tty.die("No git repo in %s. Can't use 'spack pkg'" % spack.prefix) + else: + return None return which("git", required=True) diff --git a/lib/spack/spack/hooks/case_consistency.py b/lib/spack/spack/hooks/case_consistency.py index e9208ee9fff..2b882916665 100644 --- a/lib/spack/spack/hooks/case_consistency.py +++ b/lib/spack/spack/hooks/case_consistency.py @@ -31,6 +31,7 @@ from llnl.util.filesystem import * import spack +from spack.cmd.pkg import get_git from spack.util.executable import * @@ -61,8 +62,8 @@ def git_case_consistency_check(path): """ with working_dir(path): # Don't bother fixing case if Spack isn't in a git repository - git = which('git') - if not git: + git = get_git(fatal=False) + if git is None: return try: