Commit Graph

144 Commits

Author SHA1 Message Date
Edward Thomson
e3f3868a1c 'del' instead of 'delete' for the poor C++ users 2013-09-24 11:04:14 -04:00
Russell Belfer
eefc32d549 Bug fixes and cleanups
This contains a few bug fixes and some header and API cleanups.

The main API change is that filters should now use GIT_PASSTHROUGH
to indicate that they wish to skip processing a file instead of
GIT_ENOTFOUND.

The bug fixes include a possible out-of-range buffer access in
the ident filter, a filter ordering problem I introduced into the
custom filter tests on Windows, and a filter buf NUL termination
issue that was coming up on Linux.
2013-09-17 09:31:46 -07:00
Russell Belfer
eab3746b30 More filtering tests including order
This adds more tests of filters, including the ident filter when
mixed with custom filters.  I was able to combine with the reverse
filter and demonstrate that the order of filter application with
the default priority constants matches the order of core Git.

Also, this fixes two issues in the ident filter: preventing ident
expansion on binary files and avoiding a NULL dereference when
dollar sign characters are found without Id.
2013-09-17 09:31:46 -07:00
Russell Belfer
b47349b8dc Port tests from PR 1683
This ports over some of the tests from
    https://github.com/libgit2/libgit2/pull/1683
by @yorah and @ethomson
2013-09-17 09:31:45 -07:00
Russell Belfer
a9f51e430f Merge git_buf and git_buffer
This makes the git_buf struct that was used internally into an
externally available structure and eliminates the git_buffer.

As part of that, some of the special cases that arose with the
externally used git_buffer were blended into the git_buf, such as
being careful about git_buf objects that may have a NULL ptr and
allowing for bufs with a valid ptr and size but zero asize as a
way of referring to externally owned data.
2013-09-17 09:31:45 -07:00
Russell Belfer
4b11f25a4f Add ident filter
This adds the ident filter (that knows how to replace $Id$) and
tweaks the filter APIs and code so that git_filter_source objects
actually have the updated OID of the object being filtered when
it is a known value.
2013-09-17 09:31:45 -07:00
Russell Belfer
40cb40fab9 Add functions to manipulate filter lists
Extend the git2/sys/filter API with functions to look up a filter
and add it manually to a filter list.  This requires some trickery
because the regular attribute lookups and checks are bypassed when
this happens, but in the right hands, it will allow a user to have
granular control over applying filters.
2013-09-17 09:31:45 -07:00
Russell Belfer
29e92d385e Hook up filter initialize callback
I knew I forgot something
2013-09-17 09:31:44 -07:00
Russell Belfer
2a7d224f99 Extend public filter api with filter lists
This moves the git_filter_list into the public API so that users
can create, apply, and dispose of filter lists.  This allows more
granular application of filters to user data outside of libgit2
internals.

This also converts all the internal usage of filters to the public
APIs along with a few small tweaks to make it easier to use the
public git_buffer stuff alongside the internal git_buf.
2013-09-17 09:31:44 -07:00
Russell Belfer
974774c7b0 Add attributes to filters and fix registry
The filter registry as implemented was too primitive to actually
work once multiple filters were coming into play.  This expands
the implementation of the registry to handle multiple prioritized
filters correctly.

Additionally, this adds an "attributes" field to a filter that
makes it really really easy to implement filters that are based
on one or more attribute values.  The lookup and even simple value
checking can all happen automatically without custom filter code.

Lastly, with the registry improvements, this fills out the filter
lifecycle callbacks, with initialize and shutdown callbacks that
will be called before the filter is first used and after it is
last invoked.  This allows for system-wide initialization and
cleanup by the filter.
2013-09-17 09:31:44 -07:00
Russell Belfer
570ba25cb0 Make git_filter_source opaque 2013-09-17 09:30:06 -07:00
Russell Belfer
85d5481206 Create public filter object and use it
This creates include/sys/filter.h with a basic definition of a
git_filter and then converts the internal code to use it.  There
are related internal objects (git_filter_list) that we will want
to publish at some point, but this is a first step.
2013-09-17 09:30:06 -07: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
Vicent Martí
b8b22d774e Merge pull request #1772 from libgit2/config-iter
Configuration iterators redux
2013-08-28 06:04:51 -07: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
Carlos Martín Nieto
f4be8209af config: don't special-case the multivar iterator
Build it on top of the normal iterator instead, which lets use re-use
a lot of code.
2013-08-14 00:45:05 +02:00
Carlos Martín Nieto
99dfb538ad config: working multivar iterator
Implement the foreach version as a wrapper around the iterator.
2013-08-08 20:38:42 +02:00
Carlos Martín Nieto
cca5df6376 config: hopefully get the iterator to work on multivars 2013-08-08 16:59:39 +02:00
Carlos Martín Nieto
3a7ffc29c9 config: initial multivar iterator 2013-08-08 16:18:07 +02:00
Carlos Martín Nieto
eba7399251 config: move next() and free() into the iterator
Like we have in the references iterator, next and free belong in the
iterator itself.
2013-08-08 14:39:32 +02:00
Carlos Martín Nieto
4efa32903a config: get_multivar -> get_multivar_foreach
The plain function will return an iterator, so move this one out of
the way.
2013-08-08 13:57:01 +02:00
Carlos Martín Nieto
4d588d9713 Don't typedef a pointer
Make the iterator structure opaque and make sure it compiles.
2013-08-08 11:40:41 +02:00
Nico von Geyso
a603c19157 replaced foreach() with non callback based iterations in git_config_backend
new functions in struct git_config_backend:
  * iterator_new(...)
  * iterator_free(...)
  * next(...)

