{"record":{"id":"5438026450d89da8","repo":"theonedev/onedev","slug":"cannot-find-merge-base-using-first-parent","errorCode":null,"errorMessage":"Cannot find merge base using first parent.","messagePattern":"Cannot find merge base using first parent\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java","lineNumber":65,"sourceCode":"\tRevCommit next() throws MissingObjectException,\n\t\t\tIncorrectObjectTypeException, IOException {\n\t\tGenerator g;\n\n\t\tfinal RevWalk w = walker;\n\t\tRevFilter rf = w.getRevFilter();\n\t\tfinal TreeFilter tf = w.getTreeFilter();\n\t\tAbstractRevQueue q = walker.queue;\n\n\t\tif (rf == RevFilter.MERGE_BASE) {\n\t\t\t// Computing for merge bases is a special case and does not\n\t\t\t// use the bulk of the generator pipeline.\n\t\t\t//\n\t\t\tif (tf != TreeFilter.ALL) {\n\t\t\t\tthrow new IllegalStateException(MessageFormat.format(\n\t\t\t\t\t\tJGitText.get().cannotCombineTreeFilterWithRevFilter, tf, rf));\n\t\t\t}\n\t\t\tif (w.isFirstParent()) {\n\t\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\tJGitText.get().cannotFindMergeBaseUsingFirstParent);\n\t\t\t}\n\n\t\t\tfinal MergeBaseGenerator mbg = new MergeBaseGenerator(w);\n\t\t\twalker.pending = mbg;\n\t\t\twalker.queue = AbstractRevQueue.EMPTY_QUEUE;\n\t\t\tmbg.init(q);\n\t\t\treturn mbg.next();\n\t\t}\n\n\t\tfinal boolean uninteresting = q.anybodyHasFlag(RevWalk.UNINTERESTING);\n\t\tboolean boundary = walker.hasRevSort(RevSort.BOUNDARY);\n\n\t\tif (!boundary && walker instanceof ObjectWalk) {\n\t\t\t// The object walker requires boundary support to color\n\t\t\t// trees and blobs at the boundary uninteresting so it\n\t\t\t// does not produce those in the result.\n\t\t\t//","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java#L47-L83","documentation":"Thrown by StartGenerator.next() when a merge-base walk (RevFilter.MERGE_BASE) is started on a RevWalk configured with setFirstParent(true). The merge-base generator cannot operate correctly when traversal is restricted to first parents only, so JGit rejects the combination up front.","triggerScenarios":"Calling RevWalk.setFirstParent(true) and RevWalk.setRevFilter(RevFilter.MERGE_BASE), then iterating with next().","commonSituations":"Reusing a shared RevWalk builder that enables first-parent for history simplification, then adding a merge-base filter for rename/detector or ancestor checks.","solutions":["Call walk.setFirstParent(false) before starting the merge-base walk","Use a dedicated RevWalk instance for merge-base computation","Use Repository/RevWalkUtils utilities (e.g. RevWalkUtils.findBranchesReachedFrom) or a separate algorithm that supports first-parent if that is genuinely required"],"exampleFix":"// before\nwalk.setFirstParent(true);\nwalk.setRevFilter(RevFilter.MERGE_BASE);\n// after\nwalk.setFirstParent(false); // required for merge-base\nwalk.setRevFilter(RevFilter.MERGE_BASE);","handlingStrategy":"validation","validationCode":"if (walk.getRevFilter() == RevFilter.MERGE_BASE && walk.isFirstParent()) {\n    walk.setFirstParent(false);\n}","typeGuard":null,"tryCatchPattern":"try {\n    for (RevCommit c : walk) { ... }\n} catch (IllegalStateException e) {\n    throw new ConfigurationException(\"merge-base walk cannot use first-parent mode\");\n}","preventionTips":["Keep first-parent walks and merge-base walks in separate RevWalk instances","Document that MERGE_BASE requires default parent traversal","Audit shared walk-builder helpers for firstParent flags"],"tags":["jgit","revwalk","merge-base","illegal-state"],"backgroundTag":"unsupported-operation","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"}