From e405f85ab352f90802a00d26c110693d884cc01d Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Mon, 24 Sep 2018 20:41:31 -0700 Subject: 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. --- libpiny/lib/Piny/Repo.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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: $!"; }; -- cgit v1.2.3