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 * @param out_ pointer to store the new mailmap 30 * @return 0 on success, or an error code 31 */ 32 //GIT_EXTERN 33 int git_mailmap_new(libgit2_d.types.git_mailmap** out_); 34 35 /** 36 * Free the mailmap and its associated memory. 37 * 38 * @param mm the mailmap to free 39 */ 40 //GIT_EXTERN 41 void git_mailmap_free(libgit2_d.types.git_mailmap* mm); 42 43 /** 44 * Add a single entry to the given mailmap object. If the entry already exists, 45 * it will be replaced with the new entry. 46 * 47 * @param mm mailmap to add the entry to 48 * @param real_name the real name to use, or NULL 49 * @param real_email the real email to use, or NULL 50 * @param replace_name the name to replace, or NULL 51 * @param replace_email the email to replace 52 * @return 0 on success, or an error code 53 */ 54 //GIT_EXTERN 55 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); 56 57 /** 58 * Create a new mailmap instance containing a single mailmap file 59 * 60 * @param out_ pointer to store the new mailmap 61 * @param buf buffer to parse the mailmap from 62 * @param len the length of the input buffer 63 * @return 0 on success, or an error code 64 */ 65 //GIT_EXTERN 66 int git_mailmap_from_buffer(libgit2_d.types.git_mailmap** out_, const (char)* buf, size_t len); 67 68 /** 69 * Create a new mailmap instance from a repository, loading mailmap files based 70 * on the repository's configuration. 71 * 72 * Mailmaps are loaded in the following order: 73 * 1. '.mailmap' in the root of the repository's working directory, if present. 74 * 2. The blob object identified by the 'mailmap.blob' config entry, if set. 75 * [NOTE: 'mailmap.blob' defaults to 'HEAD:.mailmap' in bare repositories] 76 * 3. The path in the 'mailmap.file' config entry, if set. 77 * 78 * @param out_ pointer to store the new mailmap 79 * @param repo repository to load mailmap information from 80 * @return 0 on success, or an error code 81 */ 82 //GIT_EXTERN 83 int git_mailmap_from_repository(libgit2_d.types.git_mailmap** out_, libgit2_d.types.git_repository* repo); 84 85 /** 86 * Resolve a name and email to the corresponding real name and email. 87 * 88 * The lifetime of the strings are tied to `mm`, `name`, and `email` parameters. 89 * 90 * @param real_name pointer to store the real name 91 * @param real_email pointer to store the real email 92 * @param mm the mailmap to perform a lookup with (may be NULL) 93 * @param name the name to look up 94 * @param email the email to look up 95 * @return 0 on success, or an error code 96 */ 97 //GIT_EXTERN 98 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); 99 100 /** 101 * Resolve a signature to use real names and emails with a mailmap. 102 * 103 * Call `git_signature_free()` to free the data. 104 * 105 * @param out_ new signature 106 * @param mm mailmap to resolve with 107 * @param sig signature to resolve 108 * @return 0 or an error code 109 */ 110 //GIT_EXTERN 111 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); 112 113 /** @} */