examples


Log

Author Commit Date CI Message
Ashok P. Nadkarni aab7c0ba 2022-02-14T13:57:07 Free parent and ref in lg2_commit before returning.
apnadkarni 77ef1a6e 2022-02-13T14:11:46 Update common.h
Edward Thomson d2458af7 2022-01-22T14:19:13 indexer: use a byte array for checksum The index's checksum is not an object ID, so we should not use the `git_oid` type. Use a byte array for checksum calculation and storage. Deprecate the `git_indexer_hash` function. Callers should use the new `git_indexer_name` function which provides a unique packfile name.
Dimitris Apostolou 90df4302 2022-01-05T12:18:05 Fix typos
Peter Pettersson 7dcc29fc 2021-10-22T22:51:59 Make enum in src,tests and examples C90 compliant by removing trailing comma.
Edward Thomson 395b3dc4 2021-11-11T22:10:51 cmake: refactor global variables Update the global variables `LIBGIT2_OBJECTS` to `LIBGIT2_DEPENDENCY_OBJECTS` for clarity and consistency.
Edward Thomson eabbee04 2021-11-11T12:48:19 example: declare print_usage function
Edward Thomson 8be22614 2021-11-11T12:47:02 examples: remove unused function
Edward Thomson 52693ab4 2021-09-26T23:11:13 cmake: stylistic refactoring Ensure that we always use lowercase function names, and that we do not have spaces preceding open parentheses, for consistency.
Edward Thomson f0e693b1 2021-09-07T17:53:49 str: introduce `git_str` for internal, `git_buf` is external libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
Paymon MARANDI 581cfbda 2021-09-23T11:59:52 examples: Free the git_config and git_config_entry after use
Crayon 59af78a4 2021-07-28T01:58:32 Fix typo in general.c
punkymaniac 8f52b0c5 2021-03-17T10:48:17 Remove duplicate line, in example code
Aaron Franke 7efddeb7 2021-02-15T15:47:28 Fix some typos
Edward Thomson 4732e030 2021-01-31T00:36:54 revspec: rename git_revparse_mode_t to git_revspec_t The information about the type of a revision spec is not information about the parser. Name it accordingly, so that `git_revparse_mode_t` is now `git_revspec_t`. Deprecate the old name.
Patrick Steinhardt 939cb73f 2020-06-08T15:28:20 examples: log: fix documentation generation Docurium seems to be confused by our use of `/** comment */;` use in the log example. Let's just switch it around to help Docurium get this right.
Edward Thomson 51eff5a5 2020-05-29T13:13:19 strarray: we should `dispose` instead of `free` We _dispose_ the contents of objects; we _free_ objects (and their contents). Update `git_strarray_free` to be `git_strarray_dispose`. `git_strarray_free` remains as a deprecated proxy function.
Peter Salomonsen dc2beb7e 2020-02-24T18:30:16 examples: additions and fixes add example for git commit fix example for git add add example for git push
Edward Thomson 3f54ba8b 2020-01-18T13:51:40 credential: change git_cred to git_credential We avoid abbreviations where possible; rename git_cred to git_credential. In addition, we have standardized on a trailing `_t` for enum types, instead of using "type" in the name. So `git_credtype_t` has become `git_credential_t` and its members have become `GIT_CREDENTIAL` instead of `GIT_CREDTYPE`. Finally, the source and header files have been renamed to `credential` instead of `cred`. Keep previous name and values as deprecated, and include the new header files from the previous ones.
Patrick Steinhardt d2d01f71 2019-12-13T11:49:37 Merge pull request #5283 from pks-t/pks/example-checkout-remote-branch examples: checkout: implement guess heuristic for remote branches
Patrick Steinhardt dfea0713 2019-11-28T13:51:40 Merge pull request #5272 from tiennou/examples/cli-ification Various examples shape-ups
Edward Thomson f94c9276 2019-10-27T22:20:38 example: use `git_object_size_t` for object size
Etienne Samson fe42557a 2019-11-06T11:08:52 examples: buff up rev-list by adding OID support This allows the example to be used as a quick revwalk test harness.
Etienne Samson 313908f9 2019-11-06T11:08:49 examples: normalize decls and usage of options structs
Etienne Samson 4a4ad2bc 2019-11-06T11:08:45 examples: add comments to add.c
Etienne Samson d4a593ef 2019-11-06T11:17:52 examples: modernize add code
Etienne Samson c9a09b91 2019-11-06T11:16:47 examples: extract argument conversion helper
Etienne Samson 204a464f 2019-11-06T11:08:39 examples: fixup for-each-ref style
Etienne Samson c924f36a 2019-11-06T11:08:35 examples: keep track of whether we processed a "--" arg
Etienne Samson 025a9357 2019-11-06T11:08:30 examples: move "args" to its own header
Etienne Samson 745ccc8a 2019-11-06T11:08:26 examples: remove duplicate includes from common.c
Etienne Samson cd5e33fb 2019-11-06T11:08:23 global: DRY includes of assert.h
Etienne Samson 882220bf 2019-11-06T11:08:19 examples: add missing include barriers
Etienne Samson 4867523e 2019-11-06T11:08:15 examples: add *.h files to IDEs
Patrick Steinhardt a9b5270b 2019-10-07T21:18:19 examples: checkout: implement guess heuristic for remote branches
Edward Thomson 5774b2b1 2019-08-11T23:42:45 Merge pull request #5113 from pks-t/pks/stash-perf stash: avoid recomputing tree when committing worktree
Patrick Steinhardt 24c491ed 2019-08-02T07:58:11 Merge pull request #5146 from scottfurry/StaticFixesExamples Adjust printf specifiers in examples code
Scott Furry 73a186f2 2019-06-27T10:02:40 Adjust printf specifiers in examples code Static analysis of example code found multiple findings of `printf` usage where filling value is members of git_indexer_progress object. Specifier used was for signed int but git_indexer_progress members are typed as unsigned ints. `printf` specifiers were altered to match type.
Patrick Steinhardt ac171542 2019-08-01T17:45:14 Merge pull request #5184 from novalis/fix-example Fix example checkout to forbid rather than require --
Patrick Steinhardt 56e7aaf0 2019-08-01T12:40:51 Merge pull request #5125 from albfan/wip/albfan/diff_buffers Compare buffers in diff example
David Turner ed387d4a 2019-07-24T12:01:27 Fix example checkout to forbid rather than require -- Make the example program for checkout follow git syntax, where "--" indicates a file. This was likely just a strcmp return value confusion.
Patrick Steinhardt 88731e3c 2019-06-14T12:34:37 examples: implement git-stash example Implement a new example that resembles the git-stash(1) command. Right now, it only provides the apply, list, save and pop subcommands without any options. This example is mostly used to test libgit2's stashing performance on big repositories.
Patrick Steinhardt 8ee3d39a 2019-06-27T09:18:19 examples: implement config example Implement a new example that resembles git-config(1). Right now, this example can both read and set configuration keys, only.
Patrick Steinhardt 960d2a07 2019-07-05T14:30:48 examples: consolidate includes into "common.h" Consolidate all standard includes and defines into "common.h". This lets us avoid having to handle platform-specific things in multiple places.
Alberto Fanjul 3be09b6c 2019-06-18T08:31:31 Compare buffers in diff example
Patrick Steinhardt 398412cc 2019-07-05T11:56:16 Merge pull request #5143 from libgit2/ethomson/warnings ci: build with ENABLE_WERROR on Windows
Patrick Steinhardt 2dea4736 2019-06-27T15:27:29 examples: avoid warning when iterating over index entries When iterating over index entries, we store the indices in an unsigned int. As the index entrycount is a `size_t` though, this may be a loss of precision which a compiler might rightfully complain about. Use `size_t` instead to fix any warnings.
Patrick Steinhardt abf24a30 2019-06-27T15:25:17 examples: avoid conversion warnings when calculating progress When computing the progress, we perform some arithmetics that are implicitly converting from `size_t` to `int`. In one case we're calclulating a percentage, so we know that it should always be in the range of [0,100] and thus we're fine. In the other case we convert from bytes to kilobytes -- this should be stored in a `size_t` to avoid loss of precision, even though it probably won't matter due to limited download rates.
Patrick Steinhardt e7bb1fe8 2019-06-27T15:14:08 examples: avoid passing signed integer to `memchr` The memchr(3P) function expects a `size_t` as its last parameter, but we do pass it an object size, which is of signed type `git_off_t`. As we can be sure that the result will be non-negative, let's just cast the parameter to a `size_t`.
Patrick Steinhardt 976eed80 2019-06-27T15:12:11 examples: cast away constness for reallocating head arrays When reallocating commit arrays in `opts_add_commit` and `opts_add_refish`, respectively, we simply pass the const pointer to `xrealloc`. As `xrealloc` expects a non-const pointer, though, this will generate a warning with some compilers. Cast away the constness to silence compilers.
Scott Furry 2ba7dbbe 2019-06-24T14:55:15 Resolve static check warnings in example code Using cppcheck on libgit2 sources indicated two warnings in example code. merge.c was reported as having a memory leak. Fix applied was to `free()` memory pointed to by `parents`. init.c was reported as having a null pointer dereference on variable arg. Function 'usage' was being called with a null variable. Changed supplied parameter to empty string.
Edward Thomson b6b2d9d7 2019-06-25T15:05:23 examples: ssize_t is signed, not unsigned
Edward Thomson cd67a903 2019-06-25T14:55:51 examples: cast away const-ness
Edward Thomson 1118dd9a 2019-06-25T14:50:12 examples: don't lose `const`
Edward Thomson ede458b4 2019-06-25T14:48:10 example: use `git_off_t` for the object size
Edward Thomson 5d92e547 2019-06-08T17:28:35 oid: `is_zero` instead of `iszero` The only function that is named `issomething` (without underscore) was `git_oid_iszero`. Rename it to `git_oid_is_zero` for consistency with the rest of the library.
Edward Thomson 0b5ba0d7 2019-06-06T16:36:23 Rename opt init functions to `options_init` In libgit2 nomenclature, when we need to verb a direct object, we name a function `git_directobject_verb`. Thus, if we need to init an options structure named `git_foo_options`, then the name of the function that does that should be `git_foo_options_init`. The previous names of `git_foo_init_options` is close - it _sounds_ as if it's initializing the options of a `foo`, but in fact `git_foo_options` is its own noun that should be respected. Deprecate the old names; they'll now call directly to the new ones.
Patrick Steinhardt 172786ec 2019-04-16T12:03:20 examples: use username provided via URL The credentials callback may be passed a username in case where the URL already includes the expected username. As we usually cannot use a different username in such context, we should use that one if provided and not ask the user for a diferent username.
Patrick Steinhardt 611fbe4f 2019-04-16T12:02:20 examples: implement SSH key credentials Implement SSH key credentials. This allows users to use the SSH transport with the lg2 example code.
Patrick Steinhardt d9351c65 2019-04-16T11:05:37 examples: implement SSH key credentials Implement SSH key credentials. This allows users to use the SSH transport with the lg2 example code.
Patrick Steinhardt e9aa8479 2019-04-16T10:52:47 examples: support plain username credentials Implement plain username credential types. These type of credentials might be asked for e.g. as some kind of pre-authentication step, before the actual credentials are passed.
Patrick Steinhardt 635ec366 2019-04-16T10:51:43 examples: honor allowed credential types when prompting user Credential callback are being passed a bitset that indicates which credential types are allowed in the current context. In our examples code, we completely ignore that field and always return username/password credentials, which doesn't necessarily make sense e.g. when only SSH keys are allowed. Refactor the code and only return username/password credentials in the case where `USERPASS_PLAINTEXT` credentials are allowed. Otherwise, return a positive error code to indicate that no credentials could be acquired.
Patrick Steinhardt b106620d 2019-04-16T10:56:18 examples: move MSVC compatibility macros into common header We currently have two locations in our examples where we define the same compatibility wrappers for MSVC. Move them into "common.h" to avoid duplication and make them available to other examples.
Edward Thomson a1ef995d 2019-02-21T10:33:30 indexer: use git_indexer_progress throughout Update internal usage of `git_transfer_progress` to `git_indexer_progreses`.
Etienne Samson 6cf47726 2019-01-15T13:54:18 examples/add: add explanatory comments and reformat
Patrick Steinhardt 106998fc 2019-01-24T11:48:44 examples: print available commands if no args are given
Patrick Steinhardt ead10785 2019-01-24T11:31:49 examples: create common lg2 executable Inside of our networking example code, we have a git2 executable that acts as an entry point to all the different network examples. As such, it is kind of the same like the normal git(1) executable in that it simply arbitrates to the respective subcommands. Let's extend this approach and merge all examples into a single standalone lg2 executable. Instead of building an executable for all the existing examples we have, we now bundle them all inside of the lg2 one and let them be callable via subcommands. In the process, we can get rid of duplicated library initialization, deinitialization and repository discovery code. Instead of having each subcommand handle these on its own, we simply do it inside of the single main function now.
Patrick Steinhardt 7562422a 2019-01-24T10:30:58 examples: merge common network code Right now, we have two sets of "common" code, one containing general common code and one containing network common code. As we intend to get rid of the network subdirectory and instead merge all examples into a single standalone executable, this distinction doesn't make a lot of sense now. Furthermore, the common network code is not that big. Let's get rid of the common network code by merging it into the general common code.
Patrick Steinhardt c4271314 2019-01-24T10:27:07 examples: remove unused Makefile This Makefile isn't used anymore and probably won't work anyway. Remove it in favor of the existing CMake build instructions.
Patrick Steinhardt a540e6bb 2019-01-24T10:07:31 examples: remove test script In commit 2e2332857 (examples: a test, for rev-list, 2013-03-20), a script was introduced with the intention of testing our rev-list example code. Nobody uses that script, and in fact it doesn't even properly work due to the not-so-recent addition out-of-source builds. Remove the script.
Edward Thomson 24ac9e0c 2019-02-13T23:26:54 deprecation: ensure we GIT_EXTERN deprecated funcs Although the error functions were deprecated, we did not properly mark them as deprecated. We need to include the `deprecated.h` file in order to ensure that the functions get their export attributes. Similarly, do not define `GIT_DEPRECATE_HARD` within the library, or those functions will also not get their export attributes. Define that only on the tests and examples.
Edward Thomson cc5da0a6 2019-01-23T09:36:52 examples: don't use deprecated types
Edward Thomson fcc7dcb1 2019-01-10T22:39:56 errors: remove giterr usage in examples
Edward Thomson 1758636b 2019-01-19T01:38:34 Merge pull request #4939 from libgit2/ethomson/git_ref Move `git_ref_t` to `git_reference_t`
Edward Thomson 83151018 2019-01-17T10:47:32 object_type: convert final internal users to new names Update some missed types that were continuing to use the old `GIT_OBJ` names.
Edward Thomson ed8cfbf0 2019-01-17T00:32:31 references: use new names in internal usage Update internal usage to use the `git_reference` names for constants.
Edward Thomson 50186ce8 2018-08-26T11:26:45 Merge pull request #4374 from pks-t/pks/pack-file-verify Pack file verification
Patrick Steinhardt ea9e2c1a 2018-07-20T13:06:56 Merge pull request #4692 from tiennou/examples/checkout Add a checkout example
Etienne Samson b24202e1 2018-07-07T12:52:24 examples: add checkout
Patrick Steinhardt e1a4a8eb 2018-06-25T11:58:34 cmake: enforce C90 standard While the aim of libgit2 was to conform to C90 code, we never instructed the compiler to enforce C90 compliance. Thus, quite a few violations were able to get into our code base, which have been removed with the previous commits. As we are now able to build libgit2 with C90 enforced, we can set the C_STANDARD property for our own build targets. Note that we explicitly avoid setting the C standard for our third-party dependencies. At least the zlib target does not build with C90 enforced, and we do not want to fix them by deviating from upstream. Thus we simply enforce no standard for them.
Patrick Steinhardt c13e56f9 2018-06-25T14:12:53 cmake: distinguish internal and system include directories While we want to enforce strict C90 mode, this may cause issues with system provided header files which are themselves not strictly conforming. E.g. if a system header has C++ style comments, a compiler in strict C90 mode would produce an error and abort the build. As the user most likely doesn't want to change the system header, this would completely break the build on such systems. One example of this is mbedtls, which provides such header files. The problem can be worked around by distinguishing between system-provided and project-provided include directories. When adding include directories via "-isystem" instead of "-I", the compiler will skip certain checks and print out less warnings. To use system includes, we can simply add the "SYSTEM" flag to CMake's `INCLUDE_DIRECTORIES` and `TARGET_INCLUDE_DIRECTORIES` functions. Note that we have to split the include directories into two variables because of this, as we definitely still want to check for all warnings produced by our own header files.
Patrick Steinhardt 9994cd3f 2018-06-25T11:56:52 treewide: remove use of C++ style comments C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
Etienne Samson 5b7ba786 2018-06-23T15:45:04 examples: add a helper for boolean-style options
Etienne Samson 8e063eb6 2018-06-23T15:44:35 examples: make the refish resolution work with short OIDs
Etienne Samson 8a629afe 2018-01-31T00:02:00 examples: move refish resolution function in common
Patrick Steinhardt c16556aa 2017-11-12T10:31:48 indexer: introduce options struct to `git_indexer_new` We strive to keep an options structure to many functions to be able to extend options in the future without breaking the API. `git_indexer_new` doesn't have one right now, but we want to be able to add an option for enabling strict packfile verification. Add a new `git_indexer_options` structure and adjust callers to use that.
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Patrick Steinhardt f9cf9a04 2018-05-09T14:51:57 Merge pull request #4642 from pks-t/pks/cmake-resolve-pkgconfig cmake: resolve libraries found by pkg-config
Patrick Steinhardt 8ab470f5 2018-04-27T15:31:43 cmake: remove now-useless LIBGIT2_LIBDIRS handling With the recent change of always resolving pkg-config libraries to their full path, we do not have to manage the LIBGIT2_LIBDIRS variable anymore. The only other remaining user of LIBGIT2_LIBDIRS is winhttp, which is a CMake-style library target and can thus be resolved by CMake automatically. Remove the variable to simplify our build system a bit.
Carson Howard 8aa437ef 2018-05-02T07:55:26 tests: ls-files: use puts instead of printf and fix typos
Carson Howard d7394c36 2018-03-27T07:21:02 examples: ls-files: print entry path only when entry is found
Carson Howard 29ca3f33 2018-01-06T11:26:41 examples: ls-files: update print_paths to print all cases
Carson Howard 7d079413 2017-12-19T15:29:40 test: ls-files: remove dependency on git_array
Carson Howard ee144650 2017-11-13T21:03:21 examples: ls-files: fix build error
Carson Howard e8661169 2017-11-13T20:52:31 examples: ls-files: address PR and style
Carson Howard 3f64a9db 2017-10-25T19:19:17 examples: ls-files: use git_array_t to handle files
Carson Howard 37cbc3ea 2017-10-23T09:54:39 examples: ls-files: build file list with array
Carson Howard d2f99e0a 2017-10-22T21:23:40 examples: ls-files: fix compile error
Carson Howard cd39273d 2017-10-22T20:43:22 examples: ls-files: fix style and refactor
Carson Howard 52d83dde 2017-10-17T21:10:54 examples: ls-files: handle --error-unmatch