Git svn clone with author name like “/CN=myname”

I’m trying to switch from svn to git on windows 7 using git svn clone command.

On one of my repository I try this:

git svn clone --stdlayout --no-metadata -A users.txt --username=/CN=john https://path/to/my/repo ./

Here is my users.txt file:

/CN=john = John Doe <john.doe@myself.com>

When I git svn clone nothing was displayed just like if everything was ok but no file were cloned. So in C:/Users/John/.suversion/servers I’ve set neon-debug-mask = 256 to display log errors.

My error is now displayed: Author: /CN=john not defined in users.txt file so I think since there is an equal in my username the git clone command can’t properly parse the datas.

I’ve tried escaping /CN\=john and quoting '/CN=john' "/CN=john" but nothing seems to work.

Does anyone have an idea for the good way to handle this?

Thank you

  • Files in gitignore
  • Git move from SVN: Where does git 2.6 store svn tracking branches?
  • How to use git-svn as intermediate review tool for a SVN repository?
  • git-svn, how to use a directory in trunk as local trunk
  • Map of all svn revision numbers <=> git SHA-1 commit hashes
  • Is it better to use merge or rebase when two people are on the same remote feature branch and having conflicts that will be dcommitted to svn
  • Git SVN Is Unable to Fetch from SVN Repository
  • Using git-svn, if I have multiple commits not in svn, how do I only push selected commits to svn?
  • 4 Solutions collect form web for “Git svn clone with author name like “/CN=myname””

    git-svn cannot currently handle SVN users which have an equals sign “=” in their usernames.

    Here is the relevant code from inside git-svn:

    # '<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 $log = $cmd eq 'log';
                while (<$authors>) {
                                chomp;
                                next unless /^(.+?|\(no author\))\s*=\s*(.+?)\s*<(.+)>\s*$/;
                                my ($user, $name, $email) = ($1, $2, $3);
                                if ($log) {
                                                $Git::SVN::Log::rusers{"$name <$email>"} = $user;
                                } else {
                                                $users{$user} = [$name, $email];
                                }
                }
                close $authors or croak $!;
    }
    

    … as you can see, the regex used to extract usernames from the file will consider only text up to the first “=” as part of the SVN username. Everything after that is considered part of the git username.

    This is a bug in git-svn.

    Possible workarounds off the top of my head:

    • I think the first .+? in that regex should be greedy, and the last .+ non-greedy, i.e. next unless /^(.+|\(no author\))\s*=\s*(.+?)\s*<(.+?)>\s*$/;
      • You could submit a fix patch to the git project?
      • You could patch your local git scripts for now, and include that in your project’s setup instructions
    • You could alias the git svn command to include --authors-prog option each time, in your .bash_profile?
    • Can you get a perl script to be run before each git-svn command? If so, you could write perl code which sets $Git::SVN::Log::rusers or $users{$user} directly?

    I had a similar problem. The best workaround I found was to use the --authors-prog option to specify a script converts the svn username eg.

    #!/usr/bin/perl
    
    $svnAuthor = $ARGV[0];
    if ($svnAuthor =~ /^.*?emailAddress=(.*?)\/CN=(.*?)\/.*$/) {
        print "$2 <$1>";
    } else {
         print $svnAuthor;
    

    }

    This can be set using

    git config svn.authors-prog <authorScript>  
    

    I’ve finally found a solution by not using users.txt.

    First I do a git svn clone -s https://path/to/my/repo ./ which clone every files from the repository.

    Now if I do a git log I’ve got ugly name and mails for every users and I want to clean that. I’ve simply used this gist which does a git filter-branch --env-filter and search & replace authors and mails by the one you provide in the gist.

    Beware of this solution because it has to crawl each commit in your repository and you have to launch the script for each branch of your repository.

    Hope it helps!

    My solution was to (temporarily) patch git-svn’s load_authors subroutine so the regex pattern had \s=\s instead of \s*=\s*. Then, I just made sure that all the lines in my authors file had exactly one space surrounding my equals sign on each side. This worked for me, because none of the equals signs in the old usernames had spaces on both sides.

    Git Baby is a git and github fan, let's start git clone.