diff options
author | Joe Rayhawk <jrayhawk@cobain.omgwallhack.org> | 2018-09-24 20:41:31 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk@cobain.omgwallhack.org> | 2018-09-24 20:41:31 -0700 |
commit | e405f85ab352f90802a00d26c110693d884cc01d (patch) | |
tree | aea3b0d8d8d3c0e9c4731c924206028e1b79e2db /libpiny | |
parent | 8f2a63b936ddf781c5b591d76108b11579485f39 (diff) | |
download | piny-code-e405f85ab352f90802a00d26c110693d884cc01d.tar.gz piny-code-e405f85ab352f90802a00d26c110693d884cc01d.zip |
libpiny: Piny::Repo: Symlink files out of root
Due to insecurities surrounding core.hooksPath and git's insistence upon
locking files it doesn't even intend to update, it's necessary to
symbolicly link several files into their own namespaces. We specifically
do this with HEAD and packed refs, but there might eventually be others
to worry about.
Diffstat (limited to 'libpiny')
-rw-r--r-- | libpiny/lib/Piny/Repo.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpiny/lib/Piny/Repo.pm b/libpiny/lib/Piny/Repo.pm index 8a7f54e..174659f 100644 --- a/libpiny/lib/Piny/Repo.pm +++ b/libpiny/lib/Piny/Repo.pm @@ -262,6 +262,20 @@ sub rebuild_git { }; }; + unless( -d $s->path . "/snowflakes" ) { + mkdir( $s->path . "/snowflakes" ) or die "Could not mkdir snowflakes: $!"; + }; + + unless( -l $s->path . "/packed-refs" ) { + rename( $s->path . "/packed-refs", $s->path . "/snowflakes/packed-refs" ) or die "Could not rename packed-refs: $!"; + symlink( "snowflakes/packed-refs", $s->path . "/packed-refs" ) or die "Could not symlink packed-refs: $!"; + }; + + unless( -l $s->path . "/HEAD" ) { + rename( $s->path . "/HEAD", $s->path . "/refs/HEAD" ) or die "Could not rename HEAD: $!"; + symlink( "refs/HEAD", $s->path . "/HEAD" ) or die "Could not symlink HEAD: $!"; + }; + foreach( "info", "logs", "branches" ) { (-e $s->path . "/" . $_) or mkdir( $s->path . "/" . $_ ) or die "Could not mkdir $_ for repo: $!"; }; |