Commit Graph

5301 Commits

Author SHA1 Message Date
Russell Belfer
430953417f Load SRWLock APIs at runtime
This loads SRWLock APIs at runtime and in their absence (i.e. on
Windows before Vista) falls back on a regular CRITICAL_SECTION
that will not permit concurrent readers.
2013-08-26 14:56:31 -07:00
Russell Belfer
44d6553186 Fix comment 2013-08-23 12:03:44 -07:00
Russell Belfer
805755f49b Fix sortedcache docs and other feedback
This converts an internal lock from a write lock to a read lock
where write isn't needed, and also clarifies some doc things about
where various locks are acquired and how various APIs are intended
to be used.
2013-08-22 15:44:34 -07:00
Russell Belfer
b6ac07b517 Trying to fix Win32 warnings 2013-08-22 14:45:10 -07:00
Russell Belfer
eb868b1e98 Drop support for THREADSAFE on Windows XP
This makes libgit2 require Windows Vista or newer if it is going
to be compiled with the THREADSAFE option
2013-08-22 14:34:21 -07:00
Russell Belfer
972bb689c4 Add SRWLock implementation of rwlocks for Win32 2013-08-22 14:10:56 -07:00
Russell Belfer
2b6e190847 A bit of item alignment paranoia 2013-08-22 11:50:10 -07:00
Russell Belfer
8d9a85d43a Convert sortedcache to use rwlock
This is the first use we have of pthread_rwlock_t in libgit2.
Hopefully it won't cause any serious portability problems.
2013-08-22 11:40:53 -07:00
Russell Belfer
3eecadcce5 Improve comments on locking for sortedcache APIs 2013-08-21 22:50:37 -07:00
Russell Belfer
e8c5eb5537 No need to lock newly created tgt in copy 2013-08-21 22:44:56 -07:00
Russell Belfer
b37359aac5 Fix warnings when compiling without threads 2013-08-21 16:50:03 -07:00
Russell Belfer
fe37274080 Rewrite refdb_fs using git_sortedcache object
This adds thread safety to the refdb_fs by using the new
git_sortedcache object and also by relaxing the handling of some
filesystem errors where the fs may be changed out from under us.

