Re: BUG: git-svn does not escape literal backslashes in author names.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric Wong wrote:
Adrian Wilkins <adrian.wilkins@xxxxxxxxx> wrote:

Can I suggest that you make the authors file compulsory by default as well?

Not going to happen.  I personally _hate_ having to track down author
information and make an authors file, and I suspect many others feel the
same.  I've never used this feature in git-svn on any real repository.


I wholeheartedly agree. One thing that could be improved in this area though
is to do what git-cvsimport does, and stash the authors file in $GIT_DIR and
re-read it on every invocation. I've forgotten to add that -A switch numerous
times when fetching incrementally and it always annoys me enormously.

Something like this, perhaps? It needs checking. My perl is.. well, you can
see for yourselves, and unfortunately I have no possibility to test this
until monday when I'm back on a sane link. It should work as a starting
point though. It applies cleanly on top of current next.

---%<---%<---%<---
From: Andreas Ericsson <ae@xxxxxx>
Subject: git svn: Cache author info in $GIT_DIR/author-cache

git-cvsimport does it, so it's reasonable that git-svn users
expect the same functionality. It's also damn convenient.

Signed-off-by: Andreas Ericsson <ae@xxxxxx>
---
Documentation/git-svn.txt |    3 +++
git-svn.perl              |   25 +++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 488e4b1..446a7d7 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -276,6 +276,9 @@ committer name that does not exist in the authors-file, git-svn
will abort operation. The user will then have to add the
appropriate entry.  Re-running the previous git-svn command
after the authors-file is modified should continue operation.
+For convenience, this data is saved to $GIT_DIR/author-cache
+each time the '-A' option is provided and read from that same
+file each time git-svn is run.

config key: svn.authorsfile

diff --git a/git-svn.perl b/git-svn.perl
index e3e00fd..0a989ed 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -14,6 +14,7 @@ my $cmd_dir_prefix = eval {
       command_oneline([qw/rev-parse --show-prefix/], STDERR => 0)
} || '';

+my $author_cache;
my $git_dir_user_set = 1 if defined $ENV{GIT_DIR};
$ENV{GIT_DIR} ||= '.git';
$Git::SVN::default_repo_id = 'svn';
@@ -203,7 +204,6 @@ exit 1 if (!$rv && $cmd && $cmd ne 'log');
usage(0) if $_help;
version() if $_version;
usage(1) unless defined $cmd;
-load_authors() if $_authors;

# make sure we're always running
unless ($cmd =~ /(?:clone|init|multi-init)$/) {
@@ -226,6 +226,14 @@ unless ($cmd =~ /(?:clone|init|multi-init)$/) {
               $ENV{GIT_DIR} = $git_dir;
       }
}
+
+$author_cache = $ENV{GIT_DIR} . "/author-cache";
+load_authors($_authors) if $_authors;
+unless ($cmd =~ /(?:clone|init|multi-init)$/) {
+       -f $author_cache and load_authors($author_cache);
+       write_author_cache();
+}
+
unless ($cmd =~ /^(?:clone|init|multi-init|commit-diff)$/) {
       Git::SVN::Migration::migration_check();
}
@@ -297,6 +305,8 @@ sub do_git_init_db {
               command_noisy('config', "$pfx.$i", $icv{$i});
               $set = $i;
       }
+
+       write_author_cache() if %users;
}

sub init_subdir {
@@ -900,7 +910,8 @@ sub file_to_s {

# '<svn username> = real-name <email address>' mapping based on git-svnimport:
sub load_authors {
-       open my $authors, '<', $_authors or die "Can't open $_authors $!\n";
+       my ($file) = @_;
+       open my $authors, '<', $file or die "Can't open $file $!\n";
       my $log = $cmd eq 'log';
       while (<$authors>) {
               chomp;
@@ -915,6 +926,16 @@ sub load_authors {
       close $authors or croak $!;
}

+sub write_author_cache {
+       open my $f, '>', $author_cache
+         or die "Can't open author cache $author_cache for writing: $!\n";
+       foreach (keys %users) {
+               print $f "$_=$users{$_}[0] <$users{$_}[1]>\n";
+       }
+
+       close $f or croak $!;
+}
+
# convert GetOpt::Long specs for use by git-config
sub read_repo_config {
       return unless -d $ENV{GIT_DIR};
--
1.5.3.5.1527.g6161
---%<---%<---%<---

--
Andreas Ericsson                   andreas.ericsson@xxxxxx
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux