Commit Graph

279 Commits

Author SHA1 Message Date
Carlos Martín Nieto
d9da4ccaa0 Document {get,set}_multivar 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
3005855f7e Implement setting multivars 2012-02-17 19:50:30 +01:00
Carlos Martín Nieto
5e0dc4af01 Support getting multivars 2012-02-17 19:43:43 +01:00
Vicent Martí
6117895fef Merge pull request #558 from schu/notes-api
Notes API
2012-02-15 11:38:40 -08:00
schu
bf477ed4a8 Add git notes API
This commit adds basic git notes support to libgit2, namely:

* git_note_read
* git_note_message
* git_note_oid
* git_note_create
* git_note_remove

In the long run, we probably want to provide some convenience callback
mechanism for merging and moving (filter-branch) notes.

Signed-off-by: schu <schu-github@schulog.org>
2012-02-15 20:32:14 +01:00
Vicent Martí
0c3bae6268 zlib: Remove custom git2/zlib.h header
This is legacy compat stuff for when `deflateBound` is not defined, but
we're not embedding zlib and that function is always available. Kill
that with fire.
2012-02-15 16:56:56 +01:00
schu
b4b79ac3db commit: actually allow yet to be born update_ref
git_commit_create is supposed to update the given reference
"update_ref", but segfaulted in case of a yet to be born
reference. Fix it.

Signed-off-by: schu <schu-github@schulog.org>
2012-02-15 13:07:41 +01:00
schu
5e0de32818 Update Copyright header
Signed-off-by: schu <schu-github@schulog.org>
2012-02-13 17:11:09 +01:00
Vicent Martí
242a1cea8d libgit2 v0.16.0 "Dutch Fries"
This lovely and much delayed release of libgit2 ships from the cold city
of Brussels, which is currently hosting FOSDEM 2012.

There's been plenty of changes since the latest stable release, here's a
full summary:

- Git Attributes support (see git2/attr.h)
	There is now support to efficiently parse and retrieve information
	from `.gitattribute` files in a repository. Note that this
	information is not yet used e.g. when checking out files.

- .gitignore support
	Likewise, all the operations that are affected by `.gitignore` files
	now take into account the global, user and local ignores when
	skipping the relevant files.

- Cleanup of the object ownership semantics
	The ownership semantics for all repository subparts (index, odb,
	config files, etc) has been redesigned. All these objects are now
	reference counted, and can be hot-swapped in the middle of
	execution, allowing for instance to add a working directory and an
	index to a repository that was previously opened as bare, or to
	change the source of the ODB objects after initialization.

	Consequently, the repository API has been simplified to remove all
	the `_openX` calls that allowed setting these subparts *before*
	initialization.

- git_index_read_tree()
	Git trees can now be read into the index.

- More reflog functionality
	The reference log has been optimized, and new API calls to rename
	and delete the logs for a reference have been added.

- Rewrite of the References code with explicit ownership semantics
	The references code has been mostly rewritten to take into account
	the cases where another Git application was modifying a repository's
	references while the Library was running.

	References are now explicitly loaded and free'd by the user, and
	they may be reloaded in the middle of execution if the user suspects
	that their values may have changed on disk. Despite the new
	ownership semantics, the references API stays the same.

- Simplified the Remotes API
	Some of the more complex Remote calls have been refactored into
	higher level ones, to facilitate the usual `fetch` workflow of a
	repository.

- Greatly improved thread-safety
	The library no longer has race conditions when loading objects from
	the same ODB and different threads at the same time. There's now
	full TLS support, even for error codes. When the library is built
	with `THREADSAFE=1`, the threading support must be globally
	initialized before it can be used (see `git_threads_init()`)

- Tree walking API
	A new API can recursively traverse trees and subtrees issuing callbacks for
	every single entry.

- Tree diff API
	There is basic support for diff'ing an index against two trees.

- Improved windows support
	The Library is now codepage aware under Windows32: new API calls
	allow the user to set the default codepage for the OS in order to
	avoid strange Unicode errors.
2012-02-05 17:14:14 +01:00
Russell Belfer
cfbc880d8a Patch cleanup for merge
After reviewing the gitignore support with Vicent, we came up
with a list of minor cleanups to prepare for merge, including:

* checking git_repository_config error returns
* renaming git_ignore_is_ignored and moving to status.h
* fixing next_line skipping to include \r skips
* commenting on where ignores are and are not included
2012-01-16 15:16:44 -08:00
Russell Belfer
df743c7d3a Initial implementation of gitignore support
Adds support for .gitignore files to git_status_foreach() and
git_status_file().  This includes refactoring the gitattributes
code to share logic where possible.  The GIT_STATUS_IGNORED flag
will now be passed in for files that are ignored (provided they
are not already in the index or the head of repo).
2012-01-11 14:39:51 -08:00
Vicent Martí
7a704309ae Merge remote-tracking branch 'drizzd/diff-index-tests' into development
Conflicts:
	tests-clay/clay.h
	tests-clay/clay_main.c
