Russell Belfer [Thu, 5 Sep 2013 19:01:17 +0000 (12:01 -0700)]
GIT_MODE_TYPE should exclude setgid bits
The GIT_MODE_TYPE macro was looking at all bits above the
permissions, but it should really just look at the top bits so
that it will give the right results for a setgid or setuid entry.
Since we're now using these macros in the tests, this was causing
a test failure on platforms that don't support setgid.
Russell Belfer [Thu, 5 Sep 2013 18:45:29 +0000 (11:45 -0700)]
Fix tests of file modes
This fixes an issue checking file modes in the tests that
initialize a repo from a template directory when a symlink is
used in the template. Also, this updates some other places where
we are examining file modes to use the new macros.
Russell Belfer [Thu, 5 Sep 2013 18:20:12 +0000 (11:20 -0700)]
Add more file mode permissions macros
This adds some more macros for some standard operations on file
modes, particularly related to permissions, and then updates a
number of places around the code base to use the new macros.
Russell Belfer [Wed, 4 Sep 2013 23:13:18 +0000 (16:13 -0700)]
Make tests take umask into account
It seems that libgit2 is correctly applying the umask when
initializing a repository from a template and when creating new
directories during checkout, but the test suite is not accounting
for possible variations due to the umask. This updates that so
that the test suite will work regardless of the umask.
nulltoken [Fri, 30 Aug 2013 15:36:00 +0000 (17:36 +0200)]
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).
Russell Belfer [Thu, 29 Aug 2013 17:27:01 +0000 (10:27 -0700)]
Treat detached HEAD as non-empty repo
This simplifies the git_repository_is_empty a bit so that a
detached HEAD is just taken to mean the repo is not empty, since
a newly initialized repo will not have a detached HEAD.
Russell Belfer [Mon, 26 Aug 2013 21:56:31 +0000 (14:56 -0700)]
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.
Fraser Tweedale [Sat, 24 Aug 2013 10:15:22 +0000 (20:15 +1000)]
netops: remove duplicate include
9e9aee6 added an include <netinet/in.h> to fix the build on FreeBSD.
Sometime since then the same header is included ifndef _WIN32, so
remove the duplicate include.
Fraser Tweedale [Sat, 24 Aug 2013 07:39:15 +0000 (17:39 +1000)]
fix tests on FreeBSD
238b761 introduced a test for posix behaviour, but on FreeBSD some
of the structs and constants used aren't defined in <arpa/inet.h>.
Include the appropriate headers to get the tests working again on
FreeBSD.
Russell Belfer [Thu, 22 Aug 2013 22:44:34 +0000 (15:44 -0700)]
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.
Russell Belfer [Wed, 21 Aug 2013 23:26:32 +0000 (16:26 -0700)]
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.
Russell Belfer [Wed, 21 Aug 2013 21:10:27 +0000 (14:10 -0700)]
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.
Russell Belfer [Tue, 20 Aug 2013 22:18:48 +0000 (15:18 -0700)]
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.