The old callback based foreach style can still be used with `git_config_backend_foreach_match`
2013-08-08 11:14:53 +02:00
Carlos Martín Nieto
c05a55b056 Clean up some documentation
clang's docparser highlighted these.
2013-07-23 09:40:19 +02:00
Vicent Marti
4e6e2ff26f ...Aaaand this works 2013-05-30 03:47:10 +02:00
Vicent Marti
ec24e54296 What are the chances, really 2013-05-29 22:47:37 +02:00
Vicent Marti
56960b8396 Liike this 2013-05-28 20:47:55 +02:00
Russell Belfer
16adc9fade Typedef git_config_level_t and use it everywhere
The GIT_CONFIG_LEVEL constants actually work well as an enum
because they are mutually exclusive, so this adds a typedef to
the enum and uses that everywhere that one of these constants are
expected, instead of the old code that typically used an unsigned
int.
2013-05-24 10:35:58 -07:00
nulltoken
1fed6b07f0 Fix trailing whitespaces 2013-05-15 22:41:30 +02:00
Linquize
0cb16fe924 Unify whitespaces to tabs 2013-05-15 20:26:55 +08:00
Edward Thomson
b6cc559a78 Merge pull request #1385 from carlosmn/refs-iter
Introduce a refs iterator
2013-05-11 02:42:49 -07:00
Carlos Martín Nieto
c58cac12c2 Introduce a glob-filtering iterator
If the backend doesn't provide support for it, the matching is done in
refdb on top of a normal iterator.
2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
2b562c3a1e refs: remove the OID/SYMBOLIC filtering
Nobody should ever be using anything other than ALL at this level, so
remove the option altogether.

As part of this, git_reference_foreach_glob is now implemented in the
frontend using an iterator. Backends will later regain the ability of
doing the glob filtering in the backend.
2013-05-11 11:20:38 +02:00
Carlos Martín Nieto
4def7035ca refs: introduce an iterator
This allows us to get a list of reference names in a loop instead of callbacks.
2013-05-11 11:20:37 +02:00
nulltoken
467cbec73d commit: make create_from_oids() accept plain oid 2013-05-05 16:48:34 +02:00
Edward Thomson
75d1c8c664 move NAME and REUC extensions to sys/ 2013-04-30 17:33:11 -05:00
Vicent Marti
879458e7cf repo: Add git_repository__cleanup 2013-04-24 15:52:58 +02:00
Russell Belfer
21ca045100 Move git_reference__alloc to include/git2/sys
Create a new include/git2/sys/refs.h and move the reference alloc
functions there.  Also fix some documentation issues and some
minor code cleanups.
2013-04-21 12:52:17 -07:00
Russell Belfer
4dcd878019 Move refdb_backend to include/git2/sys
This moves most of the refdb stuff over to the include/git2/sys
directory, with some minor shifts in function organization.

While I was making the necessary updates, I also removed the
trailing whitespace in a few files that I modified just because I
was there and it was bugging me.
2013-04-21 11:57:21 -07:00
Russell Belfer
9233b3de4e Move git_commit_create_from_oids into sys/commit.h
Actually this renames git_commit_create_oid to
git_commit_create_from_oids and moves the API declaration to
include/git2/sys/commit.h since it is a dangerous API for general
use (because it doesn't check that the OID list items actually
refer to real objects).
2013-04-21 11:50:56 -07:00
Russell Belfer
1384b688d0 Move some low-level repo fns to include/git2/sys 2013-04-21 11:50:56 -07: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
Russell Belfer
83041c711c Move git_config_backend to include/git2/sys
Moving backend implementor objects into include/git2/sys so the
APIs can be isolated from the ones that normal libgit2 users
would be likely to use.
2013-04-21 11:50:55 -07:00