All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Ericsson <ae@op5.se>
To: Eric Wong <normalperson@yhbt.net>
Cc: Adrian Wilkins <adrian.wilkins@gmail.com>, git@vger.kernel.org
Subject: Re: BUG: git-svn does not escape literal backslashes in author names.
Date: Sun, 18 Nov 2007 00:17:13 +0100	[thread overview]
Message-ID: <473F7679.4010901@op5.se> (raw)
In-Reply-To: <20071117204348.GA16333@muzzle>

Eric Wong wrote:
> Adrian Wilkins <adrian.wilkins@gmail.com> 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@op5.se>
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@op5.se>
---
 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@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

      reply	other threads:[~2007-11-17 23:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12 14:28 BUG: git-svn does not escape literal backslashes in author names Adrian Wilkins
2007-11-17 20:18 ` BUG in gitk (was: Re: BUG: git-svn does not escape literal backslashes in author names.) Benoit Sigoure
2007-11-17 20:43 ` BUG: git-svn does not escape literal backslashes in author names Eric Wong
2007-11-17 23:17   ` Andreas Ericsson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=473F7679.4010901@op5.se \
    --to=ae@op5.se \
    --cc=adrian.wilkins@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.