Skip to content

analyzeGitDelta: renamed and copied files lose isBinary (numstat -z parsed in the wrong format) #175

Closed

Description

@FredApps

What went wrong?

The output or a command was wrong or confusing

DiffCI version

core main 40aa308 (src/git/git-diff.ts)

Command you ran

git init -q demo && cd demo
printf 'abc\n' > a.txt && head -c 3000 /dev/urandom > b.bin
git add . && git commit -qm 1
git mv a.txt c.txt && git mv b.bin d.bin && git commit -qm 2

then analyzeGitDelta({ repoPath: "demo" }) and print files[].isBinary.

Environment

Linux, Node 24, git 2.43

Output

renamed a.txt -> c.txt isBinary: undefined
renamed b.bin -> d.bin isBinary: undefined

Every renamed or copied file gets isBinary: undefined, binary or not.

Cause

analyzeGitDelta runs git diff-tree -r --numstat -z --find-renames=50%. With -z, git writes a rename as three NUL-separated fields, added\tdeleted\t (empty path), then the old path, then the new path:

0000000   0  \t   0  \t  \0   a   .   t   x   t  \0   c   .   t   x   t  \0
0000020   -  \t   -  \t  \0   b   .   b   i   n  \0   d   .   b   i   n  \0

parseNumstat (src/git/git-diff.ts:151-178) splits on NUL and parses each piece as one record. It expects the tab-separated added\tdeleted\told\tnew form, which git never writes with -z. So the rename header has an empty path and is dropped, and the two path pieces have no tabs and are dropped too. The unit test "handles rename numstat records" (tests/git/git-diff.parsers.test.ts:83) builds that non-git form, so it passes.

The same split also misreads a non-rename path that contains a tab, which -z leaves unquoted. Its last tab-separated piece is taken as the path.

Nothing in core or the CLI reads isBinary today, so this is limited to the GitDelta that analyzeGitDelta returns and serializes. The field is documented on ChangedFile but is wrong for every rename or copy.

What you expected

isBinary is true for d.bin and false for c.txt, and the parser test uses the byte format git diff-tree --numstat -z actually produces.

Activity

  1. added a commit that references this issue on Nov 18, 2026
    6a503b7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions