[RFC] Batched low level index operations
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- csharp, git
- Ambito
- backend-api-design
Direzione di ricerca
Leggete prima PR #907 e gli entry point esistenti Index.Add() e Index.Remove(). Confrontate l’API proposta di Index.Update/IndexUpdater con il requisito che il repository rimanga coerente tra le chiamate; considerare il lavoro completato richiederebbe un design approvato da un maintainer e un ambito di implementazione definito, che questo RFC non fornisce ancora.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In the light of https://github.com/libgit2/libgit2sharp/pull/907, I was wondering if we should take this approach one step further.
Each call to repo.Stage() will
- Perform a diff between the working directory and the Index in order to determine what additions/removals should be promoted to the staging area
- Perform additions/deletions in the in memory Index
- Eventually persist the in memory Index to the disk
Each call to repo.Index.Add() (or Remove()) will
- Perform an addition (or a deletion) in the in memory Index
- Persist the in memory Index to the disk
As such, invoking repo.Index.Add() or repo.Index.Remove() will be more efficient than a call to repo.Stage().
We want to allow the user to switch to the command line git.git, between each call to LibGit2Sharp, and find the repository in a coherent state. This is the requirement that compels us to persist the in-memory Index at the very end of each Index related method.
However, would clients of the library require to perform many sequential calls to the lower level methods repo.Index.Add()|Remove(), the Index would be persisted as part of each call. Which may not be very efficient.
Considering this above, would a need for an IndexUpdater exist?
We may expose something like in the Index type:
public virtual void Update(params Action<IndexUpdater>[] actions)
which would allow the client to write such code:
repo.Index.Update(i => i.Add(path), i => i.Remove(otherPath))
Or even some more elaborate custom thingies such as
private void StageAllAdditionsRemovalsAndModifications(IRepository repo)
{
// Compare the Workdir against the Index without attempting at detecting Copies/Renames
var changes = repo.Diff.Compare<TreeChanges>(null, true,
compareOptions: new CompareOptions { Similarity = SimilarityOptions.None });
repo.Index.Update(i =>
{
// We first clean the Index from unwanted entries...
foreach (TreeEntryChanges treeEntryChanges in changes
.Where(tec => tec.Status == ChangeKind.Deleted))
{
i.Remove(treeEntryChanges.Path);
}
// ...then insert in the Index the additions/modifications.
foreach (TreeEntryChanges treeEntryChanges in changes
.Where(tec => tec.Status == ChangeKind.Added || tec.Status == ChangeKind.Modified))
{
i.Add(treeEntryChanges.Path);
}
});
}
And allow us to only persist the Index only once, when all the actions have been performed by the IndexUpdater.
Thoughts?
- Lingua principale
- C#
- Stelle
- 3.5k
- Fork
- 925
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di libgit2/libgit2sharp
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
libgit2/libgit2sharp#2193 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
libgit2/libgit2sharp#2192 · 1 commento ·
-
Website is down Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
libgit2/libgit2sharp#2191 · 2 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
libgit2/libgit2sharp#2189 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
libgit2/libgit2sharp#2187 · 2 commenti ·
Tutte le issue di libgit2/libgit2sharp
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
azurenoops/spin_agent#975 ·
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SubtitleEdit/subtitleedit#15108 · 1 commento ·
-
area/docs-content Bug pulumi/docs
Difficoltà 1/5 1-3 ore Idoneità per principianti 94/100