{"record":{"id":"d24267defe14cca0","repo":"GitoxideLabs/gitoxide","slug":"caller-knows-there-is-a-common-iter","errorCode":null,"errorMessage":"caller knows there is a common iter","messagePattern":"caller knows there is a common iter","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"gix-ref/src/store/file/overlay_iter.rs","lineNumber":63,"sourceCode":"impl<'p> LooseThenPacked<'p, '_> {\n    fn strip_namespace(&self, mut r: Reference) -> Reference {\n        if let Some(namespace) = &self.namespace {\n            r.strip_namespace(namespace);\n        }\n        r\n    }\n\n    fn loose_iter(&mut self, kind: IterKind) -> &mut Peekable<SortedLoosePaths> {\n        match kind {\n            IterKind::GitAndConsumeCommon => {\n                drop(self.iter_common_dir.as_mut().map(Iterator::next));\n                &mut self.iter_git_dir\n            }\n            IterKind::Git => &mut self.iter_git_dir,\n            IterKind::Common => self\n                .iter_common_dir\n                .as_mut()\n                .expect(\"caller knows there is a common iter\"),\n        }\n    }\n\n    fn convert_packed(\n        &mut self,\n        packed: Result<packed::Reference<'p>, packed::iter::Error>,\n    ) -> Result<Reference, Error> {\n        packed\n            .map(Into::into)\n            .map(|r| self.strip_namespace(r))\n            .map_err(|err| match err {\n                packed::iter::Error::Reference {\n                    invalid_line,\n                    line_number,\n                } => Error::PackedReference {\n                    invalid_line,\n                    line_number,\n                },","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-ref/src/store/file/overlay_iter.rs#L45-L81","documentation":"The overlay store iterator merges the git-dir and common-dir loose views plus the packed-refs view. `loose_iter` picks the inner iterator for the given `IterKind`; `IterKind::Common` requires `iter_common_dir` to be `Some`, which is guaranteed by construction whenever the common kind is produced. The `expect` fails only if the overlay iterator was built without a common-dir iterator while still yielding `Common` kinds.","triggerScenarios":"Iterating references of an overlay (`StoreIter`) where the internal kind tag says `Common` but no common-dir iterator was initialized — an internal inconsistency, e.g. after a misuse of internal APIs or a gix-ref bug.","commonSituations":"Not reachable through public APIs on a correctly detected repository layout; if seen, it usually indicates a bug in common-dir detection (e.g. worktree setups where `commondir` resolution differs from what the iterator assumed) or custom store construction.","solutions":["Check that your repository/worktree layout is detected correctly (presence of `commondir` file, linked worktrees)","Try reproducing with plain `git for-each-ref` to see if the repository layout itself is unusual","If it reproduces on a standard repository, report a gix-ref bug with the repo layout","Work around by iterating `store.iter()` results rather than relying on the mixed overlay enumeration, or upgrade gix-ref"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Panics can't be caught idiomatically; wrap iteration in catch_unwind if resilience is required\nlet refs = std::panic::catch_unwind(|| store.iter().collect::<Vec<_>>()).map_err(|_| \"iteration panicked\");","preventionTips":["Use standard worktree layouts (normal `.git` + `worktrees/`) where common-dir detection is well tested","Test iteration on the actual repository layout before relying on it in production","Upgrade gix-ref when this panic appears; it signals a library bug","Compare behavior with `git for-each-ref` to confirm layout oddities"],"tags":["rust","panic","gix-ref","iterator","worktree"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}