2012-01-02 09:58:39 +01:00
Vicent Martí
9191a6d246 Merge remote-tracking branch 'arrbee/git-attributes' into development
Conflicts:
	tests-clay/clay_main.c
2012-01-02 09:56:48 +01:00
Vicent Martí
9dd4c3e806 config: Rename the delete callback name
`delete` is a reserved keyword in C++.
2011-12-31 05:58:26 +01:00
Clemens Buchacher
599f2849ba add git_index_read_tree 2011-12-30 20:14:05 +01:00
Russell Belfer
73b51450a3 Add support for macros and cache flush API.
Add support for git attribute macro definitions.  Also, add
support for cache flush API to clear the attribute file content
cache when needed.

Additionally, improved the handling of global and system files,
making common utility functions in fileops and converting config
and attr to both use the common functions.

Adds a bunch more tests and fixed some memory leaks.  Note that
adding macros required me to use refcounted attribute assignment
definitions, which complicated, but probably improved memory usage.
2011-12-29 00:01:10 -08:00
Russell Belfer
ee1f0b1aed Add APIs for git attributes
This adds APIs for querying git attributes.  In addition to
the new API in include/git2/attr.h, most of the action is in
src/attr_file.[hc] which contains utilities for dealing with
a single attributes file, and src/attr.[hc] which contains
the implementation of the APIs that merge all applicable
attributes files.
2011-12-20 16:32:58 -08:00
Carlos Martín Nieto
80a665aaca config: really delete variables
Instead of just setting the value to NULL, which gives unwanted
results when asking for that variable after deleting it, delete the
variable from the list and re-write the file.
2011-12-16 02:28:39 +01:00
Vicent Marti
e923868766 tree: recursive diff-index
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Signed-off-by: Vicent Marti <tanoku@gmail.com>

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author:    Carlos Martín Nieto <carlos@cmartin.tk>
#
# On branch development
# Your branch is ahead of 'origin/development' by 11 commits.
#
# Changes to be committed:
#   (use "git reset HEAD^1 <file>..." to unstage)
#
#	modified:   include/git2/tree.h
#	modified:   src/tree.c
#	modified:   tests-clay/clay_main.c
#	modified:   tests-clay/object/tree/diff.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	0001-remote-Cleanup-the-remotes-code.patch
#	466.patch
#	466.patch.1
#	488.patch
#	Makefile
#	libgit2.0.15.0.dylib
#	libgit2.0.dylib
#	libgit2.dylib
#	libgit2_clay
#	libgit2_test
#	tests-clay/object/tree/
2011-12-03 18:06:34 +01:00
Carlos Martín Nieto
a1fdea2855 tree: implement tree diffing
For each difference in the trees, the callback gets called with the
relevant information so the user can fill in their own data
structures.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-12-03 17:47:06 +01:00
Vicent Marti
d88d4311c7 remote: Cleanup the remotes code
- Hide the remaining transports code
- Drop `git_headarray`, switch to using a callback to list refs. Makes
the code cleaner.
2011-11-28 08:40:40 +01:00
Vicent Marti
6632c15509 Document all of the things 2011-11-26 08:48:01 +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
9462c47143 repository: Change ownership semantics
The ownership semantics have been changed all over the library to be
consistent. There are no more "borrowed" or duplicated references.

Main changes:

	- `git_repository_open2` and `3` have been dropped.

	- Added setters and getters to hotswap all the repository owned
	objects:

		`git_repository_index`
		`git_repository_set_index`
		`git_repository_odb`
		`git_repository_set_odb`
		`git_repository_config`
		`git_repository_set_config`
		`git_repository_workdir`
		`git_repository_set_workdir`

	Now working directories/index files/ODBs and so on can be
	hot-swapped after creating a repository and between operations.

	- All these objects now have proper ownership semantics with
	refcounting: they all require freeing after they are no longer
	needed (the repository always keeps its internal reference).

	- Repository open and initialization has been updated to keep in
	mind the configuration files. Bare repositories are now always
	detected, and a default config file is created on init.

	- All the tests affected by these changes have been dropped from the
	old test suite and ported to the new one.
2011-11-26 08:37:08 +01:00
Vicent Martí
e42ea1f488 Merge pull request #491 from schu/refs-cleanup
reference_rename() cleanup
2011-11-25 21:30:08 -08:00
Vicent Marti
2869f404fd transport: Add git_transport_valid_url 2011-11-22 15:49:23 +01:00
Carlos Martín Nieto
6616e20750 Add a note not to free the result from git_remote_ls 2011-11-22 11:18:27 +01:00
Vicent Martí
bec92f78bf Merge pull request #492 from carlosmn/networking
Networking improvements
2011-11-21 17:12:23 -08:00
Vicent Marti
2744806f32 tree: Fix documentation 2011-11-22 02:10:41 +01:00
Carlos Martín Nieto
6ac3b707b1 Add git_remote_connected
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-21 21:00:43 +01:00
Carlos Martín Nieto
4cf01e9a1a Add git_remote_disconnect
It can be useful to separate disconnecting from actually destroying
the object.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-21 21:00:42 +01:00
schu
a5cd086dff reference_rename: don't delete the reflog
reference_rename used to delete an old reflog file when renaming a
reference to not confuse git.git. Don't do this anymore but let the user
take care of writing a reflog entry.

