57 Commits

Author SHA1 Message Date
Edward Thomson
338ceb93b6 Improve documentation 2024-11-26 21:44:09 +00:00
John Colvin
c2d697e3ce s/size on bytes/size in bytes/ 2024-10-16 14:55:12 +01:00
punkymaniac
68bc511abb Add documentation about parameter and return value 2022-01-09 10:17:51 +01:00
Edward Thomson
4591e76a2d blob: identify binary content
Introduce `git_blob_data_is_binary` to examine a blob's data, instead of
the blob itself.  A replacement for `git_buf_is_binary`.
2021-12-10 15:19:59 -05:00
Peter Pettersson
38c3449822 Make enum in includes C90 compliant by removing trailing comma. 2021-11-15 16:45:40 +01:00
Edward Thomson
90656858ce filter: use a git_oid in filter options, not a pointer
Using a `git_oid *` in filter options was a mistake; it is a deviation
from our typical pattern, and callers in some languages that GC may need
very special treatment in order to pass both an options structure and a
pointer outside of it.
2021-09-21 11:28:39 -04:00
Edward Thomson
1439b9ff05 filter: introduce GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT
Provide a mechanism to filter using attribute data from a specific
commit (making use of `GIT_ATTR_CHECK_INCLUDE_COMMIT`).
2021-07-22 16:40:42 -04:00
punkymaniac
330b24d76f Fix typo 2021-04-22 15:07:36 +02:00
Edward Thomson
c31032a3cf Merge pull request #5760 from libgit2/ethomson/tttoo_many_ttts
blob: fix name of `GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD`
2021-01-07 10:15:25 +00:00
Josh Stockin
ddafbafef5 Update documentation for git_blob_filter_options
Adds info about initializing options with git_blob_filter_options_init
2021-01-05 17:26:50 -06:00
Edward Thomson
855f2998ac blob: fix name of GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD
`GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD` is misspelled, it should be
`GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD`, and it would be if it were not
for the MacBook Pro keyboard and my inattentiveness.
2021-01-05 14:46:09 +00:00
Edward Thomson
d9c1538775 blob: add git_blob_filter_options_init
The `git_blob_filter_options_init` function should be included, to allow
callers in FFI environments to let us initialize an options structure
for them.
2021-01-05 14:29:58 +00:00
Josh Stockin
f1151fb31e Fix documentation for git_blob_filter_options 2021-01-04 16:29:10 -06:00
Josh Stockin
556e07473b Move doc comment about GIT_BLOB_FILTER_OPTIONS_VERSION
Removes doc comment on `git_blob_filter_options.version`, moves
information to `git_blob_filter_options` doc comment to remain
consistent with other options structures' documentation.

