Skip to content

Avoid crash when git graph and log outputs desync on branch switch#1920

Open
MaxShymko wants to merge 1 commit intoNeogitOrg:masterfrom
MaxShymko:fix-log-view-on-switch
Open

Avoid crash when git graph and log outputs desync on branch switch#1920
MaxShymko wants to merge 1 commit intoNeogitOrg:masterfrom
MaxShymko:fix-log-view-on-switch

Conversation

@MaxShymko
Copy link
Copy Markdown

Issue: Switching branches could crash Neogit with “No commit found for oid …” in log.lua. A minimal repro is here: https://github.com/MaxShymko/neogit-branch-switch (telescope enabled).

Root cause: For ASCII graphs Neogit runs two separate git log calls (one for commits, one for graph). During branch switches these can observe different repo states, so the graph can reference an OID not present in the commit list.

Fix: Treat missing OIDs as a normal case and render the graph line without asserting. This prevents the crash while preserving log output.

@CKolkey
Copy link
Copy Markdown
Member

CKolkey commented Mar 25, 2026

I tried the reproduction and didn't encounter an error - are you suggesting to switch branches and open the git log in very rapid succession?

@MaxShymko
Copy link
Copy Markdown
Author

Hm, that sounds strange. I probably have something else that causes this behavior 🤷‍♂️

Basically, I just open :Neogit, then press b, then r, and select another branch. No rapid toggling is needed.

CleanShot.2026-03-25.at.16.56.58.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants