Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:38

0001 /*
0002  * Copyright (C) the libgit2 contributors. All rights reserved.
0003  *
0004  * This file is part of libgit2, distributed under the GNU GPL v2 with
0005  * a Linking Exception. For full terms see the included COPYING file.
0006  */
0007 #ifndef INCLUDE_git_mailmap_h__
0008 #define INCLUDE_git_mailmap_h__
0009 
0010 #include "common.h"
0011 #include "types.h"
0012 #include "buffer.h"
0013 
0014 /**
0015  * @file git2/mailmap.h
0016  * @brief Mailmap parsing routines
0017  * @defgroup git_mailmap Git mailmap routines
0018  * @ingroup Git
0019  * @{
0020  */
0021 GIT_BEGIN_DECL
0022 
0023 /**
0024  * Allocate a new mailmap object.
0025  *
0026  * This object is empty, so you'll have to add a mailmap file before you can do
0027  * anything with it. The mailmap must be freed with 'git_mailmap_free'.
0028  *
0029  * @param out pointer to store the new mailmap
0030  * @return 0 on success, or an error code
0031  */
0032 GIT_EXTERN(int) git_mailmap_new(git_mailmap **out);
0033 
0034 /**
0035  * Free the mailmap and its associated memory.
0036  *
0037  * @param mm the mailmap to free
0038  */
0039 GIT_EXTERN(void) git_mailmap_free(git_mailmap *mm);
0040 
0041 /**
0042  * Add a single entry to the given mailmap object. If the entry already exists,
0043  * it will be replaced with the new entry.
0044  *
0045  * @param mm mailmap to add the entry to
0046  * @param real_name the real name to use, or NULL
0047  * @param real_email the real email to use, or NULL
0048  * @param replace_name the name to replace, or NULL
0049  * @param replace_email the email to replace
0050  * @return 0 on success, or an error code
0051  */
0052 GIT_EXTERN(int) git_mailmap_add_entry(
0053     git_mailmap *mm, const char *real_name, const char *real_email,
0054     const char *replace_name, const char *replace_email);
0055 
0056 /**
0057  * Create a new mailmap instance containing a single mailmap file
0058  *
0059  * @param out pointer to store the new mailmap
0060  * @param buf buffer to parse the mailmap from
0061  * @param len the length of the input buffer
0062  * @return 0 on success, or an error code
0063  */
0064 GIT_EXTERN(int) git_mailmap_from_buffer(
0065     git_mailmap **out, const char *buf, size_t len);
0066 
0067 /**
0068  * Create a new mailmap instance from a repository, loading mailmap files based
0069  * on the repository's configuration.
0070  *
0071  * Mailmaps are loaded in the following order:
0072  *  1. '.mailmap' in the root of the repository's working directory, if present.
0073  *  2. The blob object identified by the 'mailmap.blob' config entry, if set.
0074  *     [NOTE: 'mailmap.blob' defaults to 'HEAD:.mailmap' in bare repositories]
0075  *  3. The path in the 'mailmap.file' config entry, if set.
0076  *
0077  * @param out pointer to store the new mailmap
0078  * @param repo repository to load mailmap information from
0079  * @return 0 on success, or an error code
0080  */
0081 GIT_EXTERN(int) git_mailmap_from_repository(
0082     git_mailmap **out, git_repository *repo);
0083 
0084 /**
0085  * Resolve a name and email to the corresponding real name and email.
0086  *
0087  * The lifetime of the strings are tied to `mm`, `name`, and `email` parameters.
0088  *
0089  * @param real_name pointer to store the real name
0090  * @param real_email pointer to store the real email
0091  * @param mm the mailmap to perform a lookup with (may be NULL)
0092  * @param name the name to look up
0093  * @param email the email to look up
0094  * @return 0 on success, or an error code
0095  */
0096 GIT_EXTERN(int) git_mailmap_resolve(
0097     const char **real_name, const char **real_email,
0098     const git_mailmap *mm, const char *name, const char *email);
0099 
0100 /**
0101  * Resolve a signature to use real names and emails with a mailmap.
0102  *
0103  * Call `git_signature_free()` to free the data.
0104  *
0105  * @param out new signature
0106  * @param mm mailmap to resolve with
0107  * @param sig signature to resolve
0108  * @return 0 or an error code
0109  */
0110 GIT_EXTERN(int) git_mailmap_resolve_signature(
0111     git_signature **out, const git_mailmap *mm, const git_signature *sig);
0112 
0113 /** @} */
0114 GIT_END_DECL
0115 #endif