1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
4  * This file is part of libgit2, distributed under the GNU GPL v2 with
5  * a Linking Exception. For full terms see the included COPYING file.
6  */
7 module libgit2_d.sys.diff;
8 
9 
10 private static import libgit2_d.diff;
11 private static import libgit2_d.types;
12 
13 /**
14  * @file git2/sys/diff.h
15  * @brief Low-level Git diff utilities
16  * @ingroup Git
17  * @{
18  */
19 extern (C):
20 nothrow @nogc:
21 package(libgit2_d):
22 
23 /**
24  * Diff print callback that writes to a git_buf.
25  *
26  * This function is provided not for you to call it directly, but instead
27  * so you can use it as a function pointer to the `git_diff_print` or
28  * `git_patch_print` APIs.  When using those APIs, you specify a callback
29  * to actually handle the diff and/or patch data.
30  *
31  * Use this callback to easily write that data to a `git_buf` buffer.  You
32  * must pass a `git_buf *` value as the payload to the `git_diff_print`
33  * and/or `git_patch_print` function.  The data will be appended to the
34  * buffer (after any existing content).
35  */
36 //GIT_EXTERN
37 /**< payload must be a `git_buf *` */
38 int git_diff_print_callback__to_buf(const (libgit2_d.diff.git_diff_delta)* delta, const (libgit2_d.diff.git_diff_hunk)* hunk, const (libgit2_d.diff.git_diff_line)* line, void* payload);
39 
40 /**
41  * Diff print callback that writes to stdio FILE handle.
42  *
43  * This function is provided not for you to call it directly, but instead
44  * so you can use it as a function pointer to the `git_diff_print` or
45  * `git_patch_print` APIs.  When using those APIs, you specify a callback
46  * to actually handle the diff and/or patch data.
47  *
48  * Use this callback to easily write that data to a stdio FILE handle.  You
49  * must pass a `FILE *` value (such as `stdout` or `stderr` or the return
50  * value from `fopen()`) as the payload to the `git_diff_print`
51  * and/or `git_patch_print` function.  If you pass null, this will write
52  * data to `stdout`.
53  */
54 //GIT_EXTERN
55 /**< payload must be a `FILE *` */
56 int git_diff_print_callback__to_file_handle(const (libgit2_d.diff.git_diff_delta)* delta, const (libgit2_d.diff.git_diff_hunk)* hunk, const (libgit2_d.diff.git_diff_line)* line, void* payload);
57 
58 /**
59  * Performance data from diffing
60  */
61 struct git_diff_perfdata
62 {
63 	uint version_;
64 
65 	/**
66 	 * Number of stat() calls performed
67 	 */
68 	size_t stat_calls;
69 
70 	/**
71 	 * Number of ID calculations
72 	 */
73 	size_t oid_calculations;
74 }
75 
76 enum GIT_DIFF_PERFDATA_VERSION = 1;
77 
78 pragma(inline, true)
79 pure nothrow @safe @nogc
80 .git_diff_perfdata GIT_DIFF_PERFDATA_INIT()
81 
82 	do
83 	{
84 		.git_diff_perfdata OUTPUT =
85 		{
86 			version_: .GIT_DIFF_PERFDATA_VERSION,
87 			stat_calls: 0,
88 			oid_calculations: 0,
89 		};
90 
91 		return OUTPUT;
92 	}
93 
94 /**
95  * Get performance data for a diff object.
96  *
97  * Params:
98  *      out_ = Structure to be filled with diff performance data
99  *      diff = Diff to read performance data from
100  *
101  * Returns: 0 for success, <0 for error
102  */
103 //GIT_EXTERN
104 int git_diff_get_perfdata(.git_diff_perfdata* out_, const (libgit2_d.diff.git_diff)* diff);
105 
106 /**
107  * Get performance data for diffs from a git_status_list
108  */
109 //GIT_EXTERN
110 int git_status_list_get_perfdata(.git_diff_perfdata* out_, const (libgit2_d.types.git_status_list)* status);
111 
112 /** @} */