plandex-ai/plandex · error

error getting git status: %s

Error message

error getting git status: %s

What it means

After finding the repo root, the deleted-file detection goroutine runs `git status --porcelain` in baseDir. This error is thrown when that command exits non-zero. Note a bug in the surrounding code: on this path the goroutine sends the error but does NOT return, so it continues to parse an empty/partial output before later sending nil on errCh — potentially causing a panic from double-send or goroutine leak.

Source

Thrown at app/cli/fs/paths.go:64

	if isGitRepo {

		// Use git status to find deleted files
		numRoutines++
		go func() {
			cmd := exec.Command("git", "rev-parse", "--show-toplevel")
			output, err := cmd.Output()
			if err != nil {
				errCh <- fmt.Errorf("error getting git root: %s", err)
				return
			}
			repoRoot := strings.TrimSpace(string(output))

			cmd = exec.Command("git", "status", "--porcelain")
			cmd.Dir = baseDir
			out, err := cmd.Output()
			if err != nil {
				errCh <- fmt.Errorf("error getting git status: %s", err)
			}

			lines := strings.Split(string(out), "\n")

			for _, line := range lines {
				line = strings.TrimSpace(line)
				if strings.HasPrefix(line, "D ") {
					path := strings.TrimSpace(line[2:])
					absPath := filepath.Join(repoRoot, path)
					relPath, err := filepath.Rel(currentDir, absPath)
					if err != nil {
						errCh <- fmt.Errorf("error getting relative path: %s", err)
						return
					}
					deletedFiles[relPath] = true
				}
			}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Run `git status --porcelain` manually in the project directory and fix the reported git error (lock file, ownership, config).
  2. Add safe.directory entries: `git config --global --add safe.directory <repo-path>` when running as another user/container.
  3. Remove stale lock files (e.g. .git/index.lock) if git reports them, after confirming no git process is running.
  4. Validate .gitconfig / global config for invalid keys or values that make every git invocation fail.
Defensive patterns

Strategy: validation

Validate before calling

cmd := exec.Command("git", "-C", baseDir, "status", "--porcelain")
if err := cmd.Run(); err != nil {
	return fmt.Errorf("git status unavailable in %s: %w", baseDir, err)
}

Try / catch

if err := <-errCh; err != nil {
	if strings.Contains(err.Error(), "error getting git status") {
		// inspect wrapped git error: lock file, ownership, config
	}
}

Prevention

When it happens

Trigger: Calling GetPaths on a git repo where `git status --porcelain` fails: corrupt index (e.g. .git/index unreadable), dubious-ownership safe.directory rejection, a broken .gitconfig (invalid config values cause git to exit with error), or git not on PATH.

Common situations: Running inside Docker as a different user than the repo owner; a malformed .gitconfig or hook config; interrupted operations leaving a locked/corrupt .git/index; sandboxed CI runners with restricted permissions on .git.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/172caa524d6f9c8e. Report an issue: GitHub.