Commit Graph

443 Commits

Author SHA1 Message Date
Edward Thomson
fe2ee3a018 object: lookup sha256 objects
This is much of the plumbing for the object database to support SHA256,
and for objects to be able to parse SHA256 versions of themselves.
2023-02-12 22:02:00 +00:00
Edward Thomson
b43567d655 sha256: indirection for experimental functions
The experimental function signature is only available when
`GIT_EXPERIMENTAL_SHA256` is enabled.
2022-07-13 22:50:33 -04:00
Edward Thomson
3fbf580c91 oid: give oids a type
`git_oid`s now have a type, and we require the oid type when creating
the object id from creation functions.
2022-06-20 17:05:29 -04:00
Edward Thomson
0acaf3a8eb oid: define GIT_OID_SHA1_ZERO
Callers should not assume the layout of the oid structure; provide them
a macro that defines the null / zero sha1 object id.
2022-06-14 22:29:57 -04:00
Edward Thomson
dbc4ac1c76 oid: GIT_OID_*SZ is now GIT_OID_SHA1_*SIZE
In preparation for SHA256 support, `GIT_OID_RAWSZ` and `GIT_OID_HEXSZ`
need to indicate that they're the size of _SHA1_ OIDs.
2022-06-14 22:29:57 -04:00
Edward Thomson
91ba089663 cmake: rename git2internal target to libgit2
The `git2internal` target is actually the git library; call it such so
that IDE users have visibility into it.
2022-02-22 22:07:44 -05:00
Edward Thomson
5fcfada500 cmake: document CMakeLists.txt hierarchy 2022-02-22 22:07:44 -05:00
Ashok P. Nadkarni
aab7c0babc Free parent and ref in lg2_commit before returning. 2022-02-14 13:57:07 +05:30
apnadkarni
77ef1a6e14 Update common.h 2022-02-13 14:11:46 +05:30
Edward Thomson
d2458af7b7 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.
2022-01-27 20:15:09 -05:00
Dimitris Apostolou
90df43022a Fix typos 2022-01-05 16:35:52 +02:00
Peter Pettersson
7dcc29fc46 Make enum in src,tests and examples C90 compliant by removing trailing comma. 2021-11-15 16:45:40 +01:00
Edward Thomson
395b3dc403 cmake: refactor global variables
Update the global variables `LIBGIT2_OBJECTS` to
`LIBGIT2_DEPENDENCY_OBJECTS` for clarity and consistency.
2021-11-14 07:25:41 -05:00
Edward Thomson
eabbee0454 example: declare print_usage function 2021-11-11 17:21:32 -05:00
Edward Thomson
8be226148f examples: remove unused function 2021-11-11 17:21:32 -05:00
Edward Thomson
52693ab44e cmake: stylistic refactoring
Ensure that we always use lowercase function names, and that we do not
have spaces preceding open parentheses, for consistency.
2021-10-18 08:30:14 -04:00
Edward Thomson
f0e693b18a 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.
2021-10-17 09:49:01 -04:00
Paymon MARANDI
581cfbda85 examples: Free the git_config and git_config_entry after use 2021-09-24 14:14:59 -04:00
Crayon
59af78a48f Fix typo in general.c 2021-07-28 01:58:32 -04:00
punkymaniac
8f52b0c553 Remove duplicate line, in example code 2021-03-17 10:48:17 +01:00
Aaron Franke
7efddeb737 Fix some typos 2021-02-15 16:01:25 -05:00
Edward Thomson
4732e03056 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.
2021-01-31 16:36:31 +00:00
Patrick Steinhardt
939cb73fdf 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.
2020-06-08 15:43:34 +02:00
Edward Thomson
51eff5a58b 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.
2020-06-01 22:50:28 +01:00
Peter Salomonsen
dc2beb7e2d examples: additions and fixes
add example for git commit
fix example for git add
add example for git push
2020-04-02 18:39:37 +02:00
Edward Thomson
3f54ba8b61 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.
2020-01-26 18:39:41 +00:00
Patrick Steinhardt
d2d01f7152 Merge pull request #5283 from pks-t/pks/example-checkout-remote-branch
examples: checkout: implement guess heuristic for remote branches
2019-12-13 11:49:37 +01:00
Patrick Steinhardt
dfea0713e0 Merge pull request #5272 from tiennou/examples/cli-ification
Various examples shape-ups
2019-11-28 13:51:40 +01:00
Edward Thomson
f94c9276bc example: use git_object_size_t for object size 2019-11-22 15:23:46 +11:00
Etienne Samson
fe42557a6f examples: buff up rev-list by adding OID support
This allows the example to be used as a quick revwalk test harness.
2019-11-06 11:17:56 +01:00
Etienne Samson
313908f9f5 examples: normalize decls and usage of options structs 2019-11-06 11:17:56 +01:00
Etienne Samson
4a4ad2bc83 examples: add comments to add.c 2019-11-06 11:17:55 +01:00
Etienne Samson
d4a593ef78 examples: modernize add code 2019-11-06 11:17:52 +01:00
Etienne Samson
c9a09b91c4 examples: extract argument conversion helper 2019-11-06 11:16:47 +01:00
Etienne Samson
204a464f42 examples: fixup for-each-ref style 2019-11-06 11:12:34 +01:00
Etienne Samson
c924f36a8b examples: keep track of whether we processed a "--" arg 2019-11-06 11:12:34 +01:00
Etienne Samson
025a93577d examples: move "args" to its own header 2019-11-06 11:12:34 +01:00
Etienne Samson
745ccc8ab9 examples: remove duplicate includes from common.c 2019-11-06 11:08:26 +01:00
Etienne Samson
cd5e33fbc2 global: DRY includes of assert.h 2019-11-06 11:08:23 +01:00
Etienne Samson
882220bf11 examples: add missing include barriers 2019-11-06 11:08:19 +01:00
Etienne Samson
4867523e60 examples: add *.h files to IDEs 2019-11-06 11:08:15 +01:00
Patrick Steinhardt
a9b5270b9a examples: checkout: implement guess heuristic for remote branches 2019-10-25 08:11:28 +02:00
Edward Thomson
5774b2b134 Merge pull request #5113 from pks-t/pks/stash-perf
stash: avoid recomputing tree when committing worktree
2019-08-11 23:42:45 +01:00
Patrick Steinhardt
24c491ed00 Merge pull request #5146 from scottfurry/StaticFixesExamples
Adjust printf specifiers in examples code
2019-08-02 07:58:11 +02:00
Scott Furry
73a186f28a 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.
2019-08-01 12:52:12 -06:00
Patrick Steinhardt
ac171542a6 Merge pull request #5184 from novalis/fix-example
Fix example checkout to forbid rather than require --
2019-08-01 17:45:14 +02:00
Patrick Steinhardt
56e7aaf044 Merge pull request #5125 from albfan/wip/albfan/diff_buffers
Compare buffers in diff example
2019-08-01 12:40:51 +02:00
David Turner
ed387d4af6 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.
2019-07-24 12:01:27 -04:00
Patrick Steinhardt
88731e3c33 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.
2019-07-20 19:10:57 +02:00
Patrick Steinhardt
8ee3d39afd 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.
2019-07-11 08:28:55 +02:00