|
eab2b044
|
2020-06-26T16:10:30
|
|
Review feedback
* Change the default of the file limit to 0 (unlimited).
* Changed the heuristic to close files to be the file that contains the
least-recently-used window such that the window is the
most-recently-used in the file, and the file does not have in-use
windows.
* Parameterized the filelimit test to check for a limit of 1 and 100
open windows.
|
|
9679df57
|
2020-02-08T20:47:24
|
|
mwindow: set limit on number of open files
There are some cases in which repositories accrue a large number of
packfiles. The existing mwindow limit applies only to the total size of
mmap'd files, not on their number. This leads to a situation in which
having lots of small packfiles could exhaust the allowed number of open
files, particularly on macOS, where the default ulimit is very low
(256).
This change adds a new configuration parameter
(GIT_OPT_SET_MWINDOW_FILE_LIMIT) that sets the maximum number of open
packfiles, with a default of 128. This is low enough so that even macOS
users should not hit it during normal use.
Based on PR #5386, originally written by @josharian.
Fixes: #2758
|
|
4cae9e71
|
2020-01-18T18:02:08
|
|
git_libgit2_version: return an int
Stop returning a void for functions, future-proofing them to allow them
to fail.
|
|
7372573b
|
2019-10-25T12:22:10
|
|
httpclient: support expect/continue
Allow users to opt-in to expect/continue handling when sending a POST
and we're authenticated with a "connection-based" authentication
mechanism like NTLM or Negotiate.
If the response is a 100, return to the caller (to allow them to post
their body). If the response is *not* a 100, buffer the response for
the caller.
HTTP expect/continue is generally safe, but some legacy servers
have not implemented it correctly. Require it to be opt-in.
|
|
247e6d90
|
2019-02-18T07:22:20
|
|
Remove public 'inttypes.h' header
Remove an `inttypes.h` header that is too large in scope, and far too
public.
For Visual Studio 2012 and earlier (ie, `_MSC_VER < 1800`), we do need
to include `stdint.h` in our public headers, for types like `uint32_t`.
Internally, we also need to define `PRId64` as a printf formatting
string when it is not available.
|
|
004a3398
|
2019-01-28T18:31:21
|
|
Allow bypassing check '.keep' files using libgit2 option 'GIT_OPT_IGNORE_PACK_KEEP_FILE_CHECK'
|
|
44827b67
|
2019-01-20T10:36:41
|
|
deprecation: add `used` attribute
Recent GCC enables `-Wunused-const-variables`, which makes output quite
noisy. Disable unused warnings for our deprecated variables.
|
|
22d2062d
|
2019-01-09T18:25:10
|
|
Introduce GIT_CALLBACK macro to enforce cdecl
Since we now always build the library with cdecl calling conventions,
our callbacks should be decorated as such so that users will not be able
to provide callbacks defined with other calling conventions.
The `GIT_CALLBACK` macro will inject the `__cdecl` attribute as
appropriate.
|
|
a74dd39b
|
2019-01-09T12:33:47
|
|
Use cdecl calling conventions on Win32
The recommendation from engineers within Microsoft is that libraries
should have a calling convention specified in the public API, and that
calling convention should be cdecl unless there are strong reasons to
use a different calling convention.
We previously offered end-users the choice between cdecl and stdcall
calling conventions. We did this for presumed wider compatibility: most
Windows applications will use cdecl, but C# and PInvoke default to
stdcall for WINAPI compatibility. (On Windows, the standard library
functions are are stdcall so PInvoke also defaults to stdcall.)
However, C# and PInvoke can easily call cdecl APIs by specifying an
annotation.
Thus, we will explicitly declare ourselves cdecl and remove the option
to build as stdcall.
|
|
19faf7c5
|
2018-11-14T23:35:48
|
|
object_type: update public API to use git_object_t
git_object_t is the future; update the public API to use it. This will
also ensure that we can build our tests which make use of the old API
without modification (and without compiler warnings).
|
|
305e801a
|
2018-10-21T09:52:32
|
|
util: allow callers to reset custom allocators
Provide a utility to reset custom allocators back to their default.
This is particularly useful for testing.
|
|
b3ca817e
|
2018-07-16T03:14:33
|
|
INDEXER_MAX_OBJECTS -> PACK_MAX_OBJECTS
|
|
efe3f37d
|
2018-07-12T04:20:15
|
|
Add a git_libgit2_opts option to set the max indexer object count
|
|
bfa1f022
|
2018-06-22T19:17:08
|
|
settings: optional unsaved index safety
Add the `GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY` option, which will cause
commands that reload the on-disk index to fail if the current
`git_index` has changed that have not been saved. This will prevent
users from - for example - adding a file to the index then calling a
function like `git_checkout` and having that file be silently removed
from the index since it was re-read from disk.
Now calls that would re-read the index will fail if the index is
"dirty", meaning changes have been made to it but have not been written.
Users can either `git_index_read` to discard those changes explicitly,
or `git_index_write` to write them.
|
|
3be73011
|
2018-06-11T18:26:22
|
|
Merge pull request #4436 from pks-t/pks/packfile-stream-free
pack: rename `git_packfile_stream_free`
|
|
396e4960
|
2018-02-08T11:05:17
|
|
common.h: create `GIT_DEPRECATED` macro
|
|
74b7ddbf
|
2018-03-16T10:14:50
|
|
settings: allow swapping out memory allocator
Tie in the newly created infrastructure for swapping out memory
allocators into our settings code. A user can now simply use the new
option "GIT_OPT_SET_ALLOCATOR" with `git_libgit2_opts`, passing in an
already initialized allocator structure as vararg.
|
|
6c23704d
|
2017-06-08T21:40:18
|
|
settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`
Initially, the setting has been solely used to enable the use of
`fsync()` when creating objects. Since then, the use has been extended
to also cover references and index files. As the option is not yet part
of any release, we can still correct this by renaming the option to
something more sensible, indicating not only correlation to objects.
This commit renames the option to `GIT_OPT_ENABLE_FSYNC_GITDIR`. We also
move the variable from the object to repository source code.
|
|
35079f50
|
2017-04-21T07:31:56
|
|
odb: add option to turn off hash verification
Verifying hashsums of objects we are reading from the ODB may be costly
as we have to perform an additional hashsum calculation on the object.
Especially when reading large objects, the penalty can be as high as
35%, as can be seen when executing the equivalent of `git cat-file` with
and without verification enabled. To mitigate for this, we add a global
option for libgit2 which enables the developer to turn off the
verification, e.g. when he can be reasonably sure that the objects on
disk won't be corrupted.
|
|
d5e6ca1e
|
2017-01-14T18:39:32
|
|
Allow to configure default file share mode for opening files
This can prevent FILE_SHARED_VIOLATIONS when used in tools such as TortoiseGit TGitCache and FILE_SHARE_DELETE, because files can be opened w/o being locked any more.
Signed-off-by: Sven Strickroth <email@cs-ware.de>
|
|
2a5ad7d0
|
2017-02-17T16:42:40
|
|
fsync: call it "synchronous" object writing
Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` ->
`GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
|
|
6d3ad7e0
|
2016-12-13T10:58:43
|
|
Add `ENABLE_SYNCHRONIZED_OBJECT_CREATION` option
Allow users to enable `SYNCHRONIZED_OBJECT_CREATION` with a setting.
|
|
61acc9fa
|
2017-02-08T16:22:44
|
|
Changes to provide option to turn off/on ofs_delta
This change provides an option in git_libgit2_opt_t which can be used in git_libgit2_opts to turn off/on ofs_delta capability in libGit2
|
|
8d3b39a6
|
2017-01-21T23:50:38
|
|
Merge branch 'pr/3912'
|
|
28d0ba0b
|
2017-01-21T23:45:23
|
|
symbolic ref target validation: fixups
Fixups requested in #3912.
|
|
77e46232
|
2016-12-17T14:31:36
|
|
settings: clarify what each value means
Most importantly, clarify what it means for HTTPS and SSH to be supported.
|
|
93392cdd
|
2016-10-09T11:27:56
|
|
docs: GIT_OPT_ENABLE_STRICT_OBJECT_CREATION is enabled
We changed the defaults on strict object creation - it is enabled by
default. Update the documentation to reflect that.
|
|
452bf57c
|
2016-08-27T13:42:53
|
|
Make symbolic ref target validation optional
Introduce GIT_OPT_ENABLE_SYMBOLIC_REF_TARGET_VALIDATION option.
Setting this option to 0 allows
validation of a symbolic ref's target to be bypassed.
This option is enabled by default.
This mechanism is added primarily to address a discrepancy between git
behaviour and libgit2 behaviour, whereby the former allows the symbolic
ref target to carry an arbitrary string and the latter does not, so:
$ git symbolic-ref refs/heads/foo bar
$ cat .git/refs/heads/foo
ref: bar
where as attempting the same via libgit2 raises an error:
The given reference name 'bar' is not valid
this mechanism also allows those that might want to make use of
git's more lenient treatment of symbolic ref targets to do so.
|
|
f1dba144
|
2016-07-05T09:41:51
|
|
Add get user agent functionality.
|
|
98444536
|
2016-03-31T11:35:53
|
|
Add a no-op size_t typedef for the doc parser
Clang's documentation parser, which we use in our documentation system
does not report any comments for functions which use size_t as a type.
The root cause is buried somewhere in libclang but we can work around it
by defining the type ourselves. This typedef makes sure that libclang
sees it and that we do not change its size.
|
|
fa72d6da
|
2016-03-14T12:02:00
|
|
Setup better defaults for OpenSSL ciphers
This ensures that when using OpenSSL a safe default set of ciphers
is selected. This is done so that the client communicates securely
and we don't accidentally enable unsafe ciphers like RC4, or even
worse some old export ciphers.
Implements the first part of https://github.com/libgit2/libgit2/issues/3682
|
|
1ddada42
|
2016-03-11T16:31:32
|
|
Merge pull request #3636 from nerdishbynature/fix-non-modular-header-in-module
Don't include inttypes if compiling for Mac/iOS
|
|
0ac4a5de
|
2016-02-25T18:15:02
|
|
Check for __CLANG_INTTYPES_H
This fixes an issue in Xcode 7.3 in objective-git where we get the error
"Include of non-modular header file in module". Not importing this
header again fixes the issue.
|
|
22a19f5b
|
2016-02-22T23:46:50
|
|
git_libgit2_opts: introduce `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION`
|
|
5bc93eae
|
2016-02-22T22:26:01
|
|
git_libgit2_opts: document GIT_OPT_SET_USER_AGENT
|
|
3eac1037
|
2015-11-16T23:31:19
|
|
settings: allow users to set PROGRAMDATA
Allow users to set the `git_libgit2_opts` search path for the
`GIT_CONFIG_LEVEL_PROGRAMDATA`. Convert `GIT_CONFIG_LEVEL_PROGRAMDATA`
to `GIT_SYSDIR_PROGRAMDATA` for setting the configuration.
|
|
75a0ccf5
|
2015-11-12T19:53:09
|
|
Merge pull request #3170 from CmdrMoozy/nsec_fix
git_index_entry__init_from_stat: set nsec fields in entry stats
|
|
de870533
|
2015-10-02T03:43:11
|
|
settings: add a setter for a custom user-agent
|
|
240a85cf
|
2015-10-22T07:56:34
|
|
inttypes.h is built-in header file since MSVC 2013
The reason is that the types defined in libgit2's inttypes.h collide with system inttypes.h
3rd party library header files may directly reference MSVC's built-in inttypes.h
Fixes #3476
|
|
0f9b6742
|
2015-10-21T09:24:10
|
|
win32: add c linkage guard around inttypes.h inclusion
|
|
0269833f
|
2015-06-02T12:42:07
|
|
settings: expose GIT_USE_NSEC flag in git_libgit2_features
|
|
a295bd2d
|
2014-12-06T03:36:18
|
|
doc: add documentation to all the public structs and enums
This makes them show up in the reference, even if the text itself isn't
the most descriptive.
These have been found with
grep -Przon '\n\ntypedef struct.*?\{' -- include
grep -Przon '\n\ntypedef enum.*?\{' -- include
|
|
babbff34
|
2014-10-10T15:17:05
|
|
Move un-namespaced constant to internal header
FLAG_BITS only seems to be used internally
|
|
9b36537d
|
2014-10-10T17:42:52
|
|
Merge pull request #2588 from swansontec/ssl-cert-path2
Add support for setting the SSL CA location
|
|
737b445a
|
2014-09-26T20:31:33
|
|
Add support for setting the SSL CA location
This allows users to specify self-signed certificates, or to provide their
own certificate stores on limited platforms such as mobile phones.
|
|
3a728fb5
|
2012-11-13T16:35:24
|
|
object: introduce git_describe_object()
|
|
42dee8ec
|
2014-03-23T13:34:33
|
|
settings: use git_buf for returning strings
This survived the last round of culling, as the signature is only in the
comments.
|
|
6057c4a0
|
2014-03-23T15:48:13
|
|
opts: bits are not bytes
The default cache size is 256 megabytes, not megabits as claimed in the
docs.
|
|
96484ecd
|
2014-03-03T12:59:35
|
|
Fix the description for `GIT_FEATURE_SSH`.
|
|
ebb3c506
|
2014-03-03T12:40:25
|
|
features: Rename `_HAS_` to `_FEATURE_`
|
|
2491c416
|
2014-03-03T12:13:17
|
|
caps: Rename the enum name too!
|
|
c9f5298b
|
2014-03-03T12:09:17
|
|
caps: Rename to features to avoid confusion
|
|
72556cc6
|
2014-02-20T14:27:10
|
|
Address PR comments
* Make GIT_INLINE an internal definition so it cannot be used in
public headers
* Fix language in CONTRIBUTING
* Make index caps API use signed instead of unsigned values
|
|
1b57699a
|
2013-09-22T09:11:43
|
|
Fix typo in documentation
|
|
b99b10f2
|
2013-09-17T23:38:52
|
|
Can git_libgit2_opts() with GIT_OPT_GET_TEMPLATE_PATH and GIT_OPT_SET_TEMPLATE_PATH
|
|
290e1479
|
2013-07-09T16:17:41
|
|
Add GIT_CAP_SSH if library was built with SSH
This also adds a test that actually calls git_libgit2_capabilities
and git_libgit2_version.
|
|
2e62e7c2
|
2013-05-24T10:33:41
|
|
Docs for git_libgit2_opts and cache disable tweak
This adds docs for the cache control options to git_libgit2_opts
and also tweaks the cache code so that if the cache is disabled,
then the next time we attempt to insert something into the cache
in question, we will actually clear any old cached objects.
|
|
0f1f9833
|
2013-05-24T10:32:07
|
|
Add typedefs on some public enums
Apparently this makes things easier to bind in some languages.
|
|
b4117e19
|
2013-04-24T20:09:42
|
|
docs: formatting fixes
|
|
a2378ae4
|
2013-04-23T20:42:29
|
|
opts: Add getter for cached memory
|
|
d8771592
|
2013-04-22T17:04:52
|
|
cache: Max cache size, and evict when the cache fills up
|
|
e16e2684
|
2013-04-04T02:09:32
|
|
No longer needed
|
|
ee12272d
|
2013-04-05T22:48:39
|
|
Global option setters
|
|
f5e28202
|
2013-03-25T13:38:43
|
|
opts: allow configuration of odb cache size
Currently, the odb cache has a fixed size of 128 slots as defined by
GIT_DEFAULT_CACHE_SIZE. Allow users to set the size of the cache via
git_libgit2_opts().
Fixes #1035.
|
|
41954a49
|
2013-03-18T14:19:35
|
|
Switch search paths to classic delimited strings
This switches the APIs for setting and getting the global/system
search paths from using git_strarray to using a simple string with
GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment
PATH variable would contain. This makes it simpler to get and set
the value.
I also added code to expand "$PATH" when setting a new value to
embed the old value of the path. This means that I no longer
require separate actions to PREPEND to the value.
|
|
5540d947
|
2013-03-15T16:39:00
|
|
Implement global/system file search paths
The goal of this work is to expose the search logic for "global",
"system", and "xdg" files through the git_libgit2_opts() interface.
Behind the scenes, I changed the logic for finding files to have a
notion of a git_strarray that represents a search path and to store
a separate search path for each of the three tiers of config file.
For each tier, I implemented a function to initialize it to default
values (generally based on environment variables), and then general
interfaces to get it, set it, reset it, and prepend new directories
to it.
Next, I exposed these interfaces through the git_libgit2_opts
interface, reusing the GIT_CONFIG_LEVEL_SYSTEM, etc., constants
for the user to control which search path they were modifying.
There are alternative designs for the opts interface / argument
ordering, so I'm putting this phase out for discussion.
Additionally, I ended up doing a little bit of clean up regarding
attr.h and attr_file.h, adding a new attrcache.h so the other two
files wouldn't have to be included in so many places.
|
|
a0f777c8
|
2013-01-23T23:44:34
|
|
opts: Add getters too
|
|
59853eff
|
2013-01-23T02:58:58
|
|
Global options setter
|
|
359fc2d2
|
2013-01-08T17:07:25
|
|
update copyrights
|
|
613d5eb9
|
2012-11-28T11:42:37
|
|
Push! By schu, phkelley, and congyiwu, et al
|
|
b46708aa
|
2012-10-11T23:04:08
|
|
Separated git_strarray from common.h. Added doxy comments.
|
|
e564e496
|
2012-08-01T20:02:32
|
|
Add function to query for compile time settings.
|
|
a8df98c6
|
2012-06-14T18:57:24
|
|
Updates from comments on OS4 compatibility pull request http://github.com/libgit2/libgit2/pull/766
|
|
327fb51c
|
2012-06-09T18:13:07
|
|
Fix gethostbyname compatibility
|
|
fa56478f
|
2012-06-08T19:15:11
|
|
Generic needs compat files
|
|
aa5a92d1
|
2012-06-08T18:57:35
|
|
OS4 compatibility
|
|
0f5e1f3b
|
2012-06-07T21:56:19
|
|
Network byte order is big-endian - the way it should be :)
|
|
79fdde49
|
2012-05-14T22:15:53
|
|
Revert "Specifiy dllimport to MSVC if we're not building libgit2.dll"
This reverts commit 1093e2de22f6ca245b09d758a3510899a8362048.
|
|
1093e2de
|
2012-05-11T04:25:23
|
|
Specifiy dllimport to MSVC if we're not building libgit2.dll
Building a "shared object" (DLL) in Windows includes 2 steps:
- specify __declspec(dllexport)
when building the library itself. MSVC will disallow itself from
optimizing these symbols out and reference them in the PE's
Exports-Table.
Further, a static link library will be generated. This library
contains the symbols which are exported via the declsepc above.
The __declspec(dllexport) becomes part of the symbol-signature
(like parameter types in C++ are 'mangled' into the symbol name,
the export specifier is mingled with the name)
- specify __declspec(dllimport)
when using the library. This again mingles the declspec into the
name and declares the function / variable with external linkage.
cmake automatically adds -Dgit2_EXPORTS to the compiler arguments
when compiling the libgit2 project.
The 'git2' is the name specified via PROJECT() in CMakeLists.txt.
|
|
b1ec25fa
|
2012-05-10T17:16:24
|
|
Fix comment typo in common.h
|
|
40879fac
|
2012-05-02T15:59:02
|
|
Merge branch 'new-error-handling' into development
Conflicts:
.travis.yml
include/git2/diff.h
src/config_file.c
src/diff.c
src/diff_output.c
src/mwindow.c
src/path.c
tests-clar/clar_helpers.c
tests-clar/object/tree/frompath.c
tests/t00-core.c
tests/t03-objwrite.c
tests/t08-tag.c
tests/t10-refs.c
tests/t12-repo.c
tests/t18-status.c
tests/test_helpers.c
tests/test_main.c
|
|
c02f1392
|
2012-04-21T18:43:10
|
|
Check for _WIN32 is sufficient, even for x64 compilers
There is no need to check for _WIN32 and _WIN64. x64 compiler also set _WIN32 (compare http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems#Windows).
Signed-off-by: Sven Strickroth <email@cs-ware.de>
|
|
14a513e0
|
2012-04-13T15:00:29
|
|
Add support for pathspec to diff and status
This adds preliminary support for pathspecs to diff and status.
The implementation is not very optimized (it still looks at
every single file and evaluated the the pathspec match against
them), but it works.
|
|
5e0de328
|
2012-02-13T17:10:24
|
|
Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
|
|
a15c550d
|
2011-11-16T14:09:44
|
|
threads: Fix the shared global state with TLS
See `global.c` for a description of what we're doing.
When libgit2 is built with GIT_THREADS support, the threading system
must be explicitly initialized with `git_threads_init()`.
|
|
314f54eb
|
2011-10-09T05:29:57
|
|
fix build for x64
Signed-off-by: Sven Strickroth <email@cs-ware.de>
|
|
c060854e
|
2011-10-04T21:11:51
|
|
msvc: Properly handle inttypes.h/stdint.h
|
|
e311519d
|
2011-09-18T19:38:14
|
|
Merge pull request #411 from boyski/gcc4
Don't use '__attribute__ visibility' with gcc unless it's at version 4 or better
|
|
d2a1861e
|
2011-09-18T21:27:25
|
|
Don't use '__attribute__ visibility' with gcc unless it's at
version 4 or better.
|
|
87d9869f
|
2011-09-19T03:34:49
|
|
Tabify everything
There were quite a few places were spaces were being used instead of
tabs. Try to catch them all. This should hopefully not break anything.
Except for `git blame`. Oh well.
|
|
bb742ede
|
2011-09-19T01:54:32
|
|
Cleanup legal data
1. The license header is technically not valid if it doesn't have a
copyright signature.
2. The COPYING file has been updated with the different licenses used in
the project.
3. The full GPLv2 header in each file annoys me.
|
|
536955f9
|
2011-06-16T02:21:33
|
|
Add method to get the compiled version of the lib
|
|
0657e46d
|
2011-06-15T12:36:08
|
|
Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
GIT_PATH_LIST_SEPARATOR and GIT_PATH_MAX are made public so
that it's can be used by a client.
|
|
ee4912bf
|
2011-06-07T11:15:23
|
|
Revert "common: Include stat.h in include/git2/common.h instead of src/common.h"
This reverts commit df1c98ab6d6171ed63729195bd190b54b67fe530.
As 8a27b6b reverts the exposition of struct stat to the external API, we
do not need - indeed, do not want - struct stat to be in the outer
include layer.
|
|
cbf4f9f4
|
2011-05-25T16:31:14
|
|
common: Include stat.h in include/git2/common.h instead of src/common.h
00582bcb introduced a change to git_blob_create_fromfile() that required
the caller to pass a stat struct. This means that we need to include
stat.h higher in the hierarchy of includes.
|
|
6810bf28
|
2011-05-11T00:40:07
|
|
Move all error-related defines to `git2/errors.h`
|
|
ab86f159
|
2011-05-09T23:39:32
|
|
Fix issue #79 - git_lasterror() isn't appearing in git2.dll in windows.
The GIT_EXPORT macro is used to declare a function to be externally
accessible to other libraries. This commit uses GIT_EXPORT to declare
the git_lasterror() function as externally exported. I verified with
depends.exe that the function is available to external callers (i.e.
in the exports table of the PE file).
|
|
fa59f18d
|
2011-05-09T20:54:04
|
|
Change error handling mechanism once again
Ok, this is the real deal. Hopefully. Here's how it's going to work:
- One main method, called `git__throw`, that sets the error
code and error message when an error happens.
This method must be called in every single place where an error
code was being returned previously, setting an error message
instead.
Example, instead of:
return GIT_EOBJCORRUPTED;
Use:
return git__throw(GIT_EOBJCORRUPTED,
"The object is missing a finalizing line feed");
And instead of:
[...] {
error = GIT_EOBJCORRUPTED;
goto cleanup;
}
Use:
[...] {
error = git__throw(GIT_EOBJCORRUPTED, "What an error!");
goto cleanup;
}
The **only** exception to this are the allocation methods, which
return NULL on failure but already set the message manually.
/* only place where an error code can be returned directly,
because the error message has already been set by the wrapper */
if (foo == NULL)
return GIT_ENOMEM;
- One secondary method, called `git__rethrow`, which can be used to
fine-grain an error message and build an error stack.
Example, instead of:
if ((error = foobar(baz)) < GIT_SUCCESS)
return error;
You can now do:
if ((error = foobar(baz)) < GIT_SUCCESS)
return git__rethrow(error, "Failed to do a major operation");
The return of the `git_lasterror` method will be a string in the
shape of:
"Failed to do a major operation. (Failed to do an internal
operation)"
E.g.
"Failed to open the index. (Not enough permissions to access
'/path/to/index')."
NOTE: do not abuse this method. Try to write all `git__throw`
messages in a descriptive manner, to avoid having to rethrow them to
clarify their meaning.
This method should only be used in the places where the original
error message set by a subroutine is not specific enough.
It is encouraged to continue using this style as much possible to
enforce error propagation:
if ((error = foobar(baz)) < GIT_SUCCESS)
return error; /* `foobar` has set an error message, and
we are just propagating it */
The error handling revamp will take place in two phases:
- Phase 1: Replace all pieces of code that return direct error codes
with calls to `git__throw`. This can be done semi-automatically
using `ack` to locate all the error codes that must be replaced.
- Phase 2: Add some `git__rethrow` calls in those cases where the
original error messages are not specific enough.
Phase 1 is the main goal. A minor libgit2 release will be shipped once
Phase 1 is ready, and the work will start on gradually improving the
error handling mechanism by refining specific error messages.
OTHER NOTES:
- When writing error messages, please refrain from using weasel
words. They add verbosity to the message without giving any real
information. (<3 Emeric)
E.g.
"The reference file appears to be missing a carriage return"
Nope.
"The reference file is missing a carriage return"
Yes.
- When calling `git__throw`, please try to use more generic error
codes so we can eventually reduce the list of error codes to
something more reasonable. Feel free to add new, more generic error
codes if these are going to replace several of the old ones.
E.g.
return GIT_EREFCORRUPTED;
Can be turned into:
return git__throw(GIT_EOBJCORRUPTED,
"The reference is corrupted");
|
|
5eb0fab8
|
2011-05-05T01:49:27
|
|
errors: Update external API with new `git_lasterror`
|
|
55c197cd
|
2011-04-11T17:41:21
|
|
Merge upstream/development
|