Skip to content

Conversation

@esmuellert
Copy link
Owner

Summary

Fix git repository detection in explorer mode to use current working directory instead of current buffer's path.

Problem

When the current buffer is from a different repository than the working directory, :CodeDiff would show "not in a git repository" error because it was detecting based on the buffer's path.

Solution

Use vim.fn.getcwd() instead of buffer path for explorer mode, matching how git status works in terminal.

No Regression

  • Normal case (buffer in same repo as cwd): Works same as before
  • Scratch/empty buffer: Works same as before
  • Only change: buffer from different repo now correctly uses cwd's repo

…r mode

Explorer mode now uses vim.fn.getcwd() to detect the git repository,
matching the expected behavior when user runs :CodeDiff from a directory.

This fixes the case where the current buffer is from a different repo
than the working directory.
Try buffer path first, then fallback to cwd if buffer path is not
in a git repo. This maintains backward compatibility while fixing
the case where user has a file open from a different location.
@esmuellert esmuellert merged commit 9aee29f into main Jan 11, 2026
13 checks passed
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