Commit Graph

171 Commits

Author SHA1 Message Date
nulltoken
031f3f8028 odb: Error when streaming in too [few|many] bytes 2013-09-07 23:00:20 +02:00
nulltoken
4047950f30 odb: Prevent stream_finalize_write() from overwriting
Now that #1785 is merged, git_odb_stream_finalize_write() calculates the object id before invoking the odb backend.

This commit gives a chance to the backend to check if it already knows this object.
2013-09-06 22:47:28 +02:00
nulltoken
b1a6c316a6 odb: Move the auto refresh logic to the pack backend
Previously, `git_object_read()`, `git_object_read_prefix()` and
`git_object_exists()` were implementing an auto refresh logic. When the
expected object couldn't be found in any backend, a call to
`git_odb_refresh()` was triggered and the lookup was once again performed
against all backends.

This commit removes this auto-refresh logic from the odb layer and pushes
it down into the pack-backend (as it's the only one currently exposing
a `refresh()` endpoint).
2013-09-04 07:44:53 +02:00
nulltoken
a12e069a3e odb: Honor the non refreshing capability of a backend 2013-08-30 23:19:02 +02:00
Carlos Martín Nieto
090a07d295 odb: avoid hashing twice in and edge case
If none of the backends support direct writes and we must stream the
whole file, we already know what the object's id should be; so use the
stream's functions directly, bypassing the frontend's hashing and
overwriting of our existing id.
2013-08-17 02:12:04 +02:00
Carlos Martín Nieto
fe0c6d4e71 odb: make it clearer that the id is calculated in the frontend
The frontend is in charge of calculating the id of the objects. Thus
the backends should treat it as a read-only value. The positioning in
the function signature made it seem as though it was an output
parameter.

Make the id const and move it from the front to behind the subject
(backend or stream).
2013-08-17 01:41:08 +02:00
Carlos Martín Nieto
8380b39a67 odb: perform the stream hashing in the frontend
Hash the data as it's coming into the stream and tell the backend what
its name is when finalizing the write. This makes it consistent with
the way a plain git_odb_write() performs the write.
2013-08-15 14:29:39 +02:00
Carlos Martín Nieto
376e6c9f96 odb: wrap the stream reading and writing functions
This is in preparation for moving the hashing to the frontend, which
requires us to handle the incoming data before passing it to the
backend's stream.
2013-08-15 14:29:27 +02:00
Carlos Martín Nieto
e54cfb9b54 odb: free object data when id is ambiguous
By the time we recognise this as an ambiguous id, the object's data
has been loaded into memory. Free it when returning EABMIGUOUS.
2013-08-12 11:50:27 +02:00
Rémi Duraffort
c6451624c4 Fix some more memory leaks in error path 2013-07-15 16:29:18 +02:00
Vicent Marti
6de9b2ee14 util: It's called memzero 2013-06-12 21:10:33 +02:00
Russell Belfer
3e9e6cdaff Add safe memset and use it
This adds a `git__memset` routine that will not be optimized away
and updates the places where I memset() right before a free() call
to use it.
2013-06-07 09:54:33 -07:00
Russell Belfer
f658dc433c Zero memory for major objects before freeing
By zeroing out the memory when we free larger objects (i.e. those
that serve as collections of other data, such as repos, odb, refdb),
I'm hoping that it will be easier for libgit2 bindings to find
errors in their object management code.
2013-05-31 14:09:58 -07:00
Vicent Martí
03c28d92d0 Merge pull request #1526 from arrbee/cleanup-error-return-without-msg
Make sure error messages are set for most error returns
2013-05-06 06:45:53 -07:00
Vicent Marti
dfec726bba odb: Do not error out if an alternate ODB is missing 2013-05-03 23:30:54 +02:00
Russell Belfer
f063f57898 Catch some odd odb backend corner case errors
There are some cases, particularly where no loaded ODB backends
support a particular operation, where we would return an error
code without having set an error.  This catches those cases and
reports that no ODB backends support the operation in question.
2013-05-01 14:48:35 -07:00
Vicent Martí
cd2ed9f0cc Merge pull request #1518 from arrbee/export-oid-comparison
Remove most inlines from the public API
2013-04-30 04:02:52 -07:00
Russell Belfer
b7f167da29 Make git_oid_cmp public and add git_oid__cmp 2013-04-29 13:52:12 -07:00
Edward Thomson
c8a4e8a5f6 don't use uninitialized struct stat in win32 2013-04-29 11:14:56 -05:00
Russell Belfer
786062639f Add callback to git_objects_table
This adds create and free callback to the git_objects_table so
that more of the creation and destruction of objects can be table
driven instead of using switch statements.  This also makes the
semantics of certain object creation functions consistent so that
we can make better use of function pointers.  This also fixes a
theoretical error case where an object allocation fails and we
end up storing NULL into the cache.
2013-04-22 16:51:40 +02:00
Vicent Marti
8842c75f17 What has science done. 2013-04-22 16:50:50 +02:00
Vicent Marti
5df184241a lol this worked first try wtf 2013-04-22 16:50:50 +02:00
Vicent Marti
0edad3cc04 Merge branch 'development' into vmg/dupe-odb-backends
Conflicts:
	src/odb.c
2013-04-22 16:41:56 +02:00
Vicent Marti
4ef2c79cb6 odb: Disable inode checks for Win32 2013-04-22 16:37:40 +02:00
Russell Belfer
83cc70d9fe Move odb_backend implementors stuff into git2/sys
This moves some of the odb_backend stuff that is related to the
internals of an odb_backend implementation into include/git2/sys.

Some of the stuff related to streaming I left in include/git2
because it seemed like it would be reasonably needed by a normal
user who wanted to stream objects into and out of the ODB.

Also, I added APIs for traversing the list of backends so that
some of the tests would not need to access ODB internals.
2013-04-21 11:50:55 -07:00
Vicent Marti
a29c6b5f47 odb: Do not allow duplicate on-disk backends 2013-04-19 23:51:18 +02:00
Michael Schubert
f5e28202cb 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.
2013-03-25 15:45:56 +01:00
Arkadiy Shapkin
10c06114cb Several warnings detected by static code analyzer fixed
Implicit type conversion argument of function to size_t type
Suspicious sequence of types castings: size_t -> int -> size_t
Consider reviewing the expression of the 'A = B == C' kind. The expression is calculated as following: 'A = (B == C)'
Unsigned type is never < 0
2013-03-18 03:30:26 +04:00
Vicent Marti
8fe6bc5c47 odb: Refresh on exists query too 2013-01-10 15:43:08 +01:00
Vicent Marti
891a4681eb dat errorcode 2013-01-10 15:34:56 +01:00
Vicent Marti
4a863c0666 Sane refresh logic
All the ODB backends have a specific refresh interface. When reading an
object, first we attempt every single backend: if the read fails, then
we refresh all the backends and retry the read one more time to see if
the object has appeared.
2013-01-10 15:34:56 +01:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
David Michael Barr
4d185dd9b0 odb: check if object exists before writing
Update the procondition of git_odb_backend::write.
It may now be assumed that the object has already been hashed.
2012-12-21 13:05:20 +11:00
Vicent Martí
0249a5032e Merge pull request #1091 from carlosmn/stream-object
Indexer speedup with large objects
2012-12-07 09:40:21 -08:00
Ben Straub
c7231c45fe Deploy GITERR_CHECK_VERSION 2012-11-30 16:31:42 -08:00
Ben Straub
55f6f21b7d Deploy versioned git_odb_backend structure 2012-11-30 13:12:15 -08:00
Carlos Martín Nieto
f56f8585c0 indexer: use the packfile streaming API
The new API allows us to read the object bit by bit from the packfile,
instead of needing it all at once in the packfile. This also allows us
to hash the object as it comes in from the network instead of having
to try to read it all and failing repeatedly for larger objects.

This is only the first step, but it already shows huge improvements
when dealing with objects over a few megabytes in size. It reduces the
memory needs in some cases, but delta objects still need to be
completely in memory and the old inefficent method is still used for
that.
2012-11-30 15:55:23 +01:00
Vicent Marti
9507a434c6 odb: Add git_odb_add_disk_alternate
Loads a disk alternate by path to the ODB. Mimics the
`GIT_ALTERNATE_OBJECT_DIRECTORIES` shell var.
2012-11-28 10:47:10 +01:00
Ben Straub
2e76b5fc84 API updates for odb.h 2012-11-27 13:18:30 -08:00
Carlos Martín Nieto
85e7efa163 odb: recursively load alternates
The maximum depth is 5, like in git
2012-11-16 08:46:02 -08:00
Edward Thomson
603bee0791 Remove git_hash_ctx_new - callers now _ctx_init() 2012-11-13 10:23:05 -06:00
Edward Thomson
d6fb092409 Win32 CryptoAPI and CNG support for SHA1 2012-11-13 10:23:05 -06:00
Edward Thomson
09cc0b92dc create callback to handle packs from fetch, move the indexer to odb_pack 2012-11-05 16:00:29 -06:00
Michael Schubert
edca6c8fed git_odb_object_free: don't segfault w/ arg == NULL 2012-10-09 21:28:31 +02:00
Jameson Miller
addc9be4fc Fix error hashing empty file. 2012-09-27 13:12:27 -04:00
Carlos Martín Nieto
e8776d30f7 odb: don't overflow the link path buffer
Allocate a buffer large enough to store the path plus the terminator
instead of letting readlink write beyond the end.
2012-09-16 00:10:07 +02:00
Vicent Martí
9be2261eaa Merge pull request #927 from arrbee/hashfile-with-filters
Add git_repository_hashfile to hash with filters
2012-09-13 09:24:12 -07:00
Michael Schubert
13faa77c57 Fix -Wuninitialized warning 2012-09-13 17:57:45 +02:00
Russell Belfer
a13fb55afd Add tests and improve param checks
Fixed some minor `git_repository_hashfile` issues:

- Fixed incorrect doc (saying that repo could be NULL)
- Added checking of object type value to acceptable ones
- Added more tests for various parameter permutations
2012-09-11 17:26:21 -07:00
Vicent Marti
c859184bb4 Properly handle p_reads 2012-09-11 23:05:24 +02:00