This also adds some new threading tests that hammer on the refdb.
2013-08-21 16:26:32 -07:00
Russell Belfer
24c71f14b4 Add internal ref set_name fn instead of realloc
The refdb_fs implementation calls realloc directly on a reference
object when it wants to rename it.  It is not a public object, so
this doesn't mess with the immutability of references, but it does
assume certain constraints on the reference representation.  This
commit wraps that assumption in an isolated API to isolate it.
2013-08-21 14:10:27 -07:00
Russell Belfer
a4977169e1 Add sortedcache APIs to lookup index and remove
This adds two other APIs that I need to the sortedcache type.
2013-08-21 14:09:38 -07:00
Russell Belfer
0b7cdc0263 Add sorted cache data type
This adds a convenient new data type for caching the contents of
file in memory when each item in that file corresponds to a name
and you need to both be able to lookup items by name and iterate
over them in some sorted order.  The new data type has locks in
place to manage usage in a threaded environment.
2013-08-20 16:14:24 -07:00
Russell Belfer
0f0f565507 Don't try to pack symbolic refs
If there were symbolic refs among the loose refs then the code
to create packed-refs would fail trying to parse the OID out of
them (where Git just skips trying to pack them).  This fixes it.
2013-08-20 16:14:23 -07:00
Russell Belfer
5e1fb2828a Merge pull request #1800 from ethomson/mingw_warnings
Quiet down some warnings
2013-08-19 16:01:30 -07:00
Edward Thomson
8255b497b6 Quiet down some warnings 2013-08-19 17:49:53 -05:00
Ben Straub
adf9628262 Merge pull request #1796 from ethomson/fix_inet_pton
Fix p_inet_pton on windows
2013-08-19 15:47:31 -07:00
Edward Thomson
238b761491 Fix p_inet_pton on windows
p_inet_pton on Windows should set errno properly for callers.
Rewrite p_inet_pton to handle error cases correctly and add
test cases to exercise this function.
2013-08-19 17:21:35 -05:00
Ben Straub
25b2a55538 Merge pull request #1799 from ethomson/gettimeofday
Use time(2) to get the time
2013-08-19 15:06:39 -07:00
Edward Thomson
86967cc579 Use time(2) to get the time
We didn't use the added precision in gettimeofday, so remove it.
This prevents us from having an unnecessary reimplementation on
win32.
2013-08-19 16:44:17 -05:00
Ben Straub
eb04744621 Merge pull request #1797 from ethomson/keep_hash_ctx_private
Don't expose git_hash_ctx since it's internal
2013-08-19 11:00:20 -07:00
Carlos Martín Nieto
5875e8d21a travis: exit on failure for anything related to building 2013-08-19 18:50:03 +02:00
Edward Thomson
67c177ef26 Don't expose git_hash_ctx since it's internal
And doing so makes the mingw build choke.
2013-08-19 11:42:50 -05:00
Carlos Martín Nieto
6d69fbce31 Revparse does not handle refspecs 2013-08-19 13:04:05 +02:00
Vicent Martí
520287f63a Merge pull request #1785 from libgit2/cmn/odb-hash-frontend
odb: move hashing to the frontend for streaming
2013-08-19 02:17:00 -07:00
Vicent Martí
1c1b4e8a15 Merge pull request #1792 from libgit2/ntk/bug/prefix_size
odb: Straighten oid prefix handling
2013-08-19 02:16:02 -07:00
Vicent Martí
9abf7ea797 Merge pull request #1794 from libgit2/cmn/elocked
index: report when it's locked
2013-08-19 02:06:15 -07:00
Carlos Martín Nieto
6818080871 travis: really fail if the tests fail
When implementing the ssh testing, the move to the script made it so
the first test suite's exit code was ignored. Check whether the main
tests fail and exit with an error in that case.
2013-08-19 10:50:28 +02:00
Carlos Martín Nieto
3d27687475 index: report when it's locked
Report the index being locked with its own error code in order to be
able to differentiate, as a locked index is typically the result of a
crashed process or concurrent access, both of which often require user
intervention to fix.
2013-08-19 10:30:44 +02:00
Ben Straub
8f81ea45ca Merge pull request #1793 from libgit2/ntk/valgrind
Bring Valgrind back!
2013-08-18 18:30:48 -07:00
nulltoken
90a8ad63e3 ci: Make Valgrind run on Travis 2013-08-19 00:18:44 +02:00
nulltoken
d19dd9cf73 odb: Straighten oid prefix handling 2013-08-18 23:38:51 +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
7a3764bee9 odb: document git_odb_stream
Clarify the role of each function and in particular mention that there
is no need for the backend or stream to worry about the object's id,
as it will be given when `finalize_write` is called.
2013-08-17 02:02:28 +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
Vicent Martí
51a5e13347 Merge pull request #1778 from libgit2/push_tag_to_tag_test
push: handle tag chains correctly
2013-08-16 16:22:37 -07:00
Vicent Martí
b2be62fd23 Merge pull request #1790 from libgit2/examples-init
Add "git init"-like example
2013-08-16 15:33:13 -07:00
Russell Belfer
0ea41445f4 Improve isolation of new test from user environs 2013-08-16 15:04:15 -07:00
Russell Belfer
944c1589c2 Add example like "git init" 2013-08-16 15:04:15 -07:00
Russell Belfer
579d87c5d3 New test that inits repo and make commit 2013-08-16 15:04:15 -07:00
Russell Belfer
ce23330fd6 Add new git_signature_default API using config
This adds a new API for creating a signature that uses the
config to look up "user.name" and "user.email".
2013-08-16 15:04:15 -07:00
Ben Straub
68458e422a Merge pull request #1789 from martinwoodward/posix_win32-attribution
Give credit to PHP for the p_readlink function in posix_w32.c
2013-08-16 13:25:18 -07:00
Martin Woodward
c9340df055 Give credit to PHP for the p_readlink function in posix_w32.c 2013-08-16 19:40:58 +01:00
Carlos Martín Nieto
5ce6c1e917 push: handle tag chains correctly
When dealing with a chain of tags, we need to enqueue each of them
individually, which means we can't use `git_tag_peel` as that jumps
over the intermediate tags.

Do the peeling manually so we can look at each object and take the
appropriate action.
2013-08-16 01:32:29 +02:00
Carlos Martín Nieto
d4e6cf0cd0 odb: remove a duplicate object header formatting function 2013-08-15 14:32:47 +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
Vicent Martí
4424622328 Merge pull request #1784 from evhan/development
revparse: Free left side of invalid range revspecs
2013-08-14 23:15:02 -07:00