Skip to content

fix(review): a named directory is reviewed even when the shell exported GIT_DIR - #3377

Merged
backnotprop merged 1 commit into
mainfrom
fix/review-wrong-project-diff
Nov 14, 2026
Merged

backnotprop merged 1 commit into
mainfrom
fix/review-wrong-project-diff

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

What was wrong

plannotator review <folder> started from a shell that had exported GIT_DIR (and maybe GIT_WORK_TREE) showed the diff of the repository those variables name, not the folder's. A git hook or a script sets them. With GIT_DIR alone the page mixed the two: the other repository's index against the named folder's files. With both set, it showed only the other repository.

The fix

Once the review names a directory, the CLI removes GIT_DIR and its kin from its own environment before any git runs. That covers the direct review command and the OpenCode opencode-review-directory bridge, which share resolveCliReviewDirectory. With no directory named, the variables still decide, so GIT_DIR=… GIT_WORK_TREE=… plannotator review keeps working.

The variable list moves to @plannotator/shared/child-env (GIT_REPO_ENV). The Inbox's clone (inbox-launch-clone.ts) already removed the same list and now imports it.

Pi is unchanged. Its /plannotator-review runs inside Pi's own process, and that process's env is not Plannotator's to change.

Other ways a review can show another project's changes (checked, not changed here)

These behave the same on 0.28.56 and on main:

  • A bare folder name that does not exist under the current folder. For example, review --diff-type uncommitted other-project run from inside a different repository. The current folder's repository is reviewed, and the only sign is a one-line stderr notice ("Ignoring words…"). This is the documented prose tolerance (fix(review): error loudly on unknown review options instead of silently dropping them #1483), and review-args.test.ts pins it. The help says "A sole word … is a directory target", which suggests an error instead.
  • A folder that is not a repository itself but sits inside one (for example, a home folder kept in git). The folder normalizes to the enclosing repository, and the whole repository's diff is shown. This is documented ("Explicit targets inside a repository normalize to its detected VCS root").

Flag order, absolute and relative paths, linked worktrees and submodules all review the named folder. A second review on a fixed port that is already in use exits with a clear message.

Tests

apps/hook/server/review-directory.test.ts, for the CLI and the OpenCode bridge:

  • a named directory is reviewed with the caller's GIT_DIR, and with GIT_DIR plus GIT_WORK_TREE, exported;
  • with no directory named, the exported repository is still the one reviewed.

The new tests fail before the fix (they show the caller's repository) and pass after it.

…ed GIT_DIR

plannotator review <folder> run with GIT_DIR (or GIT_WORK_TREE) set by the
calling shell, as in a git hook or a script, showed the diff of the repository
those variables name instead of the folder's. The CLI now removes them once a
directory is named, before any git runs; with no directory they still decide.
The list moves to @plannotator/shared/child-env, shared with the Inbox's clone.
@backnotprop
backnotprop marked this pull request as ready for review November 14, 2026 23:13
@backnotprop
backnotprop merged commit 3a4a55b into main Nov 14, 2026
56 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.

1 participant