saadeghi/daisyui · error · Error

Malformed git diff entry for status ${status}

Error message

Malformed git diff entry for status ${status}

What it means

Thrown by parseNameStatus when a git diff --name-status entry has a status beginning with R (rename) or C (copy) but the two following NUL-separated tokens (old path, head path) are missing. These status kinds require two path tokens; the guard detects a truncated/empty token stream.

Source

Thrown at packages/tailwind-play-share/pr-preview.mjs:349

  }
}

export function parseNameStatus(output) {
  const tokens = output.split("\0")
  if (tokens.at(-1) === "") tokens.pop()
  const changes = []

  for (let index = 0; index < tokens.length;) {
    const status = tokens[index]
    index += 1
    if (!status) continue

    const kind = status[0]
    if (kind === "R" || kind === "C") {
      const oldPath = tokens[index]
      const headPath = tokens[index + 1]
      index += 2
      if (!oldPath || !headPath) throw new Error(`Malformed git diff entry for status ${status}`)
      changes.push({ headPath, kind, oldPath, status })
      continue
    }

    const filePath = tokens[index]
    index += 1
    if (!filePath) throw new Error(`Malformed git diff entry for status ${status}`)
    changes.push({
      headPath: kind === "D" ? undefined : filePath,
      kind,
      oldPath: kind === "D" ? filePath : undefined,
      status,
    })
  }

  return changes
}

View on GitHub (pinned to 42b09e637e)

Solutions

  1. Re-run; if it persists, capture the raw `git diff --name-status --find-renames -z BASE HEAD -- packages/daisyui/src/components` output and inspect it.
  2. Ensure a standard git version is on PATH.
  3. Verify both SHAs resolve cleanly (see error 53).
  4. Report upstream with the raw diff tokens if git output is well-formed.
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from "node:child_process"
function assertDiffWellFormed(baseSha, headSha) {
  const out = execSync(`git diff --name-status --find-renames -z ${baseSha} ${headSha} -- packages/daisyui/src/components`, { encoding: "utf8" })
  const tokens = out.split("\0")
  for (let i = 0; i < tokens.length;) {
    const s = tokens[i++]; if (!s) continue
    if (s[0] === "R" || s[0] === "C") { if (!tokens[i] || !tokens[i + 1]) throw new Error(`Malformed diff at ${s}`); i += 2 } else { if (!tokens[i]) throw new Error(`Malformed diff at ${s}`); i++ }
  }
}

Try / catch

try {
  inputs = buildPreviewInputs(baseSha, headSha)
} catch (error) {
  if (/Malformed git diff entry for status/.test(error.message)) {
  // inspect raw `git diff -z --name-status` output; likely corrupted capture
  }
  throw error
}

Prevention

When it happens

Trigger: parseNameStatus reads status = tokens[index], sees kind R/C, then tokens[index] or tokens[index+1] is undefined/empty after incrementing, so `!oldPath || !headPath` is true.

Common situations: Corrupted or unexpectedly formatted `git diff -z --name-status` output, a git version emitting a status line the parser does not expect (e.g. an unmerged status), or manual truncation of the diff output. Should not occur with well-formed git output.

Understand the failure class

Related errors


AI-assisted analysis of saadeghi/daisyui@42b09e637e (2026-08-13). Data as JSON: /api/errors/bbc02ba0a1ac5338. Report an issue: GitHub.