{"record":{"id":"d2cbc0f85ab55bee","repo":"theonedev/onedev","slug":"commits-have-already-been-marked-as-start","errorCode":null,"errorMessage":"Commits have already been marked as start.","messagePattern":"Commits have already been marked as start\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java","lineNumber":1741,"sourceCode":"\tprotected void assertNotStarted() {\n\t\tif (isNotStarted())\n\t\t\treturn;\n\t\tthrow new IllegalStateException(\n\t\t\t\tJGitText.get().outputHasAlreadyBeenStarted);\n\t}\n\n\t/**\n\t * Throws an exception if any commits have been marked as start.\n\t * <p>\n\t * If {@link #markStart(RevCommit)} has already been called,\n\t * {@link #reset()} can be called to satisfy this condition.\n\t *\n\t * @since 5.5\n\t */\n\tprotected void assertNoCommitsMarkedStart() {\n\t\tif (roots.isEmpty())\n\t\t\treturn;\n\t\tthrow new IllegalStateException(\n\t\t\t\tJGitText.get().commitsHaveAlreadyBeenMarkedAsStart);\n\t}\n\n\tprivate boolean isNotStarted() {\n\t\treturn pending instanceof StartGenerator;\n\t}\n\n\t/**\n\t * Create and return an {@link org.eclipse.jgit.revwalk.ObjectWalk} using\n\t * the same objects.\n\t * <p>\n\t * Prior to using this method, the caller must reset this RevWalk to clean\n\t * any flags that were used during the last traversal.\n\t * <p>\n\t * The returned ObjectWalk uses the same ObjectReader, internal object pool,\n\t * and free RevFlags. Once the ObjectWalk is created, this RevWalk should\n\t * not be used anymore.\n\t *","sourceCodeStart":1723,"sourceCodeEnd":1759,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java#L1723-L1759","documentation":"RevWalk.assertNoCommitsMarkedStart() guards APIs (added in 5.5) that must be configured before any start commits exist. Once markStart/markUninteresting (roots) have been called, changing certain settings would invalidate the pending start set, so this IllegalStateException is thrown while roots is non-empty.","triggerScenarios":"Calling an API that asserts no start commits (e.g. setCommitSpooling mode or related pre-start configuration) after markStart(...) has already registered roots on the walk.","commonSituations":"Constructing a walk, marking start commits early, then applying late configuration; helper methods marking starts as a side effect before configuration code runs.","solutions":["Move the configuration call above all markStart/markUninteresting invocations.","Create a new RevWalk, configure first, then mark start commits.","Refactor so start marking is the last step of walk setup."],"exampleFix":"// before\nwalk.markStart(head);\nwalk.setRetainBody(false); // assertNoCommitsMarkedStart throws\n// after\nwalk.setRetainBody(false);\nwalk.markStart(head);","handlingStrategy":"validation","validationCode":"if (!walk.roots.isEmpty()) // roots are registered by markStart\n    throw new IllegalStateException(\"mark start commits only after configuration\");","typeGuard":"// structural guard: keep marking in one terminal method\nvoid buildWalk(RevWalk w, Consumer<RevWalk> config, RevCommit... starts) throws IOException {\n    config.accept(w); // all settings first\n    for (RevCommit c : starts) w.markStart(c); // marking last\n}","tryCatchPattern":"try {\n    configure(walk);\n} catch (IllegalStateException e) {\n    walk = new RevWalk(repo);\n    configure(walk);\n    walk.markStart(head);\n}","preventionTips":["Make markStart the last step of walk construction","Avoid helpers with markStart side effects called mid-setup","Rebuild the walk instead of mutating after marking"],"tags":["git","revwalk","illegal-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}