Best way to do parallel stages?

為{幸葍}努か 提交于 2019-11-30 18:24:38

问题


I want to stage files in parallel and commit into different branches concurrently.

There will be multiple access at the same time. The repo.Index.Stage/repo.Commit API works on the same current directory so I think this is out of the question.

Can you guys give me some tips on how this might be achievable? A general idea?


回答1:


From a feasibility perspective, I can think of two different options:

Considering the "stage files in parallel" as a constraint

The word "staging" in git parlance implies the use of the index.

In order to stage in files in parallel, one could open many repository instances, each of them accepting a different pair of Working Directory/Index. All of them creating objects in the same object database.

This can be achieved thanks to the optional RepositoryOptions parameter of the Repository constructor.

See this this test in order to get a first glimpse at how this is achievable.

Alternate proposal, Barebone Edition

Another option is to not use the index and create objects directly in the object database. However, this means that nothing would be "staged", and that Blobs, Trees and Commits would have to created by hand.

A lower level API allows such kind of manipulations. This API would even allow one to "commit" against a bare repository.

See the ObjectDatabaseFixture and TreeDefinitionFixture test suites for more information about how to achieve this.

This API will only create objects in the database. You will have to update the tip of the branches by yourself. This can be achieved thanks to the Repo.Refs.Add() and Repo.Refs.UpdateTarget() methods.



来源:https://stackoverflow.com/questions/16241860/best-way-to-do-parallel-stages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!