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

Pygit2 truncates diff from Linux kernel commit bb8d8a6f54c1 #1043

Closed
tohojo opened this issue Oct 29, 2020 · 0 comments · Fixed by #1047
Closed

Pygit2 truncates diff from Linux kernel commit bb8d8a6f54c1 #1043

tohojo opened this issue Oct 29, 2020 · 0 comments · Fixed by #1047

Comments

@tohojo
Copy link

tohojo commented Oct 29, 2020

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?

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

Successfully merging a pull request may close this issue.

1 participant