From 280514e1dff3284549175cb0e8edb9b796e8891e Mon Sep 17 00:00:00 2001 From: Fabian Emmes Date: Fri, 2 Jan 2009 16:40:13 +0100 Subject: [PATCH 1/2] cvsserver: add option to configure commit message cvsserver annotates each commit message by "via git-CVS emulator". This is made configurable via gitcvs.commitmsgannotation. Signed-off-by: Fabian Emmes Signed-off-by: Lars Noschinski Signed-off-by: Junio C Hamano --- Documentation/config.txt | 4 ++++ git-cvsserver.perl | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 52786c7df5..b4e0eea9f7 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -723,6 +723,10 @@ gc.rerereunresolved:: kept for this many days when 'git-rerere gc' is run. The default is 15 days. See linkgit:git-rerere[1]. +gitcvs.commitmsgannotation:: + Append this string to each commit message. Set to empty string + to disable this feature. Defaults to "via git-CVS emulator". + gitcvs.enabled:: Whether the CVS server interface is enabled for this repository. See linkgit:git-cvsserver[1]. diff --git a/git-cvsserver.perl b/git-cvsserver.perl index b0a805c688..cbcaeb44e4 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -1358,7 +1358,13 @@ sub req_ci # write our commit message out if we have one ... my ( $msg_fh, $msg_filename ) = tempfile( DIR => $TEMP_DIR ); print $msg_fh $state->{opt}{m};# if ( exists ( $state->{opt}{m} ) ); - print $msg_fh "\n\nvia git-CVS emulator\n"; + if ( defined ( $cfg->{gitcvs}{commitmsgannotation} ) ) { + if ($cfg->{gitcvs}{commitmsgannotation} !~ /^\s*$/ ) { + print $msg_fh "\n\n".$cfg->{gitcvs}{commitmsgannotation}."\n" + } + } else { + print $msg_fh "\n\nvia git-CVS emulator\n"; + } close $msg_fh; my $commithash = `git-commit-tree $treehash -p $parenthash < $msg_filename`; From d500a1ee8fe4424beb7a98e4fa6159677e7569d0 Mon Sep 17 00:00:00 2001 From: Fabian Emmes Date: Fri, 2 Jan 2009 16:40:14 +0100 Subject: [PATCH 2/2] cvsserver: change generation of CVS author names CVS username is generated from local part email address. We take the whole local part but restrict the character set to the Portable Filename Character Set, which is used for Unix login names according to Single Unix Specification v3. This will obviously report different usernames from existing repositories for commits with the local part of the author e-mail address that contains characters outside the PFCS. Hopefully this won't break an old CVS checkout from an earlier version of git-cvsserver, because the names are always shown afresh to the CVS clients and not kept on the client side. Signed-off-by: Fabian Emmes Signed-off-by: Lars Noschinski Signed-off-by: Junio C Hamano --- git-cvsserver.perl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/git-cvsserver.perl b/git-cvsserver.perl index cbcaeb44e4..fef7faf339 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -2533,12 +2533,18 @@ sub open_blob_or_die return $fh; } -# Generate a CVS author name from Git author information, by taking -# the first eight characters of the user part of the email address. +# Generate a CVS author name from Git author information, by taking the local +# part of the email address and replacing characters not in the Portable +# Filename Character Set (see IEEE Std 1003.1-2001, 3.276) by underscores. CVS +# Login names are Unix login names, which should be restricted to this +# character set. sub cvs_author { my $author_line = shift; - (my $author) = $author_line =~ /<([^>@]{1,8})/; + (my $author) = $author_line =~ /<([^@>]*)/; + + $author =~ s/[^-a-zA-Z0-9_.]/_/g; + $author =~ s/^-/_/; $author; }