ConfigConstants.CONFIG_COMMIT_GRAPH, true);
db.getConfig().setBoolean(ConfigConstants.CONFIG_GC_SECTION, null,
ConfigConstants.CONFIG_KEY_WRITE_COMMIT_GRAPH, true);
+ db.getConfig().save();
// no commit-graph
ObjectDirectory dir = db.getObjectDatabase();
assertTrue(dir.getCommitGraph().isPresent());
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
commitFile("file2.txt", "content", "master");
gc.gc().get();
private final CommitGraph graph;
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) {
this.file = file;
this.snapshot = snapshot;
// commit-graph file didn't exist
return this;
}
- if (!snapshot.isModified(file)) {
+ if (snapshot != null && !snapshot.isModified(file)) {
// commit-graph file was not modified
return this;
}