Signed-off-by: schu <schu-github@schulog.org>
2011-11-21 16:38:30 +01:00
schu
b7c93a66e2 Add git_reflog_rename() and git_reflog_delete()
Signed-off-by: schu <schu-github@schulog.org>
2011-11-21 13:15:56 +01:00
Carlos Martín Nieto
617bfdf47f Add a name to a remote created from the API
Make it a bit more resilient.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-18 21:39:34 +01:00
Carlos Martín Nieto
95057b8503 remote: get rid of git_remote_negotiate
There is no good reason to expose the negotiation as a different step
to downloading the packfile.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-11-18 21:18:39 +01:00
Haitao Li
28ba94ceed Fix typo in repository documentation 2011-11-18 17:47:22 +08:00
Vicent Marti
2cbca8b06c include: Unify internal include strategies
Do not add the `git2` path to internal includes, or that will cause
an extra path dependency.
2011-11-18 01:43:27 +01:00
Vicent Marti
2ba14f2367 tree: Add payload to git_tree_walk 2011-11-18 01:40:35 +01:00
Vicent Marti
9432af36fc Rename git_tree_frompath to git_tree_get_subtree
That makes more sense to me.
2011-11-18 01:40:35 +01:00
Vicent Marti
a15c550db8 threads: Fix the shared global state with TLS
See `global.c` for a description of what we're doing.

When libgit2 is built with GIT_THREADS support, the threading system
must be explicitly initialized with `git_threads_init()`.
2011-11-16 14:09:44 +01:00
Vicent Marti
d4a0b124d0 refs: Partial rewrite for read-only refs
This new version of the references code is significantly faster and
hopefully easier to read.

External API stays the same. A new method `git_reference_reload()` has
been added to force updating a memory reference from disk. In-memory
references are no longer updated automagically -- this was killing us.

If a reference is deleted externally and the user doesn't reload the
memory object, nothing critical happens: any functions using that
reference should fail gracefully (e.g. deletion, renaming, and so on).

All generated references from the API are read only and must be free'd
by the user. There is no reference counting and no traces of generated
references are kept in the library.

There is no longer an internal representation for references. There is
only one reference struct `git_reference`, and symbolic/oid targets are
stored inside an union.

Packfile references are stored using an optimized struct with flex array
for reference names. This should significantly reduce the memory cost of
loading the packfile from disk.
2011-11-06 03:15:34 +01:00
schu
a46ec45746 refs: split internal and external references
Currently libgit2 shares pointers to its internal reference cache with
the user. This leads to several problems like invalidation of reference
pointers when reordering the cache or manipulation of the cache from
user side.

Give each user its own git_reference instead of leaking the internal
representation (struct reference).

Add the following new API functions:

	* git_reference_free
	* git_reference_is_packed

Signed-off-by: schu <schu-github@schulog.org>
2011-11-06 03:15:19 +01:00
Vicent Marti
3286c408ec global: Properly use git__ memory wrappers
Ensure that all memory related functions (malloc, calloc, strdup, free,
etc) are using their respective `git__` wrappers.
2011-10-28 19:02:36 -07:00
Vicent Marti
da37654d04 tree: Add traversal in post-order 2011-10-27 22:33:31 -07:00
Vicent Marti
11d51ca631 windows: Add support for non-UTF codepages
Our previous assumption that all paths in Windows are encoded in UTF-8
is rather weak, specially when considering that Git is
encoding-agnostic.

These set of functions allow the user to change the library's active
codepage globally, so it is possible to access paths and files on all
international versions of Windows.

Note that the default encoding here is UTF-8 because we assume that 99%
of all Git repositories will be in UTF-8.

Also, if you use non-ascii characters in paths, anywhere, please burn on
a fire.
2011-10-26 17:43:44 -07:00
Vicent Marti
28c1451a7c tree: Fix name lookups once and for all
Double-pass binary search. Jeez.
2011-10-20 02:40:14 +02:00
Vicent Marti
8cf2de078d tree: Fix lookups by entry name 2011-10-19 01:34:42 +02:00
nulltoken
3fa735ca3b tree: Add git_tree_frompath() which, given a relative path to a tree entry, retrieves the tree object containing this tree entry 2011-10-13 23:30:07 +02:00
nulltoken
34aff01002 oid: Add git_oid_streq() which checks if an oid and an hex formatted string are equal 2011-10-13 23:15:11 +02:00
Vicent Martí
92e2081f40 Merge pull request #449 from csware/include-win-version-information
Include windows version information in git2.dll
2011-10-12 11:03:58 -07:00