`git_blob_filter_options_init` still needed; should be added in another
commit/PR (it's out of the scope of this PR, #5759), update this
documentation again.
2021-01-04 10:56:01 -06:00
Josh Stockin
0af0f7fdcf Add documentation for git_blob_filter_options.version
Resolves #5756
2021-01-03 20:39:45 -06:00
Edward Thomson
abb7a7e44a blob: use GIT_ASSERT 2020-11-25 11:42:03 +00:00
Edward Thomson
4334b1779f blob: use git_object_size_t for object size
Instead of using a signed type (`off_t`) use a new `git_object_size_t`
for the sizes of objects.
2019-11-22 15:10:19 +11:00
Sven Strickroth
452b7f8f4c Don't use enum for flags
Using an `enum` causes trouble when used with C++ as bitwise operations are not possible w/o casting (e.g., `opts.flags &= ~GIT_BLOB_FILTER_CHECK_FOR_BINARY;` is invalid as there is no `&=` operator for `enum`).

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2019-09-26 08:26:09 +02:00
Edward Thomson
fba3bf7978 blob: optionally read attributes from repository
When `GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD` is passed to
`git_blob_filter`, read attributes from `gitattributes` files that
are checked in to the repository at the HEAD revision.  This passes
the flag `GIT_FILTER_ATTRIBUTES_FROM_HEAD` to the filter functions.
2019-08-11 20:47:59 +01:00
Edward Thomson
a5392eae3d blob: allow blob filtering to ignore system gitattributes
Introduce `GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES`, which tells
`git_blob_filter` to ignore the system-wide attributes file, usually
`/etc/gitattributes`.

This simply passes the appropriate flag to the attribute loading code.
2019-08-11 20:47:59 +01:00
Edward Thomson
fa1a4c77f5 blob: deprecate git_blob_filtered_content
Users should now use `git_blob_filter`.
2019-08-11 20:47:59 +01:00
Edward Thomson
a32ab076bd blob: introduce git_blob_filter
Provide a function to filter blobs that allows for more functionality
than the existing `git_blob_filtered_content` function.
2019-08-11 20:47:59 +01:00
Edward Thomson
08f392080c blob: add underscore to from functions
The majority of functions are named `from_something` (with an
underscore) instead of `fromsomething`.  Update the blob functions for
consistency with the rest of the library.
2019-06-16 00:16:49 +01:00
Sven Strickroth
b5818ddabd Fix last references to deprecated git_buf_free
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2018-06-18 13:05:08 +02:00
Arthur Schreiber
a3e379cb4e Remove traces of git_blob_create_fromchunks 2016-04-26 11:10:31 +02:00
Edward Thomson
f0224772ee git_object_dup: introduce typesafe versions 2016-03-23 17:08:37 -04:00
Carlos Martín Nieto
0a5c602889 blob: introduce creating a blob by writing into a stream
The pair of `git_blob_create_frombuffer()` and
`git_blob_create_frombuffer_commit()` is meant to replace
`git_blob_create_fromchunks()` by providing a way for a user to write a
new blob when they want filtering or they do not know the size.

This approach allows the caller to retain control over when to add data
to this buffer and a more natural fit into higher-level language's own
stream abstractions instead of having to handle IO wait in the callback.

The in-memory buffer size of 2MB is chosen somewhat arbitrarily to be a
round multiple of usual page sizes and a value where most blobs seem
likely to be either going to be way below or way over that size. It's
also a round number of pages.

This implementation re-uses the helper we have from `_fromchunks()` so
we end up writing everything to disk, but hopefully more efficiently
than with a default filebuf. A later optimisation can be to avoid
writing the in-memory contents to disk, with some extra complexity.
2016-03-22 19:34:08 +01:00
tepas
cf339ede0a fix git_blob_create_fromchunks documentation
putting `0.` at the start of the line turns it into a numbered list.
2015-12-16 09:25:18 +11:00
Carlos Martín Nieto
bd470d0034 blob: don't recomment using git_buf_grow
We currently recommend using `git_buf_grow` in order to make a buffer
make an owned copy of the memory it points to. This is not behaviour we
should encourage, so remove this recommendation.

The function itself is not changed, as we need to remain compatible, but
it will be changed not to allow usage on borrowed buffers.
2015-06-24 23:49:10 +02:00
Ungureanu Marius
fda73bc5fd [Blob] Update documentation for is_binary.
filter.h tells me that we check the first 8000 bytes.
2014-05-28 22:57:21 +03:00
Jacques Germishuys
3b4ba27870 Const correctness! 2014-04-03 16:06:31 +02:00
Russell Belfer
5572d2b8a1 Some missing oid to id renames 2014-01-30 09:59:59 -08:00
Edward Thomson
6adcaab70c Handle git_buf's from users more liberally 2014-01-08 10:08:23 -08:00
Russell Belfer
19853bdd97 Update git_blob_create_fromchunks callback behavr
The callback to supply data chunks could return a negative value
to stop creation of the blob, but we were neither using GIT_EUSER
nor propagating the return value.  This makes things use the new
behavior of returning the negative value back to the user.
2013-12-11 10:57:50 -08: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
0cf77103b2 Start of filter API + git_blob_filtered_content
This begins the process of exposing git_filter objects to the
public API.  This includes:

* new public type and API for `git_buffer` through which an
  allocated buffer can be passed to the user
* new API `git_blob_filtered_content`
* make the git_filter type and GIT_FILTER_TO_... constants public
2013-09-17 09:30:06 -07:00
Russell Belfer
d77611022c Standardize cast versions of git_object accessors
This removes the GIT_INLINE versions of the simple git_object
accessors and standardizes them with a helper macro in src/object.h
to build the function bodies.
2013-04-29 14:22:06 -07:00
Miquel Canes Gonzalez
c2186230f3 Remove GIT_SUCCESS from documentation 2013-03-24 12:34:00 +01:00
Edward Thomson
359fc2d241 update copyrights 2013-01-08 17:31:27 -06:00
Russell Belfer
f2b7f7a6cb Share git_diff_blobs/git_diff_blob_to_buffer code
This moves the implementation of these two APIs into common code
that will be shared between the two.  Also, this adds tests for
the `git_diff_blob_to_buffer` API.  Lastly, this adds some extra
`const` to a few places that can use it.
2013-01-07 15:44:22 -08:00
nulltoken
a3337f10bb blob: introduce git_blob_is_binary() 2012-12-17 17:20:31 +01:00
Vicent Marti
cfbe4be3fb More external API cleanup
Conflicts:
	src/branch.c
	tests-clar/refs/branches/create.c
2012-11-27 13:18:27 -08:00
nulltoken
b8457baae2 portability: Improve x86/amd64 compatibility 2012-07-24 16:10:12 +02:00
nulltoken
cd44576790 blob: add git_blob_create_fromchunks() 2012-06-07 20:33:22 +02:00
Vicent Martí
e172cf082e errors: Rename the generic return codes 2012-05-18 01:26:26 +02:00
nulltoken
6ca9643c96 blob: Add git_blob_create_fromdisk()
This function will create blobs in the object database from files anywhere on the filesystem. This can be run against bare and non-bare repositories.
2012-05-13 11:28:49 +02:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Vicent Marti
45e79e3701 Rename all _close methods
There's no difference between `_free` and `_close` semantics: keep
everything with the same name to avoid confusions.
2011-11-26 08:48:00 +01:00
Vicent Marti
bb742ede3d 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.
2011-09-19 01:54:32 +03:00
David Boyce
d911172255 Standardized doxygen @return lines for int functions to say "GIT_SUCCESS or an error code". 2011-09-13 12:30:25 -04:00