- my ($dir) = @_;
- my @cmd = (qw(git init --bare -q), $dir);
- run_die(\@cmd);
- # set a reasonable default:
- @cmd = (qw/git config/, "--file=$dir/config",
- 'repack.writeBitmaps', 'true');
- run_die(\@cmd);
+ my ($dir) = @_; # or self
+ $dir = $dir->{git}->{git_dir} if ref($dir);
+ require File::Path;
+ File::Path::mkpath([ map { "$dir/$_" } qw(objects/info refs/heads) ]);
+ for (my $i = 0; $i < @INIT_FILES; $i++) {
+ my $f = $dir.'/'.$INIT_FILES[$i++];
+ next if -f $f;
+ open my $fh, '>', $f or die "open $f: $!";
+ print $fh $INIT_FILES[$i] or die "print $f: $!";
+ close $fh or die "close $f: $!";
+ }