Commit Graph

335 Commits

Author SHA1 Message Date
Carlos Martín Nieto
37a0165f8d examples: adjust merge to git_commit_create_on
This should be a good place to eventually make use of `_fromstate` depending on
what we're trying to show in this example.
2018-03-22 16:35:23 +01:00
Etienne Samson
33f44db9d0 examples: zero out our options memory before use 2018-01-25 22:17:39 +01:00
Etienne Samson
fb79d7d12e examples: our/their can be NULL 2018-01-25 22:14:39 +01:00
Etienne Samson
cc845595f0 examples: fix remaining review comments 2018-01-25 22:14:39 +01:00
Etienne Samson
5ce4f19bce examples: move support code into static functions 2018-01-25 22:14:37 +01:00
Etienne Samson
503b30d526 examples: hoist the merge analysis back into main 2018-01-25 22:13:25 +01:00
Etienne Samson
60c6547ce6 examples: minor review fixups 2018-01-25 22:12:41 +01:00
Etienne Samson
59ea2c58da examples: add merge 2018-01-25 22:12:38 +01:00
Etienne Samson
bb9353cfc1 examples: Dead code & warnings 2018-01-25 22:11:20 +01:00
Etienne Samson
3fa5e5779a examples: Move xrealloc to common example code 2018-01-25 22:11:19 +01:00
Etienne Samson
b67200186f examples: Switch to the nifty argv helpers from common 2018-01-25 22:11:19 +01:00
Patrick Steinhardt
bf15dbf6cf examples: network: fix Win32 linking errors due to getline
The getline(3) function call is not part of ISO C and, most importantly,
it is not implemented on Microsoft Windows platforms. As our networking
example code makes use of getline, this breaks builds on MSVC and MinGW.
As this code wasn't built prior to the previous commit, this was never
noticed.

Fix the error by instead implementing a `readline` function, which
simply reads the password from stdin until it reads a newline
character.
2017-11-06 14:48:50 +00:00
Carlos Martín Nieto
9e3fb594d6 Merge pull request #4373 from cjhoward92/examples/log-show-log-size
example-log: add support for --log-size
2017-10-29 15:32:18 +01:00
Patrick Steinhardt
9b12eb6f78 examples: remove Makefile
Back in the days when libgit2 was still young, libgit2 was using plain
Makefiles as build infrastructure. We later changed that to instead use
the CMake build system to make cross-platform development easier. In the
process, we forgot to remove the Makefile from our examples directory,
which is fixed by this commit here. Furthermore, remove the accompanying
.gitignore file, which ignores build outputs. As we do out-of-tree
builds only nowadays, no output is generated in that directory anymore.
2017-10-20 15:05:26 +02:00
Carson Howard
12a888d557 examples: log: pass options pointer to print_commit
Cleaned up the PR to address styling issues.
2017-10-13 07:18:54 -07:00
Carson Howard
1436b0e11c example-log: add support for --log-size 2017-10-11 21:47:58 -07:00
Douglas Swanson
f4770e4757 Fix Issue #4047 Check return codes and free objects 2017-10-07 01:29:21 +01:00
Patrick Steinhardt
8e31cc2580 cmake: keep track of libraries and includes via lists
Later on, we will move detection of required libraries, library
directories as well as include directories into a separate
CMakeLists.txt file inside of the source directory. Obviously, we want
to avoid duplication here regarding these parameters.

To prepare for the split, put the parameters into three variables
LIBGIT2_LIBS, LIBGIT2_LIBDIRS and LIBGIT2_INCLUDES, tracking the
required libraries, linking directory as well as include directories.
These variables can later be exported into the parent scope from inside
of the source build instructions, making them readily available for the
other subdirectories.
2017-08-16 07:12:38 +02:00
Patrick Steinhardt
f0ca00e013 examples: network: refactor credentials callback
The credentials callback reads the username and password via scanf into
fixed-length arrays. While these are simply examples and as such not as
interesting, the unchecked return value of scanf causes GCC to emit
warnings. So while we're busy to shut up GCC, we also fix the possible
overflow of scanf by using getline instead.
2017-05-15 07:34:03 +02: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
Force.Charlie-I
3fdba15c2f fix examples/network/clone.c: heap-buffer-overflow
Format of a length of string to the correct format is:%.*s
2017-01-09 14:09:57 +08:00
Douglas Swanson
832278bf36 Fix issue #4046 Seg fault in config_files() 2016-12-29 07:43:03 -07:00
Patrick Steinhardt
fc29391950 examples: add: fix type casting warning 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
5c2a8361d7 examples: diff: parse correct types for line-diffopts 2016-10-10 09:04:42 +02:00
Patrick Steinhardt
7314da1055 examples: fix warnings in network/fetch.c 2016-10-10 09:04:42 +02: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
Carlos Martín Nieto
07bd3e57d9 proxy: ask the user for credentials if necessary 2016-04-19 13:54:19 +02:00
Patrick McKenna
698e0c2777 Update link to Pro Git's Git internals chapter. 2016-03-07 16:34:30 -08:00
Eun
8b8f1f9188 fix return 2015-10-07 14:01:05 +02:00
Matt Burke
5d7cd57f99 Update another call to git_remote_connect 2015-09-08 14:15:29 -04:00
Carlos Martín Nieto
97c0a85fc6 Merge pull request #3306 from libgit2/cmn/fetch-ex-fetch
examples: modernise the fetch example
2015-07-13 11:23:07 +02:00
Matthew Plough
768f8be31c Fix #3094 - improve use of portable size_t/ssize_t format specifiers.
The header src/cc-compat.h defines portable format specifiers PRIuZ, PRIdZ, and PRIxZ. The original report highlighted the need to use these specifiers in examples/network/fetch.c.  For this commit, I checked all C source and header files not in deps/ and transitioned to the appropriate format specifier where appropriate.
2015-07-12 19:55:19 +02:00
Carlos Martín Nieto
6c7e86e158 examples: modernise the fetch example
Under normal conditions, git_remote_fetch() should be the only function
used to perform a fetch. Don't let the example lead people astray.
2015-07-12 19:41:01 +02:00
Edward Thomson
d202bb7d3b examples: clean up some warnings 2015-06-29 21:48:35 +00:00
Carlos Martín Nieto
c2418f4613 Rename FALLBACK to UNSPECIFIED
Fallback describes the mechanism, while unspecified explains what the
user is thinking.
2015-06-25 12:48:44 +02:00
Carlos Martín Nieto
7d6dacdc17 examples: adjust to submodule status API change 2015-06-22 17:02:55 +02:00
Ariel O. Barria
9334c86f49 print_usage functions is defined but not used
Use the previously created function to display a message when the arguments are not valid.

ticket 3095
2015-06-03 14:54:35 -05:00