hraban / tomono

Multi- To Mono-repository merge
https://tomono.0brg.net
GNU Affero General Public License v3.0
842 stars 138 forks source link

packed-refs are ignored when listing remote branches #32

Closed scholzb-hb closed 2 years ago

scholzb-hb commented 5 years ago

The function remote-branches has a bug which may lead to missing branches and/or subtrees in the monorepo.

The file-based approach for listing all branches for a given remote does not consider packed-refs. The Git GC (garbage collector) may occasionally pack individual ref files into a single file named .git/packed-refs and remove them from the refs directory. Those refs will be ignored by tomono.

Further information:

For now we cannot provide any steps to reproduce, but it seems that the issue is related to the number and size of the repositories to process. In our case, we migrated ~100 single repositories with a total of ~125000 commits and ~1400 remote branches into a monorepo, when we detected that the content of a certain single repository was missing.

scholzb-hb commented 5 years ago

The same problem may occur when creating the namespaced tags. The tags within .git/packed-refs are ignored in this case.

pcentgraf commented 3 years ago

The easiest way to work around this is to disable gc-auto right after creating the new repository, like so:

git init --bare .git

# we don't want pack-refs to run and break our flow
git config gc.auto 0

Then at the end of the main function, re-enable gc.auto. I also recommend running a full GC to optimize the resulting monorepo.

# optimize the git storage files
git config --unset gc.auto
git gc --aggressive
hraban commented 2 years ago

This was fixed for branches but is still an issue for tags.