From 6b65ffbab45e70be18a2761d0c98d9a46162a7a9 Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Sat, 23 Jul 2011 06:02:12 +0530 Subject: [PATCH] (minor) setperms and DOS users Supporting git on DOS may be a fact of life, but it felt good to make them use the "right" editor (hint: starts with v, ends with m, has three letters), or at least something equivalent, to produce their setperms input files. I'd say "yes Fred I know. However, Unix doesn't work like that, and when talking to a big, important, OS like Unix from your little single-user workstation, you do have to go the extra mile. It's not that different from going into a meeting with the CEO you know -- you dress up a little for that meeting don't you?". And Fred would nod, a little awed by the analogy. Maybe the awe was tinged with a wee bit of anger but not much; he knows there's a hierarchy among OSs, just like among people, and he knows where his OS stands in that hierarchy... ---- For the humour impaired, that was a joke. To start with, I don't know anyone called Fred. It *is* true that I tend to ignore DOS if at all possible, especially in my *code*. But since I don't really use wildrepos at work, this issue would never have come up for me, even in the DOS projects I manage. In this case someone who's contributed a heck of a lot to the evolution of gitolite asked, so here it is. ---- oh and in case you were wondering, DOS stands for "dominant operating system" ;-) --- src/gitolite.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gitolite.pm b/src/gitolite.pm index 885372c..bfced77 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -9,6 +9,7 @@ use Exporter 'import'; check_repo_write_enabled cli_repo_rights dbg + dos2unix list_phy_repos ln_sf log_it @@ -140,6 +141,12 @@ sub dbg { } } +sub dos2unix { + # WARNING: when calling this, make sure you supply a list context + s/\r\n/\n/g for @_; + return @_; +} + sub log_it { my ($ip, $logmsg); open my $log_fh, ">>", $ENV{GL_LOG} or die "open log failed: $!\n"; @@ -310,8 +317,7 @@ sub new_wild_repo { my %perm_cats; if ($user and -f "$REPO_BASE/$repo.git/gl-perms") { - my $fh = wrap_open("<", "$REPO_BASE/$repo.git/gl-perms"); - my $perms = join ("", <$fh>); + my ($perms) = dos2unix(slurp("$REPO_BASE/$repo.git/gl-perms")); # discard comments $perms =~ s/#.*//g; # convert R and RW to the actual category names in the config file