]> source.dussan.org Git - jgit.git/commitdiff
CommitGraphWriter: throw exception on unknown chunk 61/204061/2
authorIvan Frade <ifrade@google.com>
Fri, 1 Sep 2023 18:25:50 +0000 (11:25 -0700)
committerIvan Frade <ifrade@google.com>
Fri, 1 Sep 2023 18:39:40 +0000 (11:39 -0700)
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

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java

index c5cfe95864a854ad3469c630d1116fb388ebef4f..bab262231f69682d18ab67a371a634452e715280 100644 (file)
@@ -222,6 +222,9 @@ public class CommitGraphWriter {
                                }
                                chunk.data.get().writeTo(out);
                                break;
+                       default:
+                               throw new IllegalStateException(
+                                               "Don't know how to write chunk " + chunkId); //$NON-NLS-1$
                        }
                }
        }