问题
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