Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_diff_index_to_workdir fails to load untracked content when GIT_DIFF_REVERSE and GIT_DIFF_SHOW_UNTRACKED_CONTENT are set. #6576

Open
arroz opened this issue Jun 10, 2023 · 0 comments

Comments

@arroz
Copy link
Contributor

arroz commented Jun 10, 2023

Reproduction steps

Assume the following code on a workdir with an untracked file with at least one line of content:

git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
git_diff *diff = NULL;
opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_SHOW_UNTRACKED_CONTENT | GIT_DIFF_REVERSE;
git_diff_index_to_workdir(&diff, repo, NULL, &opts)

This diff will not properly load the content when inspected. Specifically, the following call will never get run diff_hunk_cb or diff_line_cb:

git_diff_foreach(diff, diff_file_cb, diff_binary_cb, diff_hunk_cb, diff_line_cb, &exp)

Expected behavior

The call above should call diff_hunk_cb once and diff_line_cb for each content line.

Actual behavior

The calls never happen because, internally, the content is never loaded.

Version of libgit2 (release number or SHA1)

2f20fe8869d7a1df7c9b7a9e2939c1a20533c6dc

Operating system(s) tested

macOS

arroz added a commit to cavaquinho/libgit2 that referenced this issue Jun 10, 2023
ethomson added a commit that referenced this issue Jul 15, 2023
…ed_reverse

#6576 git_diff_index_to_workdir reverse now loads untracked content
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

No branches or pull requests

1 participant