diff options
author | Miguel Molina <miguel@erizocosmi.co> | 2018-08-01 09:07:47 +0200 |
---|---|---|
committer | Miguel Molina <miguel@erizocosmi.co> | 2018-08-01 11:07:34 +0200 |
commit | b173cc03edd25af3e868d83037168663ef84a329 (patch) | |
tree | 1fe466ab40e697139a917f4ed4ed7099424a57be /plumbing/format/idxfile/writer.go | |
parent | d314e86c179f755ca9c92c60d6b0aedd9f568767 (diff) | |
parent | 6f7fc05543861ee074aa17f75e1d1b5c1b948d48 (diff) | |
download | go-git-b173cc03edd25af3e868d83037168663ef84a329.tar.gz |
Merge pull request #907 from erizocosmico/feature/fix-tests
plumbing: packfile, fix package tests
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
Diffstat (limited to 'plumbing/format/idxfile/writer.go')
-rw-r--r-- | plumbing/format/idxfile/writer.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plumbing/format/idxfile/writer.go b/plumbing/format/idxfile/writer.go index efcdcc6..a22cf16 100644 --- a/plumbing/format/idxfile/writer.go +++ b/plumbing/format/idxfile/writer.go @@ -25,6 +25,7 @@ type Writer struct { offset64 uint32 finished bool index *MemoryIndex + added map[plumbing.Hash]struct{} } // Index returns a previously created MemoryIndex or creates a new one if @@ -45,7 +46,15 @@ func (w *Writer) Add(h plumbing.Hash, pos uint64, crc uint32) { w.m.Lock() defer w.m.Unlock() - w.objects = append(w.objects, Entry{h, crc, pos}) + if w.added == nil { + w.added = make(map[plumbing.Hash]struct{}) + } + + if _, ok := w.added[h]; !ok { + w.added[h] = struct{}{} + w.objects = append(w.objects, Entry{h, crc, pos}) + } + } func (w *Writer) Finished() bool { |