0

I am currently trying to move a couple of projects from svn to git using git-svn. No matter which project I am trying to convert, there are many more svn revisions than git commits. I don't really know svn, so I have a hard time figuring out why that happens.

I have basically followed this guide for conversion. The loss on the way ranged from 18 revisions to 9 commits up to from 131 revisions to 10 commits in git. This happened in projects with many branches as well as ones without any branches.

So far I have tried using the option --stdlayout (Missing revisions after "git svn clone"). I have also tried using svn2git, however that failed as well, likely because my projects don't seem to have the infrastructure svn2git requires (format and db files are missing). I guess I will eventually find a way to do this by using any of the other tools available (like this) but I would just really like to know why this happens.

So: Does anyone know why so many revisions are not shown in the commit history when using git-svn for converting svn repositories to git? Is git-svn just buggy or are there some revision types which just aren't shown in a git commit history?

Update

I have since found out that svn log - contrary to git log - shows all revisions in the history, not just the ones to trunk/master. This means that many of the revisions I thought were missing, were actually just in branches. However, even so, not all revisions are in the commit history. The ones that are missing are those which are shown when calling svn log e.g. inside \branches (but not inside one of the branches). git-svn does probably not import them because they affect neither master nor any of the branches. While this is clear to me now, I'm still somewhat at a loss as to the significance of this. Are those revisions important or is the git history fine without them?

Update 2

The .git/config file

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    ignorecase = true
[svn-remote "svn"]
    noMetadata = 1
    url = svn://TheURL/TheRepository
    fetch = trunk:refs/remotes/svn/trunk
    branches = branches/*:refs/remotes/svn/*
    tags = tags/*:refs/remotes/svn/tags/*
[svn]
    authorsfile = /a/file/path/svn/authors-transform.txt
[remote "origin"]
    url = https://github.com/User/TheRepository.git
    fetch = +refs/heads/*:refs/remotes/origin/*

The file structure:

TheRepository
|
+--branches
|  |
|  +--branchA
|  |
|  +--Readme_branch.txt
|
+--trunk
|
+--tags
Maria H.
  • 41
  • 6
  • 1
    When you say that revisions are missing, you mean from a single branch? Like a branch has 30 revisions and only 10 revisions end up on git? Or it's whole branches that are missing? – eftshift0 May 16 '19 at 13:02
  • Most prominently they are missing from the trunk/master. And yes, all the branches are there, but some revisions are missing. – Maria H. May 16 '19 at 13:10
  • 1
    In my experiencia, git-svn does a more than heroic effort at tracking revisions that make up the history of a branch. Let's try to dig. Can you provide in the question the content of the svn-related stuff in .git/config? Then, list the branches related to svn on your repo, then show us a revision on svn that is missing from git? List the metadata and the files that changed (paths from the root of the repo, that is). – eftshift0 May 16 '19 at 13:24
  • I hope I updated my question in such a way that this is clearer even without providing metadata and .git/config. If not, I'm happy to provide it :) – Maria H. May 17 '19 at 12:15
  • Those revisions that are not related to your branches, what are they related to? – eftshift0 May 17 '19 at 13:10
  • Mostly the creation of the folders themselves and subfolders. So e.g. in `\branches` there is one which created `\branches` and one for the creation of each branch etc. Apart from them mostly creation of readmes. The readmes get lost in the conversion process. – Maria H. May 17 '19 at 13:25
  • Well.... creation of branches and directories.... creation of branches should be picked up by git-svn....an empty revision on the history of the branch that got created there. Creation of directories inside branches? That won't be caught by git.... but the revision should also be picked up by git. Readmes are lost? Why? The path where they are created is tracked in .git/config? – eftshift0 May 17 '19 at 13:37
  • I added the file structure. `readme_branch` gets lost. My guess is because its neither within the trunk nor within any of the branches. – Maria H. May 17 '19 at 13:59
  • Hmm.... but that branch gets merged into any of the other branches at one point? If it's _not_ merged on svn and it's just a branch sitting on a non-standard location of the repo, if you want to pick it up, you could add a 'fetch' line with the location of the branch and the name of the branch that you want on svn (there will be a line already for trunk set up on the file so take that as a guide, add a second fetch line and then run `git svn fetch` without providing revisions so that you don't lose anything from that branch) – eftshift0 May 17 '19 at 14:17
  • Just saw you posted the .config. On that configuration, Readme_branch should be picked up. Weird. – eftshift0 May 17 '19 at 14:19
  • Sorry, that was misleading. readme_branch is a txt file – Maria H. May 17 '19 at 14:29
  • Oh! Ok... that makes sense now. Well... you got all that gi-svn will be able to pick up. I would _not_ recommend to add a "fetch" line for branches directory of svn... that's a recipe for disaster. – eftshift0 May 17 '19 at 14:34

1 Answers1

0

So today I learnt (with many thanks to eftshift0):

1. svn log and git log show different things

svn log will return all revisions done to any subdirectories you are currently in. So if you're in the root directory, it will show all changes made to all branches, the trunk and tags. This is unlike git log which only shows the commits done to the branch you're currently on. This might seem obvious if you know svn, but I didn't, so...

2. What --stdlayout does

Specifying --stdlayout means that git-svn will only incorporate files and revisions done either within trunk, branches or tags. Inside branches and tags it only picks up the branches and tags (that is, directories), so if for some reason there are additional files in branches (but not in any of the actual branches), these won't be in the git repository. This also means that revisions related to these files will not be turned into commits.

These two facts were the reasons why the commits I had differed from the revisions. I hope this information will be useful to someone else one day :)

Maria H.
  • 41
  • 6