Skip to content

Pygit2 truncates diff from Linux kernel commit bb8d8a6f54c1 #1043

Closed
@tohojo

Description

@tohojo

The diff output of commit bb8d8a6f54c1 in the Linux kernel is truncated by pygit2. Here's a minimal reproducer:

Assuming 'linux' contains a Linux kernel tree such as one that can be obtained by git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git:

import pygit2

r = pygit2.Repository("linux")
c = r.get('bb8d8a6f54c1')
print(c.parents[0].tree.diff_to_tree(c.tree).patch)

This ends with half a hunk:

@@ -431,6 +440,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
 }
 
 /**
+

The same hunk as output by git show bb8d8a6f54c1 (without a pager):

@@ -431,6 +440,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
 }
 
 /**
+
  * gfs2_ri_total - Total up the file system space, according to the rindex.
  *
  */

Note that when using 'less' as a pager, it shows this hunk as:

@@ -431,6 +440,7 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
 }
 
 /**
+^@
  * gfs2_ri_total - Total up the file system space, according to the rindex.
  *
  */

(note the ^@ escape). I suspect maybe there's a NULL byte in the middle of the hunk output for some reason, and that this causes the diff to be terminated prematurely in pygit2?

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