Greg
Greg

Reputation: 12847

Author not defined when importing SVN repository into Git

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 <[email protected]>

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.

Upvotes: 54

Views: 22269

Answers (10)

DuongTC
DuongTC

Reputation: 29

None of above solution work for me. But remove the authors make it works:

svn2git svn://<hosts>/path/to/repo --username <username>

Or run below commands (for my case):

git svn init --prefix=svn/ --username='<username>' --no-metadata --trunk='trunk' --tags='tags' --branches='branches' svn://<hosts>/path/to/repo
git svn fetch

Upvotes: 0

Svend Hansen
Svend Hansen

Reputation: 3333

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

Upvotes: 4

Hyryel
Hyryel

Reputation: 1

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

Upvotes: 0

Naeem Gittham
Naeem Gittham

Reputation: 11

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.

Upvotes: 1

Fizz
Fizz

Reputation: 3487

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 protected]> which showed just fine in Notepad. Although when opened in Notepad++ I noticed that it was formatted the following way:

john =
John <[email protected]>

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

Upvotes: 1

Stephane
Stephane

Reputation: 3402

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.

Upvotes: 17

Add
Add

Reputation: 11

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.

Upvotes: 1

Oscar Montoya
Oscar Montoya

Reputation: 305

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;[email protected]&#8250;
user1 = User1 Lastname1 &#8249;[email protected]&#8250;
user2 = User2 Lastname2 &#8249;[email protected]&#8250;

For instance this format won't work:

user1 = [email protected]

Upvotes: 7

Daniel Lemke
Daniel Lemke

Reputation: 2459

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.

Upvotes: 54

Greg
Greg

Reputation: 12847

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".

Upvotes: 2

Related Questions