Commit 30592106f218dbbb2e07de1c2b439735389c541e

Thomas de Grivel 2022-08-01T10:43:20

fix git nif diff with multiple hunks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/c_src/git_nif.c b/c_src/git_nif.c
index cc2ccb1..82c66b6 100644
--- a/c_src/git_nif.c
+++ b/c_src/git_nif.c
@@ -203,14 +203,8 @@ static ERL_NIF_TERM diff_nif (ErlNifEnv *env, int argc,
     res = enif_make_atom(env, "git_diff_tree_to_tree");
     goto error;
   }
-  printf("patch\n");
-  if (git_patch_from_diff(&patch, diff, 0)) {
-    res = enif_make_atom(env, "git_patch_from_diff");
-    goto error;
-  }
-  printf("buf\n");
-  if (git_patch_to_buf(&buf, patch)) {
-    res = enif_make_atom(env, "git_patch_to_buf");
+  if (git_diff_to_buf(&buf, diff, GIT_DIFF_FORMAT_PATCH)) {
+    res = enif_make_atom(env, "git_diff_to_buf");
     goto error;
   }
   printf("res\n");