diff: always print the file header on GIT_DIFF_FORMAT_PATCH_HEADER #6887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
diff_print_patch_file
we try to avoid printing the file if we're not surethat there will be some content. This works fine if we have any later functions
that might get called as part of printing. But when given the format
GIT_DIFF_FORMAT_PATCH_HEADER
, this is the only function to get called.Force us to print the diff header for the file in such a situation. This may
still print the header where e.g.
GIT_DIFF_FORMAT_PATCH
wouldn't, but it'sbetter than this option not working at all.
This fixes a regression introduced in #5893 that's making the rugged tests fail to pass. This sort of regresses that fix by sending out the header more than we'd like, but this is a fix I could make quickly.
An alternative might be to still call the hunk function but have it return early if the format is just asking for the header (that might require teaching a few of these functions though as we could still instead land in the binary function).