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.mailmap; 8 9 10 private static import libgit2_d.types; 11 12 /** 13 * @file git2/mailmap.h 14 * @brief Mailmap parsing routines 15 * @defgroup git_mailmap Git mailmap routines 16 * @ingroup Git 17 * @{ 18 */ 19 extern (C): 20 nothrow @nogc: 21 public: 22 23 /** 24 * Allocate a new mailmap object. 25 * 26 * This object is empty, so you'll have to add a mailmap file before you can do 27 * anything with it. The mailmap must be freed with 'git_mailmap_free'. 28 * 29 * Params: 30 * out_ = pointer to store the new mailmap 31 * 32 * Returns: 0 on success, or an error code 33 */ 34 //GIT_EXTERN 35 int git_mailmap_new(libgit2_d.types.git_mailmap** out_); 36 37 /** 38 * Free the mailmap and its associated memory. 39 * 40 * Params: 41 * mm = the mailmap to free 42 */ 43 //GIT_EXTERN 44 void git_mailmap_free(libgit2_d.types.git_mailmap* mm); 45 46 /** 47 * Add a single entry to the given mailmap object. If the entry already exists, 48 * it will be replaced with the new entry. 49 * 50 * Params: 51 * mm = mailmap to add the entry to 52 * real_name = the real name to use, or NULL 53 * real_email = the real email to use, or NULL 54 * replace_name = the name to replace, or NULL 55 * replace_email = the email to replace 56 * 57 * Returns: 0 on success, or an error code 58 */ 59 //GIT_EXTERN 60 int git_mailmap_add_entry(libgit2_d.types.git_mailmap* mm, const (char)* real_name, const (char)* real_email, const (char)* replace_name, const (char)* replace_email); 61 62 /** 63 * Create a new mailmap instance containing a single mailmap file 64 * 65 * Params: 66 * out_ = pointer to store the new mailmap 67 * buf = buffer to parse the mailmap from 68 * len = the length of the input buffer 69 * 70 * Returns: 0 on success, or an error code 71 */ 72 //GIT_EXTERN 73 int git_mailmap_from_buffer(libgit2_d.types.git_mailmap** out_, const (char)* buf, size_t len); 74 75 /** 76 * Create a new mailmap instance from a repository, loading mailmap files based 77 * on the repository's configuration. 78 * 79 * Mailmaps are loaded in the following order: 80 * 1. '.mailmap' in the root of the repository's working directory, if present. 81 * 2. The blob object identified by the 'mailmap.blob' config entry, if set. 82 * [NOTE: 'mailmap.blob' defaults to 'HEAD:.mailmap' in bare repositories] 83 * 3. The path in the 'mailmap.file' config entry, if set. 84 * 85 * Params: 86 * out_ = pointer to store the new mailmap 87 * repo = repository to load mailmap information from 88 * 89 * Returns: 0 on success, or an error code 90 */ 91 //GIT_EXTERN 92 int git_mailmap_from_repository(libgit2_d.types.git_mailmap** out_, libgit2_d.types.git_repository* repo); 93 94 /** 95 * Resolve a name and email to the corresponding real name and email. 96 * 97 * The lifetime of the strings are tied to `mm`, `name`, and `email` parameters. 98 * 99 * Params: 100 * real_name = pointer to store the real name 101 * real_email = pointer to store the real email 102 * mm = the mailmap to perform a lookup with (may be NULL) 103 * name = the name to look up 104 * email = the email to look up 105 * 106 * Returns: 0 on success, or an error code 107 */ 108 //GIT_EXTERN 109 int git_mailmap_resolve(const (char)** real_name, const (char)** real_email, const (libgit2_d.types.git_mailmap)* mm, const (char)* name, const (char)* email); 110 111 /** 112 * Resolve a signature to use real names and emails with a mailmap. 113 * 114 * Call `git_signature_free()` to free the data. 115 * 116 * Params: 117 * out_ = new signature 118 * mm = mailmap to resolve with 119 * sig = signature to resolve 120 * 121 * Returns: 0 or an error code 122 */ 123 //GIT_EXTERN 124 int git_mailmap_resolve_signature(libgit2_d.types.git_signature** out_, const (libgit2_d.types.git_mailmap)* mm, const (libgit2_d.types.git_signature)* sig); 125 126 /** @} */