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