From 352208759189bfa5edc8743f5cbb9e5a0d60ba75 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sat, 29 Aug 2009 11:36:26 +0530 Subject: [PATCH] compile: REPO_BASE need not be under $HOME In the "create new repos" loop, we need an absolute value for REPO_BASE, in order to be able to chdir back and forth. But (taking the "normal user with no privileges" assumption too far!) we assumed REPO_BASE would be within $HOME, and relative to it. So it fails when someone wants the repo_base elsewhere. Now we don't prefix $HOME if REPO_BASE is already absolute (begins with a "/") bug reported by evocallaghan --- conf/example.gitolite.rc | 2 +- src/gl-compile-conf | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/conf/example.gitolite.rc b/conf/example.gitolite.rc index 7a5068d..44413a0 100644 --- a/conf/example.gitolite.rc +++ b/conf/example.gitolite.rc @@ -1,6 +1,6 @@ # this is meant to be pulled into a perl program using "do" -# base directory for all the repos +# base directory for all the repos (absolute, or relative to $HOME) $REPO_BASE="repositories"; # gitolite admin directory, files, etc diff --git a/src/gl-compile-conf b/src/gl-compile-conf index 3388979..811c325 100755 --- a/src/gl-compile-conf +++ b/src/gl-compile-conf @@ -184,7 +184,10 @@ close $compiled_fh or die "close compiled-conf failed: $!"; # did not have that luxury, so it was forced to detect the first push and # create it then -my_chdir("$ENV{HOME}/$REPO_BASE"); +# repo-base needs to be an absolute path for this loop to work right +# so if it was not already absolute, prefix $HOME. +my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" ); +my_chdir("$repo_base_abs"); for my $repo (keys %repos) { unless (-d "$repo.git") @@ -194,7 +197,7 @@ for my $repo (keys %repos) system("git init --bare"); system("cp $GL_ADMINDIR/src/update-hook.pl hooks/update"); system("chmod 755 hooks/update"); - my_chdir("$ENV{HOME}/$REPO_BASE"); + my_chdir("$repo_base_abs"); } }