From 333c0a499bd76a129dfbb4ba78c182c398caa79f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Nov 2021 12:39:00 -0500 Subject: project: init hooks in objdir only objdir is the .repo/project-objects/ dir based on the remote path. gitdir is the .repo/projects/ dir based on the local source checkout path. When we setup the gitdir, we symlink "hooks" to the one in the objdir. But when we go to initialize the hooks, we do it via gitdir. There is a 1-to-many mapping from project-objects to projects, so initializing via gitdir can be repetitive. Collapse the hook init logic to the objdir init path. Change-Id: I828fca60ce6e125d6706c709cdb2797faa40aa50 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/323815 Reviewed-by: Raman Tenneti Tested-by: Mike Frysinger --- project.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'project.py') diff --git a/project.py b/project.py index 59221914..57826a17 100644 --- a/project.py +++ b/project.py @@ -2466,6 +2466,8 @@ class Project(object): os.makedirs(self.objdir) self.bare_objdir.init() + self._UpdateHooks(quiet=quiet) + if self.use_git_worktrees: # Enable per-worktree config file support if possible. This is more a # nice-to-have feature for users rather than a hard requirement. @@ -2526,8 +2528,6 @@ class Project(object): _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), os.path.join(ref_dir, 'objects') + '\n') - self._UpdateHooks(quiet=quiet) - m = self.manifest.manifestProject.config for key in ['user.name', 'user.email']: if m.Has(key, include_defaults=False): @@ -2543,11 +2543,11 @@ class Project(object): raise def _UpdateHooks(self, quiet=False): - if os.path.exists(self.gitdir): + if os.path.exists(self.objdir): self._InitHooks(quiet=quiet) def _InitHooks(self, quiet=False): - hooks = platform_utils.realpath(self._gitdir_path('hooks')) + hooks = platform_utils.realpath(os.path.join(self.objdir, 'hooks')) if not os.path.exists(hooks): os.makedirs(hooks) for stock_hook in _ProjectHooks(): @@ -2831,9 +2831,6 @@ class Project(object): 'for other options.') return 'filesystem must support symlinks' - def _gitdir_path(self, path): - return platform_utils.realpath(os.path.join(self.gitdir, path)) - def _revlist(self, *args, **kw): a = [] a.extend(args) -- cgit v1.2.3-54-g00ecf