]> source.dussan.org Git - jgit.git/commit
Expose the ObjectInserter that created an ObjectReader 59/71359/4
authorDave Borowitz <dborowitz@google.com>
Mon, 25 Apr 2016 17:36:46 +0000 (13:36 -0400)
committerDave Borowitz <dborowitz@google.com>
Tue, 26 Apr 2016 21:21:37 +0000 (17:21 -0400)
commitadff322a698b2f248180c0a2c81dbeaf50015420
treeaedb49013427eda5c909318842671fbc5326c574
parent8a26d0577f0c5eb391d82fefec1a52c2d69bdee6
Expose the ObjectInserter that created an ObjectReader

We've found in Gerrit Code Review that it is common to pass around
both an ObjectReader (or more commonly a RevWalk wrapping one) and an
ObjectInserter. These code paths often assume that the ObjectReader
can read back any objects created by the ObjectInserter without
flushing. However, we previously had no way to enforce that constraint
programmatically, leading to hard-to-spot problems.

Provide a solution by exposing the ObjectInserter that created an
ObjectReader, when known. Callers can either continue passing both
objects and check:
  reader.getCreatedFromInserter() == inserter
or they can just pass around ObjectReader and extract the inserter
when it's needed (checking that it's not null at usage time).

Change-Id: Ibbf5d1968b506f6b47030ab1b046ffccb47352ea
org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/ObjectDirectoryInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCursor.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectInserter.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ObjectReader.java