Merge pull request #5128 from tiennou/fix/docs More documentation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
diff --git a/include/git2/apply.h b/include/git2/apply.h
index 09d6521..94bac1f 100644
--- a/include/git2/apply.h
+++ b/include/git2/apply.h
@@ -62,10 +62,15 @@ typedef int GIT_CALLBACK(git_apply_hunk_cb)(
* @see git_apply_to_tree, git_apply
*/
typedef struct {
- unsigned int version;
+ unsigned int version; /**< The version */
+ /** When applying a patch, callback that will be made per delta (file). */
git_apply_delta_cb delta_cb;
+
+ /** When applying a patch, callback that will be made per hunk. */
git_apply_hunk_cb hunk_cb;
+
+ /** Payload passed to both delta_cb & hunk_cb. */
void *payload;
} git_apply_options;
diff --git a/include/git2/buffer.h b/include/git2/buffer.h
index 0027678..926f133 100644
--- a/include/git2/buffer.h
+++ b/include/git2/buffer.h
@@ -32,26 +32,32 @@ GIT_BEGIN_DECL
* a block of memory they hold. In this case, libgit2 will not resize or
* free the memory, but will read from it as needed.
*
- * A `git_buf` is a public structure with three fields:
- *
- * - `ptr` points to the start of the allocated memory. If it is NULL,
- * then the `git_buf` is considered empty and libgit2 will feel free
- * to overwrite it with new data.
- *
- * - `size` holds the size (in bytes) of the data that is actually used.
- *
- * - `asize` holds the known total amount of allocated memory if the `ptr`
- * was allocated by libgit2. It may be larger than `size`. If `ptr`
- * was not allocated by libgit2 and should not be resized and/or freed,
- * then `asize` will be set to zero.
- *
* Some APIs may occasionally do something slightly unusual with a buffer,
* such as setting `ptr` to a value that was passed in by the user. In
* those cases, the behavior will be clearly documented by the API.
*/
typedef struct {
+ /**
+ * The buffer contents.
+ *
+ * `ptr` points to the start of the allocated memory. If it is NULL,
+ * then the `git_buf` is considered empty and libgit2 will feel free
+ * to overwrite it with new data.
+ */
char *ptr;
- size_t asize, size;
+
+ /**
+ * `asize` holds the known total amount of allocated memory if the `ptr`
+ * was allocated by libgit2. It may be larger than `size`. If `ptr`
+ * was not allocated by libgit2 and should not be resized and/or freed,
+ * then `asize` will be set to zero.
+ */
+ size_t asize;
+
+ /**
+ * `size` holds the size (in bytes) of the data that is actually used.
+ */
+ size_t size;
} git_buf;
/**
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index 7b10455..3c87001 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -261,7 +261,7 @@ typedef void GIT_CALLBACK(git_checkout_perfdata_cb)(
*
*/
typedef struct git_checkout_options {
- unsigned int version;
+ unsigned int version; /**< The version */
unsigned int checkout_strategy; /**< default will be a safe checkout */
@@ -271,29 +271,46 @@ typedef struct git_checkout_options {
int file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */
unsigned int notify_flags; /**< see `git_checkout_notify_t` above */
+
+ /**
+ * Optional callback to get notifications on specific file states.
+ * @see git_checkout_notify_t
+ */
git_checkout_notify_cb notify_cb;
+
+ /** Payload passed to notify_cb */
void *notify_payload;
/** Optional callback to notify the consumer of checkout progress. */
git_checkout_progress_cb progress_cb;
+
+ /** Payload passed to progress_cb */
void *progress_payload;
- /** When not zeroed out, array of fnmatch patterns specifying which
- * paths should be taken into account, otherwise all files. Use
- * GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list.
+ /**
+ * A list of wildmatch patterns or paths.
+ *
+ * By default, all paths are processed. If you pass an array of wildmatch
+ * patterns, those will be used to filter which paths should be taken into
+ * account.
+ *
+ * Use GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as a simple list.
*/
git_strarray paths;
- /** The expected content of the working directory; defaults to HEAD.
- * If the working directory does not match this baseline information,
- * that will produce a checkout conflict.
+ /**
+ * The expected content of the working directory; defaults to HEAD.
+ *
+ * If the working directory does not match this baseline information,
+ * that will produce a checkout conflict.
*/
git_tree *baseline;
- /** Like `baseline` above, though expressed as an index. This
- * option overrides `baseline`.
+ /**
+ * Like `baseline` above, though expressed as an index. This
+ * option overrides `baseline`.
*/
- git_index *baseline_index; /**< expected content of workdir, expressed as an index. */
+ git_index *baseline_index;
const char *target_directory; /**< alternative checkout path to workdir */
@@ -303,6 +320,8 @@ typedef struct git_checkout_options {
/** Optional callback to notify the consumer of performance data. */
git_checkout_perfdata_cb perfdata_cb;
+
+ /** Payload passed to perfdata_cb */
void *perfdata_payload;
} git_checkout_options;
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 4303a06..f9454d6 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -495,7 +495,8 @@ typedef int GIT_CALLBACK(git_url_resolve_cb)(git_buf *url_resolved, const char *
* about the progress of the network operations.
*/
struct git_remote_callbacks {
- unsigned int version;
+ unsigned int version; /**< The version */
+
/**
* Textual progress from the remote. Text send over the
* progress side-band will be passed to this function (this is
diff --git a/include/git2/status.h b/include/git2/status.h
index 586d2ca..9693cc4 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -163,27 +163,36 @@ typedef enum {
/**
* Options to control how `git_status_foreach_ext()` will issue callbacks.
*
- * This structure is set so that zeroing it out will give you relatively
- * sane defaults.
+ * Initialize with `GIT_STATUS_OPTIONS_INIT`. Alternatively, you can
+ * use `git_status_options_init`.
*
- * The `show` value is one of the `git_status_show_t` constants that
- * control which files to scan and in what order.
- *
- * The `flags` value is an OR'ed combination of the `git_status_opt_t`
- * values above.
- *
- * The `pathspec` is an array of path patterns to match (using
- * fnmatch-style matching), or just an array of paths to match exactly if
- * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
- *
- * The `baseline` is the tree to be used for comparison to the working directory
- * and index; defaults to HEAD.
*/
typedef struct {
- unsigned int version;
+ unsigned int version; /**< The version */
+
+ /**
+ * The `show` value is one of the `git_status_show_t` constants that
+ * control which files to scan and in what order.
+ */
git_status_show_t show;
+
+ /**
+ * The `flags` value is an OR'ed combination of the `git_status_opt_t`
+ * values above.
+ */
unsigned int flags;
+
+ /**
+ * The `pathspec` is an array of path patterns to match (using
+ * fnmatch-style matching), or just an array of paths to match exactly if
+ * `GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH` is specified in the flags.
+ */
git_strarray pathspec;
+
+ /**
+ * The `baseline` is the tree to be used for comparison to the working directory
+ * and index; defaults to HEAD.
+ */
git_tree *baseline;
} git_status_options;
diff --git a/include/git2/sys/alloc.h b/include/git2/sys/alloc.h
index 642740d..c295807 100644
--- a/include/git2/sys/alloc.h
+++ b/include/git2/sys/alloc.h
@@ -21,51 +21,51 @@ GIT_BEGIN_DECL
* that all fields need to be set to a proper function.
*/
typedef struct {
- /* Allocate `n` bytes of memory */
+ /** Allocate `n` bytes of memory */
void * GIT_CALLBACK(gmalloc)(size_t n, const char *file, int line);
- /*
+ /**
* Allocate memory for an array of `nelem` elements, where each element
* has a size of `elsize`. Returned memory shall be initialized to
* all-zeroes
*/
void * GIT_CALLBACK(gcalloc)(size_t nelem, size_t elsize, const char *file, int line);
- /* Allocate memory for the string `str` and duplicate its contents. */
+ /** Allocate memory for the string `str` and duplicate its contents. */
char * GIT_CALLBACK(gstrdup)(const char *str, const char *file, int line);
- /*
+ /**
* Equivalent to the `gstrdup` function, but only duplicating at most
* `n + 1` bytes
*/
char * GIT_CALLBACK(gstrndup)(const char *str, size_t n, const char *file, int line);
- /*
+ /**
* Equivalent to `gstrndup`, but will always duplicate exactly `n` bytes
* of `str`. Thus, out of bounds reads at `str` may happen.
*/
char * GIT_CALLBACK(gsubstrdup)(const char *str, size_t n, const char *file, int line);
- /*
+ /**
* This function shall deallocate the old object `ptr` and return a
* pointer to a new object that has the size specified by `size`. In
* case `ptr` is `NULL`, a new array shall be allocated.
*/
void * GIT_CALLBACK(grealloc)(void *ptr, size_t size, const char *file, int line);
- /*
+ /**
* This function shall be equivalent to `grealloc`, but allocating
* `neleme * elsize` bytes.
*/
void * GIT_CALLBACK(greallocarray)(void *ptr, size_t nelem, size_t elsize, const char *file, int line);
- /*
+ /**
* This function shall allocate a new array of `nelem` elements, where
* each element has a size of `elsize` bytes.
*/
void * GIT_CALLBACK(gmallocarray)(size_t nelem, size_t elsize, const char *file, int line);
- /*
+ /**
* This function shall free the memory pointed to by `ptr`. In case
* `ptr` is `NULL`, this shall be a no-op.
*/
diff --git a/include/git2/transport.h b/include/git2/transport.h
index 91d27c7..ab45a3a 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -37,7 +37,7 @@ typedef enum {
* Hostkey information taken from libssh2
*/
typedef struct {
- git_cert parent;
+ git_cert parent; /**< The parent cert */
/**
* A hostkey type from libssh2, either
@@ -62,11 +62,13 @@ typedef struct {
* X.509 certificate information
*/
typedef struct {
- git_cert parent;
+ git_cert parent; /**< The parent cert */
+
/**
* Pointer to the X.509 certificate data
*/
void *data;
+
/**
* Length of the memory block pointed to by `data`.
*/
@@ -144,14 +146,16 @@ typedef struct git_cred git_cred;
*/
struct git_cred {
git_credtype_t credtype; /**< A type of credential */
+
+ /** The deallocator for this type of credentials */
void GIT_CALLBACK(free)(git_cred *cred);
};
/** A plaintext username and password */
typedef struct {
- git_cred parent;
- char *username;
- char *password;
+ git_cred parent; /**< The parent cred */
+ char *username; /**< The username to authenticate as */
+ char *password; /**< The password to use */
} git_cred_userpass_plaintext;
@@ -172,33 +176,43 @@ typedef void GIT_CALLBACK(git_cred_ssh_interactive_cb)(const char* name, int nam
* A ssh key from disk
*/
typedef struct git_cred_ssh_key {
- git_cred parent;
- char *username;
- char *publickey;
- char *privatekey;
- char *passphrase;
+ git_cred parent; /**< The parent cred */
+ char *username; /**< The username to authenticate as */
+ char *publickey; /**< The path to a public key */
+ char *privatekey; /**< The path to a private key */
+ char *passphrase; /**< Passphrase used to decrypt the private key */
} git_cred_ssh_key;
/**
* Keyboard-interactive based ssh authentication
*/
typedef struct git_cred_ssh_interactive {
- git_cred parent;
- char *username;
+ git_cred parent; /**< The parent cred */
+ char *username; /**< The username to authenticate as */
+
+ /**
+ * Callback used for authentication.
+ */
git_cred_ssh_interactive_cb prompt_callback;
- void *payload;
+
+ void *payload; /**< Payload passed to prompt_callback */
} git_cred_ssh_interactive;
/**
* A key with a custom signature function
*/
typedef struct git_cred_ssh_custom {
- git_cred parent;
- char *username;
- char *publickey;
- size_t publickey_len;
+ git_cred parent; /**< The parent cred */
+ char *username; /**< The username to authenticate as */
+ char *publickey; /**< The public key data */
+ size_t publickey_len; /**< Length of the public key */
+
+ /**
+ * Callback used to sign the data.
+ */
git_cred_sign_cb sign_callback;
- void *payload;
+
+ void *payload; /**< Payload passed to prompt_callback */
} git_cred_ssh_custom;
/** A key for NTLM/Kerberos "default" credentials */
@@ -206,8 +220,8 @@ typedef struct git_cred git_cred_default;
/** Username-only credential information */
typedef struct git_cred_username {
- git_cred parent;
- char username[1];
+ git_cred parent; /**< The parent cred */
+ char username[1]; /**< The username to authenticate as */
} git_cred_username;
/**