From 13c8dacae55b8719d228b303570c369231f7c1c1 Mon Sep 17 00:00:00 2001 From: Ivan Frade Date: Fri, 1 Sep 2023 11:25:50 -0700 Subject: [PATCH] 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 --- .../jgit/internal/storage/commitgraph/CommitGraphWriter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java index c5cfe9586..bab262231 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java @@ -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$ } } }