mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
project: fallback to hardlinks with git hooks
Windows requires Administrator access to create symlinks. We can mitigate this a bit by falling back to hardlinks as those may be created by any user on the system. Do this with the git hooks as these are supposed to be internal only and people shouldn't be modifying them. If they do, they'll have to delink first. This seems worth it to allow repo usage without extra privileges. Change-Id: I996ea9c9238f7bd7d27d1d9b1f2786593bf75ef7 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256312 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
8c268c0e7b
commit
7951e14385
14
project.py
14
project.py
@ -2860,19 +2860,23 @@ class Project(object):
|
||||
if platform_utils.islink(dst):
|
||||
continue
|
||||
if os.path.exists(dst):
|
||||
if filecmp.cmp(stock_hook, dst, shallow=False):
|
||||
platform_utils.remove(dst)
|
||||
else:
|
||||
# If the files are the same, we'll leave it alone. We create symlinks
|
||||
# below by default but fallback to hardlinks if the OS blocks them.
|
||||
# So if we're here, it's probably because we made a hardlink below.
|
||||
if not filecmp.cmp(stock_hook, dst, shallow=False):
|
||||
if not quiet:
|
||||
_warn("%s: Not replacing locally modified %s hook",
|
||||
self.relpath, name)
|
||||
continue
|
||||
continue
|
||||
try:
|
||||
platform_utils.symlink(
|
||||
os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
|
||||
except OSError as e:
|
||||
if e.errno == errno.EPERM:
|
||||
raise GitError(self._get_symlink_error_message())
|
||||
try:
|
||||
os.link(stock_hook, dst)
|
||||
except OSError:
|
||||
raise GitError(self._get_symlink_error_message())
|
||||
else:
|
||||
raise
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user