From 2d1f8319667741c57697613d27a99dbbf0e49663 Mon Sep 17 00:00:00 2001
From: Joe Rayhawk <jrayhawk@omgwallhack.org>
Date: Fri, 15 Oct 2010 19:54:35 -0700
Subject: Change owner/group data from $s->path to $s->path . "/objects" in
 repostat, create, and rebuild functions.

---
 usr/src/libpiny/lib/Piny/Repo.pm | 41 +++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/usr/src/libpiny/lib/Piny/Repo.pm b/usr/src/libpiny/lib/Piny/Repo.pm
index 84eb0c9..facc812 100644
--- a/usr/src/libpiny/lib/Piny/Repo.pm
+++ b/usr/src/libpiny/lib/Piny/Repo.pm
@@ -198,10 +198,21 @@ sub rebuild {
 
   my $ikiuser = Piny::User::IkiWiki->new( "name" => "ikiwiki-" . $s->name );
 
-  open( TOUCH, ">", $s->path . "/git-daemon-export-ok" ) or die "Could not touch git-daemon-export-ok for repo: $!";
-  close( TOUCH );
+  foreach( "git-daemon-export-ok", "packed-refs" ) {
+    open( TOUCH, ">", $s->path . "/" . $_ ) or die "Could not touch $_ for repo: $!";
+    close( TOUCH );
+  };
+
+  foreach( "info", "logs" ) {
+    mkdir( $s->path . "/" . $_ ) and die "Could not mkdir $_ for repo: $!";
+  };
+
+  chown( 0, 0, $s->path, $s->path . '/config' ) and die "Could not change ownership of git dir!";
+
+  foreach( "branches", "description", "HEAD", "info", "logs", "objects", "packed-refs", "refs" ) {
+    system( "/bin/chown", "-R", $s->owner->name . "." . $s->group->name, $s->path . "/" . $_ ) and die "Could not change ownership of $_ for repo: $!";
+  };
 
-  system( "/bin/chown", "-R", $s->owner->name . "." . $s->group->name, $s->path ) and die "Could not change ownership of git repo!";
   system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $s->path . "/hooks" ) and die "Could not change ownership of git hooks!";
 
   open( SETUP, ">", "/etc/ikiwiki/piny/" . $s->name . ".setup" ) or die "Could not open new ikiwiki setup file: $!";
@@ -363,7 +374,7 @@ sub _change_owner {
 
   return unless defined $old_owner;
 
-  find( { wanted => sub { chown( $new_owner->uid, -1, $_ ) or die "Couldn't chown $_: $!"; }, no_chdir => 1 }, $s->path );
+  find( { wanted => sub { chown( $new_owner->uid, -1, $_ ) or die "Couldn't chown $_: $!"; }, no_chdir => 1 }, $s->path . "/objects" );
 
   $s->clear_ikiwiki_setup;
 };
@@ -413,10 +424,22 @@ sub create {
 
   $repo->description( $description );
 
-  open( TOUCH, ">", $repo->path . "/git-daemon-export-ok" ) or die "Could not touch git-daemon-export-ok for repo: $!";
-  close( TOUCH );
+  foreach( "git-daemon-export-ok", "packed-refs" ) {
+    open( TOUCH, ">", $repo->path . "/" . $_ ) or die "Could not touch $_ for repo: $!";
+    close( TOUCH );
+  };
+
+  foreach( "info", "logs" ) {
+    mkdir( $repo->path . "/" . $_ ) and die "Could not mkdir $_ for repo: $!";
+  };
+
+
+  foreach( "branches", "description", "HEAD", "info", "logs", "objects", "packed-refs", "refs" ) {
+    system( "/bin/chown", "-R", $user->name . "." . $group->name, $repo->path . "/" . $_ ) and die "Could not change ownership of $_ for repo: $!";
+  };
+
+  chown( 0, 0, $repo->path, $repo->path . '/config' ) and die "Could not change ownership of git dir!";
 
-  system( "/bin/chown", "-R", $user->name . "." . $group->name, $repo->path ) and die "Could not change ownership of git repo!";
   system( "/bin/chown", "-R", $ikiuser->name . "." . $ikiuser->name, $repo->path . "/hooks" ) and die "Could not change ownership of git hooks!";
 
   open( SETUP, ">", "/etc/ikiwiki/piny/" . $repo->name . ".setup" ) or die "Could not open new ikiwiki setup file: $!";
@@ -527,8 +550,8 @@ sub _build_description {
 sub _build_repostat {
   my ( $s ) = @_;
 
-  my @res = stat( $s->path );
-  die "stat( " . $s->path . " ) failed: $!" unless @res;
+  my @res = stat( $s->path . "/objects" );
+  die "stat( " . $s->path . "/objects ) failed: $!" unless @res;
   return \@res;
 };
 
-- 
cgit v1.2.3