Deleted file shows up as a typechange with GIT_DIFF_INCLUDE_TYPECHANGE_TREES and a pathspec · Issue #7392 · libgit2/libgit2 · GitHub
Skip to content

Deleted file shows up as a typechange with GIT_DIFF_INCLUDE_TYPECHANGE_TREES and a pathspec #7392

Open

Description

@yerseg

Reproduction steps

Old tree has files a and c with the same content, new tree only has c/d.

char *paths[] = { "a", "c/*" };

opts.flags = GIT_DIFF_INCLUDE_TYPECHANGE_TREES;
opts.pathspec.strings = paths;
opts.pathspec.count = 2;

git_diff_tree_to_tree(&diff, repo, old_tree, new_tree, &opts);

Expected behavior

D a and A c/d.

Actual behavior

T a (100644 -> 040000) and A c/d.

handle_unmatched_old_item adds a delta for c and then uses diff_delta__last_for_item to turn it into a typechange. Here the pathspec filters out c, so no delta is added, and the last delta is actually the one for a. diff_delta__last_for_item only compares ids, and a and c have the same id, so the delta for a gets changed. A notify callback that skips the delta causes the same thing, and handle_unmatched_new_item has the same pattern.

Version of libgit2 (release number or SHA1)

main (0551dfd)

Operating system(s) tested

Linux

Activity

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