48

I'm trying to import our SVN repository into Git. When I run either this command:

git svn --authors-file=/path/to/authors --trunk=trunk clone https://my-repo/project .

or this command:

svn2git https://my-repo/project --no-minimize-url -v --authors /path/to/authors

Both return this error:

Author: patrick  not defined in /path/to/authors file

..but as far as I can tell, there is nothing wrong with my authors file:

$ grep patrick /path/to/authors
patrick = Patrick <none@example.com>

That error doesn't happen until it gets to revision 8700, so it must be grabbing the other author names correctly.

What could be going on here? Thanks.

Greg
  • 12,119
  • 5
  • 32
  • 34

9 Answers9

47

I've had the same issue when trying to execute this on Windows. It turned out that the encoding of the file that I stored the authors in was set to UTF-8 instead of UTF-8 without BOM. As the "with BOM" version adds some additional bytes to the beginning of the file, the first author in the list was never found.

Daniel Lemke
  • 1,966
  • 18
  • 24
  • 2
    Using BitBucket migration tool, that auto generates the authors.txt file. Over 2 years after your answer and the original question, I had the same problem. My file was encoded as UTF16LE for some reason. Changing it to UTf-8 without BOM did the trick and the converter is running atm. Thx! – Psychokiller1888 May 26 '17 at 18:42
  • 9
    On Windows, you can use Notepad++ to convert the file to UTF8 without BOM. Encoding -> Encode in UTF-8 (the simple one, without anything after is the one without BOM). – BogdanC Feb 01 '18 at 16:09
  • 1
    This works for me. I use `Visual Studio Code` > click the `UTF-16` at the bottom right > Save with Encoding > `UTF-8`. I tried Save to `UTF-8` on `Notepad` but it didn't work. – sky91 Oct 25 '19 at 06:40
  • 1
    The PowerShell statement saved it as UTF-16 BE BOM (as according to Notepad++) I resaved it as UTF-8 and that worked. – ahwm Oct 08 '21 at 21:46
17

I had the same problem but the cause was actually rather different: I used Powershell to dump the authors list from SVN and I didn't realized that it saved the result as a UTF-16 file.

It turned out git (at least, up to git for windows version 2.16.1) is unable to use UTF-16 files. Converting the file to UTF-8 did the trick for me.

Stephane
  • 3,173
  • 3
  • 29
  • 42
  • 3
    Exactly the same, thanks for pointing it out! Converted the file with `Notepad > File > Save As > Encoding: UTF-8` or `Notepad++ > Convert > Convert to UTF-8`. – Dan Dar3 Mar 31 '18 at 07:09
4

I had the same issue. The format of the authors.txt is strict with the form

svn name = user name &#8249;email&#8250;

as in:

cruise-control = Cruise Control &#8249;cruise-control@abc.com&#8250;
user1 = User1 Lastname1 &#8249;user1@abc.com&#8250;
user2 = User2 Lastname2 &#8249;user2@abc.com&#8250;

For instance this format won't work:

user1 = user1@abc.com
Termininja
  • 6,620
  • 12
  • 48
  • 49
Oscar Montoya
  • 177
  • 1
  • 8
4

I saw the same error, but for a different reason. I'll post my solution here as an "answer", as it might be the answer to other people who find this question (even if it isn't the solution/answer to OP's problem/question):

I was running the svn log from the checkout of the project. But I only had trunk checked out, so only authors who had committed changes to trunk were included. This was obviously most of the authors, so the clone would run for a long time (over 90 minutes) before it would crash with the error.

As checking out the entire project root wasn't a viable option (it has over 500 branches and tags, and a dump is over 600 GB), I found that I could just run the svn log on the remote repo like this:

svn log -q svn://server/path-to-project-root

The actual command also did some filtering and formatting of the output:

svn log -q svn://server-url/path-to-project-root | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
Svend Hansen
  • 3,277
  • 3
  • 31
  • 50
2

There were two problems:

I solved the first by assigning unique email addresses to each author.

Also, the username was "patrick ". I have no idea how that happened, but by using svnadmin I was able to change all instances of that nickname to just "patrick".

Greg
  • 12,119
  • 5
  • 32
  • 34
  • 1
    I had the same issue. It's definitely not a problem to have multiple accounts mapped to the same email address. I had multiple instances where SVN had the author with an extra space at the end. Removing that allowed the migration to proceed smoothly. – nopuck4you Oct 17 '12 at 22:30
1

Look for any empty spaces in the beginning of the Authors names and delete the spaces. If that does not help, try moving the author's name to the top of the file.

Add
  • 11
  • 1
1

I had the same error as the question and for my solution was extra newline or carriage return characters that were not showing up in Notepad. I had the entry john = John <email@example.com> which showed just fine in Notepad. Although when opened in Notepad++ I noticed that it was formatted the following way:

john =
John <email@example.com>

After I fixed this in Notepad++ to be a single line, it seemed to work fine for me.

Fizz
  • 3,427
  • 4
  • 27
  • 43
1

I have 2 users in the file one after the other and the encoding was set to Ucs-2 LE BOM by default. Changing the encoding to UTF-8 worked for me.

0

beware of your endlines. My file was in UTF-8, but the endlines was "mac style" although I was on Windows.

Now, with the good endlines (cr + lf) the file is accepted

Hyryel
  • 1