From 473d404b53488a17458beea81913c1bc5df47a8a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 3 Mar 2006 21:34:14 -0800 Subject: [PATCH 1/3] tar-tree: file/dirmode fix. This fixes two bugs introduced when we switched to generic tree traversal code. (1) directory mode recorded silently became 0755, not 0777 (2) if passed a tree object (not a commit), it emitted an alarming error message (but proceeded anyway). Signed-off-by: Junio C Hamano --- tar-tree.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tar-tree.c b/tar-tree.c index e85a1ed660..e478e13e28 100644 --- a/tar-tree.c +++ b/tar-tree.c @@ -304,9 +304,11 @@ static void write_header(const unsigned char *sha1, char typeflag, const char *b } if (S_ISDIR(mode)) - mode |= 0755; /* GIT doesn't store permissions of dirs */ - if (S_ISLNK(mode)) - mode |= 0777; /* ... nor of symlinks */ + mode |= 0777; + else if (S_ISREG(mode)) + mode |= (mode & 0100) ? 0777 : 0666; + else if (S_ISLNK(mode)) + mode |= 0777; sprintf(&header[100], "%07o", mode & 07777); /* XXX: should we provide more meaningful info here? */ @@ -391,7 +393,7 @@ int main(int argc, char **argv) usage(tar_tree_usage); } - commit = lookup_commit_reference(sha1); + commit = lookup_commit_reference_gently(sha1, 1); if (commit) { write_global_extended_header(commit->object.sha1); archive_time = commit->date; From 6be32d4791126da12e0eade17362ae8ad3f13971 Mon Sep 17 00:00:00 2001 From: Martin Langhoff Date: Sat, 4 Mar 2006 17:47:29 +1300 Subject: [PATCH 2/3] cvsserver: nested directory creation fixups for Eclipse clients To create nested directories without (or before) sending file entries is rather tricky. Most clients just work. Eclipse, however, expects a very specific sequence of events. With this patch, cvsserver meets those expectations. Note: we may want to reuse prepdir() in req_update -- should move it outside of req_co. Right now prepdir() is tied to how req_co() works. Signed-off-by: Junio C Hamano --- git-cvsserver.perl | 73 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 17 deletions(-) diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 6f10d4c951..9da27231fb 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -579,6 +579,11 @@ sub req_co print $state->{CVSROOT} . "/$module/\n"; print "Clear-static-directory $checkout_path/\n"; print $state->{CVSROOT} . "/$module/\n"; + print "Clear-sticky $checkout_path/\n"; # yes, twice + print $state->{CVSROOT} . "/$module/\n"; + print "Template $checkout_path/\n"; + print $state->{CVSROOT} . "/$module/\n"; + print "0\n"; # instruct the client that we're checking out to $checkout_path print "E cvs checkout: Updating $checkout_path\n"; @@ -586,6 +591,43 @@ sub req_co my %seendirs = (); my $lastdir =''; + # recursive + sub prepdir { + my ($dir, $repodir, $remotedir, $seendirs) = @_; + my $parent = dirname($dir); + $dir =~ s|/+$||; + $repodir =~ s|/+$||; + $remotedir =~ s|/+$||; + $parent =~ s|/+$||; + $log->debug("announcedir $dir, $repodir, $remotedir" ); + + if ($parent eq '.' || $parent eq './') { + $parent = ''; + } + # recurse to announce unseen parents first + if (length($parent) && !exists($seendirs->{$parent})) { + prepdir($parent, $repodir, $remotedir, $seendirs); + } + # Announce that we are going to modify at the parent level + if ($parent) { + print "E cvs checkout: Updating $remotedir/$parent\n"; + } else { + print "E cvs checkout: Updating $remotedir\n"; + } + print "Clear-sticky $remotedir/$parent/\n"; + print "$repodir/$parent/\n"; + + print "Clear-static-directory $remotedir/$dir/\n"; + print "$repodir/$dir/\n"; + print "Clear-sticky $remotedir/$parent/\n"; # yes, twice + print "$repodir/$parent/\n"; + print "Template $remotedir/$dir/\n"; + print "$repodir/$dir/\n"; + print "0\n"; + + $seendirs->{$dir} = 1; + } + foreach my $git ( @{$updater->gethead} ) { # Don't want to check out deleted files @@ -593,6 +635,17 @@ sub req_co ( $git->{name}, $git->{dir} ) = filenamesplit($git->{name}); + if (length($git->{dir}) && $git->{dir} ne './' + && $git->{dir} ne $lastdir ) { + unless (exists($seendirs{$git->{dir}})) { + prepdir($git->{dir}, $state->{CVSROOT} . "/$module/", + $checkout_path, \%seendirs); + $lastdir = $git->{dir}; + $seendirs{$git->{dir}} = 1; + } + print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n"; + } + # modification time of this file print "Mod-time $git->{modified}\n"; @@ -604,24 +657,10 @@ sub req_co print "M U $checkout_path/$git->{name}\n"; } - if (length($git->{dir}) && $git->{dir} ne './' - && $git->{dir} ne $lastdir && !exists($seendirs{$git->{dir}})) { + # instruct client we're sending a file to put in this path + print "Created $checkout_path/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "\n"; - # Eclipse seems to need the Clear-sticky command - # to prepare the 'Entries' file for the new directory. - print "Clear-sticky $checkout_path/$git->{dir}\n"; - print $state->{CVSROOT} . "/$module/$git->{dir}\n"; - print "Clear-static-directory $checkout_path/$git->{dir}\n"; - print $state->{CVSROOT} . "/$module/$git->{dir}\n"; - print "E cvs checkout: Updating /$checkout_path/$git->{dir}\n"; - $lastdir = $git->{dir}; - $seendirs{$git->{dir}} = 1; - } - - # instruct client we're sending a file to put in this path - print "Created $checkout_path/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "\n"; - - print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n"; + print $state->{CVSROOT} . "/$module/" . ( defined ( $git->{dir} ) and $git->{dir} ne "./" ? $git->{dir} . "/" : "" ) . "$git->{name}\n"; # this is an "entries" line print "/$git->{name}/1.$git->{revision}///\n"; From cdb6760e6f4ba956604d715df191b6f442238d5d Mon Sep 17 00:00:00 2001 From: Martin Langhoff Date: Sat, 4 Mar 2006 17:47:22 +1300 Subject: [PATCH 3/3] cvsserver: better error messages We now have different error messages when the repo is not found vs repo is not configured to allow gitcvs. Should help users during initial checkouts. Signed-off-by: Martin Langhoff Signed-off-by: Junio C Hamano --- git-cvsserver.perl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 9da27231fb..b45079246a 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -139,8 +139,21 @@ sub req_Root $state->{CVSROOT} = $data; $ENV{GIT_DIR} = $state->{CVSROOT} . "/"; + unless (-d $ENV{GIT_DIR} && -e $ENV{GIT_DIR}.'HEAD') { + print "E $ENV{GIT_DIR} does not seem to be a valid GIT repository\n"; + print "E \n"; + print "error 1 $ENV{GIT_DIR} is not a valid repository\n"; + return 0; + } - foreach my $line ( `git-var -l` ) + my @gitvars = `git-var -l`; + if ($?) { + print "E problems executing git-var on the server -- this is not a git repository or the PATH is not set correcly.\n"; + print "E \n"; + print "error 1 - problem executing git-var\n"; + return 0; + } + foreach my $line ( @gitvars ) { next unless ( $line =~ /^(.*?)\.(.*?)=(.*)$/ ); $cfg->{$1}{$2} = $3;