CommitGraphWriter: throw exception on unknown chunk

CommitGraphWriter first defines the chunks and then writes them. If at
write time a chunk is unknown, it is ignored. This is brittle: if
somebody adds a chunk to the header but not to the actual writing, the
commit-graph is broken and there is no error reported anywhere.

Throw exception if at write time a chunk is unknown. This can only
happen by a coding error in the writer.

Change-Id: Iade677bb6ce368b6941b75a21c622917afa3b751
This commit is contained in:
Ivan Frade 2023-09-01 11:25:50 -07:00
parent 2be8bf2b37
commit 13c8dacae5
1 changed files with 3 additions and 0 deletions

View File

@ -222,6 +222,9 @@ private void writeChunks(ProgressMonitor monitor,
}
chunk.data.get().writeTo(out);
break;
default:
throw new IllegalStateException(
"Don't know how to write chunk " + chunkId); //$NON-NLS-1$
}
}
}