Skip to content

Failure to parse diff when it adds an empty file #6778

Description

@marcosdiazr

Reproduction steps

on any existing repo generate a diff that adds an empty file like this:

$ touch new_file
$ git add new_file 
$ git diff --staged > new_file.patch

(attaching here the produced path, I used git 2.25.1)
new_file.patch.txt

And when running this small program that uses libgit2:
test.c.txt
built using
gcc test.c -lgit2 -L <path to libgit2>/libgit2/build/ -Wall -pedantic -I <path to libgit2>/libgit2/include/
And run like this:
LD_LIBRARY_PATH=<path to libgit2>/libgit2/build/ ./a.out <Path to repo> <path to patch file>

Expected behavior

It successfully applies the change

Actual behavior

Error creating patch: unexpected header line 4

I checked while doing other changes and the only apparent issue seems to be including empty files

Version of libgit2 (release number or SHA1)

1.3.0 and main ( d74d491 )

Operating system(s) tested

Linux (Ubuntu 20.04)

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