Merge branch 'stable-6.5'
* stable-6.5: Ensure FileCommitGraph scans commit-graph file if it already exists Change-Id: I5218ff5214222c7d6d96e452cf427eea1f20c316
This commit is contained in:
commit
a30c1da323
|
@ -278,6 +278,7 @@ public void testGetCommitGraph() throws Exception {
|
||||||
ConfigConstants.CONFIG_COMMIT_GRAPH, true);
|
ConfigConstants.CONFIG_COMMIT_GRAPH, true);
|
||||||
db.getConfig().setBoolean(ConfigConstants.CONFIG_GC_SECTION, null,
|
db.getConfig().setBoolean(ConfigConstants.CONFIG_GC_SECTION, null,
|
||||||
ConfigConstants.CONFIG_KEY_WRITE_COMMIT_GRAPH, true);
|
ConfigConstants.CONFIG_KEY_WRITE_COMMIT_GRAPH, true);
|
||||||
|
db.getConfig().save();
|
||||||
|
|
||||||
// no commit-graph
|
// no commit-graph
|
||||||
ObjectDirectory dir = db.getObjectDatabase();
|
ObjectDirectory dir = db.getObjectDatabase();
|
||||||
|
@ -294,6 +295,13 @@ public void testGetCommitGraph() throws Exception {
|
||||||
assertTrue(dir.getCommitGraph().isPresent());
|
assertTrue(dir.getCommitGraph().isPresent());
|
||||||
assertEquals(1, dir.getCommitGraph().get().getCommitCnt());
|
assertEquals(1, dir.getCommitGraph().get().getCommitCnt());
|
||||||
|
|
||||||
|
// get commit-graph in a newly created db
|
||||||
|
try (FileRepository repo2 = new FileRepository(db.getDirectory())) {
|
||||||
|
ObjectDirectory dir2 = repo2.getObjectDatabase();
|
||||||
|
assertTrue(dir2.getCommitGraph().isPresent());
|
||||||
|
assertEquals(1, dir2.getCommitGraph().get().getCommitCnt());
|
||||||
|
}
|
||||||
|
|
||||||
// update commit-graph
|
// update commit-graph
|
||||||
commitFile("file2.txt", "content", "master");
|
commitFile("file2.txt", "content", "master");
|
||||||
gc.gc().get();
|
gc.gc().get();
|
||||||
|
|
|
@ -85,10 +85,10 @@ private static final class GraphSnapshot {
|
||||||
private final CommitGraph graph;
|
private final CommitGraph graph;
|
||||||
|
|
||||||
GraphSnapshot(@NonNull File file) {
|
GraphSnapshot(@NonNull File file) {
|
||||||
this(file, FileSnapshot.save(file), null);
|
this(file, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphSnapshot(@NonNull File file, @NonNull FileSnapshot snapshot,
|
GraphSnapshot(@NonNull File file, FileSnapshot snapshot,
|
||||||
CommitGraph graph) {
|
CommitGraph graph) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.snapshot = snapshot;
|
this.snapshot = snapshot;
|
||||||
|
@ -104,7 +104,7 @@ GraphSnapshot refresh() {
|
||||||
// commit-graph file didn't exist
|
// commit-graph file didn't exist
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (!snapshot.isModified(file)) {
|
if (snapshot != null && !snapshot.isModified(file)) {
|
||||||
// commit-graph file was not modified
|
// commit-graph file was not modified
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue