From 672cc499b9dce9c18ecd9dfc81fd18094535dc49 Mon Sep 17 00:00:00 2001 From: Jesse Hall Date: Wed, 27 Nov 2013 11:17:13 -0800 Subject: [PATCH] Canonicalize project hooks path before use If the top-level .repo directory is moved somewhere else (e.g. a different drive) and replaced with a symlink, _InitHooks() will create broken symlinks. Resolving symlinks before computing the relative path for the symlink keeps the path within the repo tree, so the tree can be moved anywhere. Change-Id: Ifa5c07869e3477186ddd2c255c6c607f547bc1fe --- project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project.py b/project.py index b01a52ba..1fb5d586 100644 --- a/project.py +++ b/project.py @@ -82,7 +82,7 @@ def _ProjectHooks(): """ global _project_hook_list if _project_hook_list is None: - d = os.path.abspath(os.path.dirname(__file__)) + d = os.path.realpath(os.path.abspath(os.path.dirname(__file__))) d = os.path.join(d , 'hooks') _project_hook_list = [os.path.join(d, x) for x in os.listdir(d)] return _project_hook_list @@ -1955,7 +1955,7 @@ class Project(object): self._InitHooks() def _InitHooks(self): - hooks = self._gitdir_path('hooks') + hooks = os.path.realpath(self._gitdir_path('hooks')) if not os.path.exists(hooks): os.makedirs(hooks) for stock_hook in _ProjectHooks():