summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-11-15 12:39:00 -0500
committerMike Frysinger <vapier@google.com>2021-11-15 19:50:18 +0000
commit333c0a499bd76a129dfbb4ba78c182c398caa79f (patch)
treea132e6384fc780f6fb9f1b0272f4961a991739f9 /project.py
parentfdeb20f43fa853f4113598f18045bd2f6414569b (diff)
downloadgit-repo-333c0a499bd76a129dfbb4ba78c182c398caa79f.tar.gz
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 <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py11
1 files changed, 4 insertions, 7 deletions
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):
2466 os.makedirs(self.objdir) 2466 os.makedirs(self.objdir)
2467 self.bare_objdir.init() 2467 self.bare_objdir.init()
2468 2468
2469 self._UpdateHooks(quiet=quiet)
2470
2469 if self.use_git_worktrees: 2471 if self.use_git_worktrees:
2470 # Enable per-worktree config file support if possible. This is more a 2472 # Enable per-worktree config file support if possible. This is more a
2471 # nice-to-have feature for users rather than a hard requirement. 2473 # nice-to-have feature for users rather than a hard requirement.
@@ -2526,8 +2528,6 @@ class Project(object):
2526 _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'), 2528 _lwrite(os.path.join(self.gitdir, 'objects/info/alternates'),
2527 os.path.join(ref_dir, 'objects') + '\n') 2529 os.path.join(ref_dir, 'objects') + '\n')
2528 2530
2529 self._UpdateHooks(quiet=quiet)
2530
2531 m = self.manifest.manifestProject.config 2531 m = self.manifest.manifestProject.config
2532 for key in ['user.name', 'user.email']: 2532 for key in ['user.name', 'user.email']:
2533 if m.Has(key, include_defaults=False): 2533 if m.Has(key, include_defaults=False):
@@ -2543,11 +2543,11 @@ class Project(object):
2543 raise 2543 raise
2544 2544
2545 def _UpdateHooks(self, quiet=False): 2545 def _UpdateHooks(self, quiet=False):
2546 if os.path.exists(self.gitdir): 2546 if os.path.exists(self.objdir):
2547 self._InitHooks(quiet=quiet) 2547 self._InitHooks(quiet=quiet)
2548 2548
2549 def _InitHooks(self, quiet=False): 2549 def _InitHooks(self, quiet=False):
2550 hooks = platform_utils.realpath(self._gitdir_path('hooks')) 2550 hooks = platform_utils.realpath(os.path.join(self.objdir, 'hooks'))
2551 if not os.path.exists(hooks): 2551 if not os.path.exists(hooks):
2552 os.makedirs(hooks) 2552 os.makedirs(hooks)
2553 for stock_hook in _ProjectHooks(): 2553 for stock_hook in _ProjectHooks():
@@ -2831,9 +2831,6 @@ class Project(object):
2831 'for other options.') 2831 'for other options.')
2832 return 'filesystem must support symlinks' 2832 return 'filesystem must support symlinks'
2833 2833
2834 def _gitdir_path(self, path):
2835 return platform_utils.realpath(os.path.join(self.gitdir, path))
2836
2837 def _revlist(self, *args, **kw): 2834 def _revlist(self, *args, **kw):
2838 a = [] 2835 a = []
2839 a.extend(args) 2836 a.extend(args)