summaryrefslogtreecommitdiff
path: root/src/patch_parse.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-04-25 00:35:48 -0400
committerEdward Thomson <ethomson@github.com>2016-05-26 13:01:09 -0500
commit7166bb16659790ae2b398e1e95c752f784f6f1d3 (patch)
tree1cc3a26e908ed54f579f5595332ba62bbba5a49c /src/patch_parse.h
parent94e488a056942f1bb1ebbe7c9f0c693937726609 (diff)
downloadlibgit2-7166bb16659790ae2b398e1e95c752f784f6f1d3.tar.gz
introduce `git_diff_from_buffer` to parse diffs
Parse diff files into a `git_diff` structure.
Diffstat (limited to 'src/patch_parse.h')
-rw-r--r--src/patch_parse.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/patch_parse.h b/src/patch_parse.h
index d5e86073f..da56dad7c 100644
--- a/src/patch_parse.h
+++ b/src/patch_parse.h
@@ -7,6 +7,31 @@
#ifndef INCLUDE_patch_parse_h__
#define INCLUDE_patch_parse_h__
+typedef struct {
+ git_refcount rc;
+
+ /* Original content buffer */
+ const char *content;
+ size_t content_len;
+
+ git_patch_options opts;
+
+ /* The remaining (unparsed) buffer */
+ const char *remain;
+ size_t remain_len;
+
+ const char *line;
+ size_t line_len;
+ size_t line_num;
+} git_patch_parse_ctx;
+
+extern git_patch_parse_ctx *git_patch_parse_ctx_init(
+ const char *content,
+ size_t content_len,
+ const git_patch_options *opts);
+
+extern void git_patch_parse_ctx_free(git_patch_parse_ctx *ctx);
+
/**
* Create a patch for a single file from the contents of a patch buffer.
*
@@ -22,4 +47,8 @@ extern int git_patch_from_buffer(
size_t contents_len,
const git_patch_options *opts);
+extern int git_patch_parse(
+ git_patch **out,
+ git_patch_parse_ctx *ctx);
+
#endif