1

I am in the process of moving all of our projects from Subversion to Git. For projects that did not need to retain any branches, I have had success using git-svn in a manner that purposely ignored all branches & tags.

I am now using the "KDE Version" of svn2git (a.k.a. svn-all-fast-export) to work on a couple of Svn repos where branches must be carried forward.

To prepare for the conversion, I created a dmp file:

svnadmin create /opt/csvn/data/repositories/svnrepo
svnrdump https://<serverurl>/svn/thisproject > svn.dump      # Has branches, tags, trunk structure
svnadmin load /opt/csvn/data/repositories/svnrepo < svn.dump

My svn list file:///opt/csvn/data/repositories/v2_cleaned/ shows the directories branches, tags & trunk as expected.

My rules file:

create repository testrepo
end repository

match /trunk/
    repository testrepo
    branch master
end match

match /branches/manufacturing/
    repository testrepo
    branch manufacturing
end match

# Ignore all other directories
match /
end match

Then, I ran the conversion from a directory that contains other working repositories (including svn2git & kde-ruleset):

./svn2git/svn-all-fast-export --debug-rules --identity-map=./Authors.map --rules=./Conversions/v2togit/rules-file --stats --add-metadata /opt/csvn/data/repositories/svnrepo/

The conversion finished extremely fast, in less than a minute...

My problem:

If I cd into the testrepo directory and run "git branch", it shows *master and manufacturing, which per my rules file above seems fine.

However if run "git status", or "git checkout manufacturing" I receive the message:

fatal; this operation must be run in a work tree

Looking at the directory tree of the repository, there is no .git directory, nor are the expected files and directories of "trunk" present. Also when comparing the contents of other Git repositories, the contents of the "good" .git directory seem to be present at the top level of this directory.

I tried manually creating .git and moving things into it to match "good" repos, but that didn't help.

It seems I missed a step or perhaps am not invoking svn-all-fast-export with the correct incantation.

Version information:

  • Ubuntu 21-10 VM
  • svn, version 1.14.1 (r1886195)
  • git, version 2.32.0
  • KDE svn2git version of yesterday when I cloned and built it.

And these migrations are intended to be one-time conversions, have no interest in supporting the Svn OR Git workflow that I have read about (I have enough nightmares already).

Thank you in advance.

Christian
  • 4,902
  • 4
  • 24
  • 42
zemog
  • 11
  • 2
  • Welcome to SO! Not sure what your question is. Maybe https://stackoverflow.com/questions/9262801/fatal-this-operation-must-be-run-in-a-work-tree helps you. Read [how to ask](https://stackoverflow.com/help/how-to-ask) and shorten your question text, describing the expected and current behavior. – Christian Jun 14 '22 at 23:12
  • 1
    Point taken, I was being verbose to hopefully avoid requests for details, but apparently buried the intent. However, the post being titled "svn2git/svn-all-fast-export not creating .git directory" is a summary of the intended question. – zemog Jun 15 '22 at 21:58
  • 1
    In my Svn -> Git journey, other tools (reposurgeon & git-svn) created a .git directory that allowed using git set remote xxxxxx, then pushing it directly to our Git server. The svn2git implementation I described above did not, making the output rather useless. Can someone spot a correction above that WILL result in a valid git repo? – zemog Jun 15 '22 at 22:07
  • OK, fair enough - I have slightly changed the formatting. Interesting topic though - have you seen this issue about the identity map file? https://github.com/svn-all-fast-export/svn2git/issues/52 - are there any logs that indicate an issue? – Christian Jun 15 '22 at 22:30
  • If the expected trunk files and directories are not there, there must have been a problem during conversion, no? From https://github.com/svn-all-fast-export/svn2git: Sample usage with input mounted in /tmp and output produced in /workdir: [...] svn2git/svn-all-fast-export --identity-map /tmp/conf/project1.authors --rules /tmp/conf/project1.rules --add-metadata --svn-branches --debug-rules --svn-ignore --empty-dirs /tmp/svn/ – Christian Jun 15 '22 at 22:44
  • The first issue you noted above seemed to be related to improper author mapping, which seems to be OK in my case. There are log files created during the run, but a review of them didn't show any clues. Oddly enough, although the files that would be at the top level of the "master" are not shown, "svn log" seems to work fine and shows what appears to be the expected log information including correct Author: entries throughout. Odder still, "gitk --all &" shows proper history for master & the branch with proper branch origin point. Still searching... – zemog Jun 16 '22 at 21:36

1 Answers1

1

Sounds like you try to operate on the bare repository that the tool generates.

Try git clone /path/to/your/output/testrepo testrepo-working_dir first and work with the cloned repository

Dbin
  • 11
  • 1
  • Thank you, that made it an easy fix. I had not considered using git as "file based" as with svn list file:///xyz, but now seems obvious. For reference to others encountering the same issue, after the local clone you proposed above, I was able to cd into the new repo, git fetch, git branch --track mybranch origin/mybranch, git remote set-url origin URL, git push -u origin --all and everything was available on the server. – zemog Jun 17 '22 at 15:03