]> git.proxmox.com Git - libgit2.git/blame - include/git2/common.h
Merge pull request #2144 from linquize/branch-f-current
[libgit2.git] / include / git2 / common.h
CommitLineData
f5918330 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
f5918330 3 *
bb742ede
VM
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.
f5918330 6 */
c15648cb
SP
7#ifndef INCLUDE_git_common_h__
8#define INCLUDE_git_common_h__
9
58519018 10#include <time.h>
00571828 11#include <stdlib.h>
e3fe32b6 12
c060854e
VM
13#ifdef _MSC_VER
14# include "inttypes.h"
15#else
16# include <inttypes.h>
17#endif
18
c15648cb 19#ifdef __cplusplus
87d9869f
VM
20# define GIT_BEGIN_DECL extern "C" {
21# define GIT_END_DECL }
c15648cb 22#else
87d9869f
VM
23 /** Start declarations in C mode */
24# define GIT_BEGIN_DECL /* empty */
25 /** End declarations in C mode */
26# define GIT_END_DECL /* empty */
c15648cb
SP
27#endif
28
16a67770 29/** Declare a public function exported for application use. */
d2a1861e 30#if __GNUC__ >= 4
3b8ab0b9 31# define GIT_EXTERN(type) extern \
87d9869f
VM
32 __attribute__((visibility("default"))) \
33 type
25e9b4dd 34#elif defined(_MSC_VER)
79fdde49 35# define GIT_EXTERN(type) __declspec(dllexport) type
16a67770 36#else
3b8ab0b9 37# define GIT_EXTERN(type) extern type
16a67770
SP
38#endif
39
15bffce9
SP
40/** Declare a function's takes printf style arguments. */
41#ifdef __GNUC__
42# define GIT_FORMAT_PRINTF(a,b) __attribute__((format (printf, a, b)))
43#else
44# define GIT_FORMAT_PRINTF(a,b) /* empty */
45#endif
46
c02f1392 47#if (defined(_WIN32)) && !defined(__CYGWIN__)
0657e46d
RG
48#define GIT_WIN32 1
49#endif
50
0f5e1f3b 51#ifdef __amigaos4__
327fb51c 52#include <netinet/in.h>
0f5e1f3b
CY
53#endif
54
c15648cb 55/**
f5918330 56 * @file git2/common.h
c15648cb
SP
57 * @brief Git common platform definitions
58 * @defgroup git_common Git common platform definitions
59 * @ingroup Git
60 * @{
61 */
c15648cb 62
16a67770 63GIT_BEGIN_DECL
00571828 64
0657e46d
RG
65/**
66 * The separator used in path list strings (ie like in the PATH
67 * environment variable). A semi-colon ";" is used on Windows, and
68 * a colon ":" for all other systems.
69 */
70#ifdef GIT_WIN32
71#define GIT_PATH_LIST_SEPARATOR ';'
72#else
73#define GIT_PATH_LIST_SEPARATOR ':'
74#endif
75
76/**
b1ec25fa 77 * The maximum length of a valid git path.
0657e46d
RG
78 */
79#define GIT_PATH_MAX 4096
80
613d5eb9
PK
81/**
82 * The string representation of the null object ID.
83 */
84#define GIT_OID_HEX_ZERO "0000000000000000000000000000000000000000"
85
536955f9
VM
86/**
87 * Return the version of the libgit2 library
88 * being currently used.
89 *
90 * @param major Store the major version number
91 * @param minor Store the minor version number
92 * @param rev Store the revision (patch) number
93 */
94GIT_EXTERN(void) git_libgit2_version(int *major, int *minor, int *rev);
95
e564e496
SC
96/**
97 * Combinations of these values describe the capabilities of libgit2.
98 */
0f1f9833 99typedef enum {
e564e496 100 GIT_CAP_THREADS = ( 1 << 0 ),
290e1479
RB
101 GIT_CAP_HTTPS = ( 1 << 1 ),
102 GIT_CAP_SSH = ( 1 << 2 ),
0f1f9833 103} git_cap_t;
e564e496
SC
104
105/**
106 * Query compile time options for libgit2.
107 *
108 * @return A combination of GIT_CAP_* values.
109 *
110 * - GIT_CAP_THREADS
0f1f9833
RB
111 * Libgit2 was compiled with thread support. Note that thread support is
112 * still to be seen as a 'work in progress' - basic object lookups are
113 * believed to be threadsafe, but other operations may not be.
e564e496
SC
114 *
115 * - GIT_CAP_HTTPS
0f1f9833
RB
116 * Libgit2 supports the https:// protocol. This requires the openssl
117 * library to be found when compiling libgit2.
e564e496
SC
118 */
119GIT_EXTERN(int) git_libgit2_capabilities(void);
120
59853eff 121
2e62e7c2 122typedef enum {
a0f777c8
VM
123 GIT_OPT_GET_MWINDOW_SIZE,
124 GIT_OPT_SET_MWINDOW_SIZE,
125 GIT_OPT_GET_MWINDOW_MAPPED_LIMIT,
5540d947
RB
126 GIT_OPT_SET_MWINDOW_MAPPED_LIMIT,
127 GIT_OPT_GET_SEARCH_PATH,
128 GIT_OPT_SET_SEARCH_PATH,
d8771592
VM
129 GIT_OPT_SET_CACHE_OBJECT_LIMIT,
130 GIT_OPT_SET_CACHE_MAX_SIZE,
a2378ae4 131 GIT_OPT_ENABLE_CACHING,
b99b10f2
L
132 GIT_OPT_GET_CACHED_MEMORY,
133 GIT_OPT_GET_TEMPLATE_PATH,
134 GIT_OPT_SET_TEMPLATE_PATH
2e62e7c2 135} git_libgit2_opt_t;
59853eff
VM
136
137/**
138 * Set or query a library global option
139 *
140 * Available options:
141 *
b4117e19 142 * * opts(GIT_OPT_GET_MWINDOW_SIZE, size_t *):
59853eff 143 *
b4117e19 144 * > Get the maximum mmap window size
5540d947 145 *
b4117e19 146 * * opts(GIT_OPT_SET_MWINDOW_SIZE, size_t):
5540d947 147 *
b4117e19
CMN
148 * > Set the maximum mmap window size
149 *
150 * * opts(GIT_OPT_GET_MWINDOW_MAPPED_LIMIT, size_t *):
151 *
152 * > Get the maximum memory that will be mapped in total by the library
153 *
154 * * opts(GIT_OPT_SET_MWINDOW_MAPPED_LIMIT, size_t):
155 *
156 * >Set the maximum amount of memory that can be mapped at any time
59853eff
VM
157 * by the library
158 *
b4117e19
CMN
159 * * opts(GIT_OPT_GET_SEARCH_PATH, int level, char *out, size_t len)
160 *
161 * > Get the search path for a given level of config data. "level" must
162 * > be one of `GIT_CONFIG_LEVEL_SYSTEM`, `GIT_CONFIG_LEVEL_GLOBAL`, or
163 * > `GIT_CONFIG_LEVEL_XDG`. The search path is written to the `out`
164 * > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
165 *
166 * * opts(GIT_OPT_SET_SEARCH_PATH, int level, const char *path)
167 *
168 * > Set the search path for a level of config data. The search path
169 * > applied to shared attributes and ignore files, too.
170 * >
171 * > - `path` lists directories delimited by GIT_PATH_LIST_SEPARATOR.
172 * > Pass NULL to reset to the default (generally based on environment
173 * > variables). Use magic path `$PATH` to include the old value
174 * > of the path (if you want to prepend or append, for instance).
175 * >
176 * > - `level` must be GIT_CONFIG_LEVEL_SYSTEM, GIT_CONFIG_LEVEL_GLOBAL,
177 * > or GIT_CONFIG_LEVEL_XDG.
5540d947 178 *
2e62e7c2
RB
179 * * opts(GIT_OPT_SET_CACHE_OBJECT_LIMIT, git_otype type, size_t size)
180 *
181 * > Set the maximum data size for the given type of object to be
182 * > considered eligible for caching in memory. Setting to value to
183 * > zero means that that type of object will not be cached.
184 * > Defaults to 0 for GIT_OBJ_BLOB (i.e. won't cache blobs) and 4k
185 * > for GIT_OBJ_COMMIT, GIT_OBJ_TREE, and GIT_OBJ_TAG.
186 *
187 * * opts(GIT_OPT_SET_CACHE_MAX_SIZE, ssize_t max_storage_bytes)
188 *
189 * > Set the maximum total data size that will be cached in memory
190 * > across all repositories before libgit2 starts evicting objects
191 * > from the cache. This is a soft limit, in that the library might
192 * > briefly exceed it, but will start aggressively evicting objects
193 * > from cache when that happens. The default cache size is 256Mb.
194 *
195 * * opts(GIT_OPT_ENABLE_CACHING, int enabled)
196 *
197 * > Enable or disable caching completely.
198 * >
199 * > Because caches are repository-specific, disabling the cache
200 * > cannot immediately clear all cached objects, but each cache will
201 * > be cleared on the next attempt to update anything in it.
202 *
203 * * opts(GIT_OPT_GET_CACHED_MEMORY, ssize_t *current, ssize_t *allowed)
204 *
205 * > Get the current bytes in cache and the maximum that would be
206 * > allowed in the cache.
207 *
1b57699a 208 * * opts(GIT_OPT_GET_TEMPLATE_PATH, char *out, size_t len)
b99b10f2
L
209 *
210 * > Get the default template path.
211 * > The path is written to the `out`
212 * > buffer up to size `len`. Returns GIT_EBUFS if buffer is too small.
213 *
214 * * opts(GIT_OPT_SET_TEMPLATE_PATH, const char *path)
215 *
216 * > Set the default template path.
217 * >
218 * > - `path` directory of template.
219 *
5540d947
RB
220 * @param option Option key
221 * @param ... value to set the option
222 * @return 0 on success, <0 on failure
59853eff 223 */
5540d947 224GIT_EXTERN(int) git_libgit2_opts(int option, ...);
59853eff 225
c15648cb
SP
226/** @} */
227GIT_END_DECL
b46708aa 228
c15648cb 229#endif