Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/2541

Change subject: scons: Use a relative symlink for git hooks more selectively.
......................................................................

scons: Use a relative symlink for git hooks more selectively.

If the hooks directory is a symlink, then there are at least two possible
scenarios to consider when installing a hook which is itself a symlink. The
first is that hooks is a relative symlink, and so is likely intended to stay
in place relative to .git and the git working directory. In that case, it's ok for the symlinks inside of hooks to be relative to the working directory too,
since they should also stay in place relatively speaking.

The second situation is that the symlink is absolute. In that case, moving the
git working directory will move the hook relative to the hook directory, and
any relative symlink will become broken. In that case, the hook symlink needs
to be absolute.

The same logic likely applies to the .git directory itself, although I haven't
run into a situation in practice where the .git directory is actually a
symlink.

Change-Id: I047aa198094dd0fd5a841417d93b211ece02783f
---
M SConstruct
1 file changed, 6 insertions(+), 2 deletions(-)



diff --git a/SConstruct b/SConstruct
index 4593fdd..fbc52cc 100755
--- a/SConstruct
+++ b/SConstruct
@@ -400,8 +400,12 @@
         if not git_hooks.exists():
             mkdir(git_hooks.get_abspath())

-        # Use a relative symlink if the hooks live in the source directory
-        if hook.is_under(main.root):
+        abs_symlink_hooks = git_hooks.islink() and \
+            os.path.isabs(os.readlink(git_hooks.get_abspath()))
+
+        # Use a relative symlink if the hooks live in the source directory,
+        # and the hooks directory is not a symlink to an absolute path.
+        if hook.is_under(main.root) and not abs_symlink_hooks:
             script_path = os.path.relpath(
                 script.get_abspath(),
                 hook.Dir(".").get_abspath())

--
To view, visit https://gem5-review.googlesource.com/2541
To unsubscribe, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I047aa198094dd0fd5a841417d93b211ece02783f
Gerrit-Change-Number: 2541
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabebl...@google.com>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to