71 Commits

Author SHA1 Message Date
qaqland
196c465995 examples: correct git_commit_time comment 2025-12-31 16:36:04 +08:00
Edward Thomson
c26d8a8b54 sha256: further API simplifications for OID parsing
Introduce `git_oid_from_string`, `git_oid_from_prefix`, and
`git_oid_from_raw`, all of which take a `git_oid_t` that indicates what
type of OID should be parsed (SHA1 or SHA256).

This allows users to continue to use `git_oid_fromstr` without any code
changes, while remaining in a SHA1 world.

Note that these are not perfect analogs to the `fromstr` APIs.

* `git_oid_from_string` now takes a NUL terminated string, instead of
  allowing for non-NUL terminated strings. Adding a NUL check feels like
  an important safety consideration for C strings.
* `git_oid_from_prefix` should be used for an OID substring and length.

Previous usages of `git_oid_fromstr` with non-NUL terminated strings
should move to `git_oid_from_prefix` with the hexsize for the given OID
type.
2025-01-02 13:13:59 +00:00
Sven Strickroth
6c7df67071 Consistently use libgit2.org
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2024-03-01 14:45:08 +01:00
Sven Strickroth
bd242a05e2 Fix broken links
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2024-02-24 14:35:10 +01: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
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
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
Patrick Steinhardt
960d2a070f 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.
2019-07-05 14:30:48 +02:00
Patrick Steinhardt
2dea47362e 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.
2019-07-05 11:28:57 +02:00
Patrick Steinhardt
ead10785dc 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.
2019-02-15 12:06:54 +01:00
Edward Thomson
cc5da0a63d examples: don't use deprecated types 2019-01-25 09:06:50 +00:00
Edward Thomson
fcc7dcb176 errors: remove giterr usage in examples 2019-01-22 22:30:37 +00:00
Edward Thomson
1758636b13 Merge pull request #4939 from libgit2/ethomson/git_ref
Move `git_ref_t` to `git_reference_t`
2019-01-19 01:38:34 +00:00
Edward Thomson
83151018ef object_type: convert final internal users to new names
Update some missed types that were continuing to use the old `GIT_OBJ`
names.
2019-01-17 11:03:19 +00:00
Edward Thomson
ed8cfbf041 references: use new names in internal usage
Update internal usage to use the `git_reference` names for constants.
2019-01-17 10:32:29 +00:00
Patrick Steinhardt
9994cd3f0f 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.
2018-07-13 08:25:12 +02:00
Douglas Swanson
f4770e4757 Fix Issue #4047 Check return codes and free objects 2017-10-07 01:29:21 +01:00
Patrick Steinhardt
f9ea8c6a14 examples: general: fix memory leaks 2017-01-12 22:04:36 +01:00
Patrick Steinhardt
ed2b1c7e75 examples: general: display config only if it was found 2017-01-12 22:01:45 +01:00
Patrick Steinhardt
5aa101078e examples: general: narrow down scope of loop variables 2017-01-12 22:01:23 +01:00
Patrick Steinhardt
8572e2252b examples: general: clean up committer/author variables 2017-01-12 22:00:53 +01:00
Douglas Swanson
832278bf36 Fix issue #4046 Seg fault in config_files() 2016-12-29 07:43:03 -07:00
Patrick Steinhardt
e2d1b7ecbf examples: general: fix remaining warnings 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
662eee1541 examples: general: convert C99 comments to C90 comments 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
c313e3d986 examples: general: extract function demonstrating OID parsing 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
29d9afc0fb examples: general: extract function demonstrating ODB 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
b009adad35 examples: general: extract function demonstrating commit writing 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
15960454c5 examples: general: extract functions demonstrating object parsing 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
8b93ccdf08 examples: general: extract function demonstrating revwalking 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
c079e3c847 examples: general: extract function demonstrating index walking 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
f9a7973dd9 examples: general: extract function demonstrating reference listings 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
986913f45b examples: general: extract function demonstrating config files 2016-10-10 09:04:41 +02:00
Patrick Steinhardt
176d58bad4 examples: general: use tabs instead of spaces 2016-10-10 09:04:41 +02:00
Patrick McKenna
698e0c2777 Update link to Pro Git's Git internals chapter. 2016-03-07 16:34:30 -08:00
Will Stamper
b874629b2d Spelling fixes 2014-12-04 21:06:59 -06:00
Carlos Martín Nieto
799e22ea0c Rename git_threads_ to git_libgit2_
This describes their purpose better, as we now initialize ssl and some
other global stuff in there. Calling the init function is not something
which has been optional for a while now.
2014-11-08 23:46:39 +01:00
Ciro Santilli
3b2cb2c91e Factor 40 and 41 constants from source. 2014-09-16 13:07:04 +02:00
Linquize
fbc5661ebf MSVC doesn't like modern code neither 2014-01-27 20:52:57 +08:00
Ben Straub
83e1efbf46 Update files that reference tests-clar 2013-11-14 14:10:32 -08:00
Ben Straub
6cb831bd56 Replace copyright topmatter in example files 2013-11-02 05:33:26 -07:00
Carlos Martín Nieto
2b562c3a1e refs: remove the OID/SYMBOLIC filtering
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.

As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
2013-05-11 11:20:38 +02:00
Vicent Marti
0d3ccf0b28 examples: Don't print weird characters 2013-04-10 16:41:05 +02:00
Ben Straub
f8591e519a General example: run against testrepo.git
Fixes #1455
2013-04-04 11:44:50 -07:00
Russell Belfer
a7ed746093 Add rudimentary error checks and reformat comments
There were a number of functions assigning their return value to
`error` without much explanation.  I added in some rudimentary
error checking to help flesh out the example.

Also, I reformatted all of the comments down to 80 cols (and in
some cases, slightly updated the wording).
2013-02-15 15:58:13 -08:00
Carlos Scheidegger
ef41ab880c removed other references to api.html 2013-02-06 17:37:51 -05:00
Ben Straub
f45d51ff8e API updates for index.h 2012-11-27 13:18:28 -08:00