Commit Graph

585 Commits

Author SHA1 Message Date
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
Sven Strickroth
96fab093e3 put version information in separate file
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2011-10-09 18:39:52 +02:00
Sven Strickroth
314f54eb06 fix build for x64
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2011-10-09 05:29:57 +02:00
Vicent Marti
dd3fd68266 msvc: Remove superfluous includes 2011-10-05 13:44:27 -07:00
Vicent Marti
c060854ed5 msvc: Properly handle inttypes.h/stdint.h 2011-10-05 16:21:16 -04:00
Carlos Martín Nieto
dc8e3096d6 Include stdint.h in git2/config.h
Otherwise MSVC doesn't know what we're talking about when we say
int32_t or int64_t.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-10-01 02:09:35 +02:00
Vicent Marti
fafd471021 config: Proper type declarations for 64 bit ints 2011-09-30 16:08:41 +02:00
Carlos Martín Nieto
c36280a036 repository: export git_repository_config_autoload
Take the opportunity to finish the comment about this function.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-30 06:28:22 +02:00
Vicent Marti
8af4d074cc odb: Let users decide compression level for the loose ODB 2011-09-29 15:34:17 +02:00
Carlos Martín Nieto
40fe5fbea8 Make repo config loading automatic or completely explicit
git_repository_config wants to take the global and system paths again
so that one can be explicit if needed.

The git_repository_config_autoload function is provided for the cases
when it's good enough for the library to guess where those files are
located.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-27 14:40:56 +02:00
Carlos Martín Nieto
4c562347ae Add git_config_find_system
This allows the library to guess where the system configuration file
should be located.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-27 14:39:38 +02:00
nulltoken
ad196c6ae6 config: make git_config_[get|set]_long() able to properly deal with 8 bytes wide values
Should fix issue #419.

Signed-off-by: nulltoken <emeric.fermas@gmail.com>
2011-09-22 18:58:47 +02:00
Vicent Martí
6640266e5a Merge pull request #398 from carlosmn/config-autohome
git_repository_config: open global config file automatically
2011-09-18 19:58:22 -07:00
Vicent Martí
e311519dce Merge pull request #411 from boyski/gcc4
Don't use '__attribute__ visibility' with gcc unless it's at version 4 or better
2011-09-18 19:38:14 -07:00
David Boyce
d2a1861ea1 Don't use '__attribute__ visibility' with gcc unless it's at
version 4 or better.
2011-09-18 21:27:25 -04:00
Vicent Marti
87d9869fc3 Tabify everything
There were quite a few places were spaces were being used instead of
tabs. Try to catch them all. This should hopefully not break anything.
Except for `git blame`. Oh well.
2011-09-19 03:34:49 +03: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
nulltoken
56453d3468 status: enhance determination of status for a single file
- fix retrieval of a file status when working against a newly initialized repository
 - reduce memory pressure
 - prevents a directory from being tested
2011-09-15 01:14:36 +02:00
nulltoken
3601c4bfce repository: Add git_repository_head() 2011-09-15 01:13:50 +02: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
Carlos Martín Nieto
f9d4b0c395 git_repository_config: open global config file automatically
If the global configuration file is missing, it is ignored.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-09-12 17:25:46 +02:00
Sebastian Schuberth
26e74c6ace Fix some random size_t vs. int conversion warnings 2011-09-08 17:07:37 +02:00
Carlos Martín Nieto
778e1c739b Add git_remote_new
As we no longer expose the transport functions, this is now the only
way to connect to a remote when given an URL instead of a remote name

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-30 19:37:14 +02:00
Carlos Martín Nieto
b5a8aa94bf Don't hide the transport details
Transports shouldn't get used outside of the library, so don't expose
accessor functions.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-30 19:37:14 +02:00
Carlos Martín Nieto
a1be77cd35 Be smarter about selecting wants
There is no need to inspect what the local repository is like. Only
check whether the objects exist locally.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:09 +02:00
Carlos Martín Nieto
1564db11fe Remove enum git_whn
Instead, use flags inside the git_remote_head structure.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:09 +02:00
Carlos Martín Nieto
441f57c2b7 Add git_remote_update_tips
This function updates the references in the local reference storage to
match the ones in the remote.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
48a65a071d Only wait for pack if we need it
Provide the git_remote_download function to instruct the library to
downlad the packfile and let the user know the temporary location.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
e1d8803068 Don't expose the fetch code to the user
Move the generation of the want-list to be done from the negotiate
function, and keep the filtered references inside the remote
structure.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:08 +02:00
Carlos Martín Nieto
65fbc48a17 negotiation 2011-08-18 02:34:07 +02:00
Carlos Martín Nieto
e1f4a76150 Add git_fetch_list_want which creates the "want" list
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-18 02:34:07 +02:00
schu
e7be57a98b reflog: assimilate reflog API to return git_oid's
Rather than returning the OIDs out of the reflog as string return them
as git_oid.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-15 21:14:51 +02:00
Lambert CLARA
a6bbb8cab6 Add missing GIT_BEGIN_DECL and GIT_END_DECL to indexer header 2011-08-13 10:56:33 +02:00
Vicent Marti
5ae2f0c013 commit: Add support for Encoding header 2011-08-12 16:24:19 -07:00
Vicent Marti
b2e60e4eb5 Add common.h to types.h 2011-08-10 15:25:37 -07:00
Vicent Martí
31bf5f3857 Merge pull request #345 from carlosmn/gsoc2011/indexer
Implement a pack indexer
2011-08-03 18:59:30 -07:00
schu
63396a3998 signature: adjust API to return error codes
git_signature_new() and git_signature_now() currently don't return error
codes. Change the API to return error codes and not pointers to let the
user handle errors properly.

Signed-off-by: schu <schu-github@schulog.org>
2011-08-03 16:05:32 +02:00
Carlos Martín Nieto
65cb1586c4 Document the indexer calls
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-03 14:02:49 +02:00
Carlos Martín Nieto
48b3ad4f15 Move pack index writing to a public function
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-03 14:02:49 +02:00
Carlos Martín Nieto
b7c44096ae Implement the indexer
Only v2 index files are supported.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-03 14:02:41 +02:00
Carlos Martín Nieto
ab525a7463 Rename stuff to git_indexer_
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-02 21:41:33 +02:00
Carlos Martín Nieto
f23c4a66bd Start the runner
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-08-02 21:41:05 +02:00
Carlos Martín Nieto
3412391d4c Intial indexer code 2011-08-02 21:41:02 +02:00
Marcel Groothuis
ede21113a2 Fix compilation in C++: remove double GIT_BEGIN_DECL 2011-07-29 19:31:39 +02:00
Carlos Martín Nieto
1e76676fb4 Fixup network headers
The network headers were still missing some formalities.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-27 01:22:50 +02:00
Johan 't Hart
136e7129d7 On some header files, GIT_END_DECL was absent while GIT_BEGIN_DECL wasn't. 2011-07-27 00:06:19 +02:00
Kirill A. Shutemov
7d9cc9f81a index: fix cast warnings
/home/kas/git/public/libgit2/src/index.c: In function ‘git_index_clear’:
/home/kas/git/public/libgit2/src/index.c:228:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c:235:8: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c: In function ‘index_insert’:
/home/kas/git/public/libgit2/src/index.c:392:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c:399:7: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c: In function ‘read_unmerged’:
/home/kas/git/public/libgit2/src/index.c:681:35: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]
/home/kas/git/public/libgit2/src/index.c: In function ‘read_entry’:
/home/kas/git/public/libgit2/src/index.c:716:33: warning: cast discards ‘__attribute__((const))’ qualifier from pointer target type [-Wcast-qual]

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-25 21:12:47 +02:00
Lambert CLARA
ac2351fdec Modify struct definition to enable forward declare with C++ compiler,
thus avoid including C library's header in C++ header.
2011-07-25 20:24:10 +02:00
nulltoken
e5f365051f tag: Make git_tag_create_lightweight() accessible to bindings 2011-07-14 15:11:31 +02:00
Carlos Martín Nieto
91d8a4c077 typo: one git_remote_fetchspec should be pushspec
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-07-13 23:55:48 +02:00
Vicent Marti
b08683ffb2 config: Rename del to `delete 2011-07-12 02:38:20 +02:00
nulltoken
bfbb55628b tag: Add creation of lightweight tag 2011-07-11 19:42:21 +02:00
Lambert CLARA
f6e4a98a95 Finish to hide git_pkt from external API. 2011-07-11 13:05:13 +02:00
Lambert CLARA
5f35d0ce77 Remove the last reference of git_net_direction enum 2011-07-11 03:00:34 +02:00
Vicent Marti
bdd18829ad Cleanup external API
Some of the WIP API calls have been hidden in preparation for the next
minor release.
2011-07-11 02:59:18 +02:00
Vicent Marti
f27f29b100 include: Fix unmatched params in documentation 2011-07-11 02:59:17 +02:00
Vicent Marti
c52736fa52 status: Cleanup
The `hashfile` function has been moved to ODB, next to `git_odb_hash`.

Global state has been removed from the dirent call in `status.c`,
because global state is killing the rainforest and causing global
warming.
2011-07-09 15:05:14 +02:00
Jason Penny
20361b2f69 status: get status for single file
Add git_status_file to be able to retrieve status of single file by
supplying a path.
2011-07-09 13:49:50 +02:00
Jason Penny
3af6b34a76 status: get file statuses and run callback
Add git_status_foreach() to run a callback on each file passing the path
and a status value.
2011-07-09 13:49:50 +02:00
Jason Penny
205166d27c status: get blob object id of file on disk
Add git_status_hashfile() to get blob's object id for a file without adding
it to the object database or needing a repository at all.
This functionality is similar to `git hash-object` without '-w'.
2011-07-09 13:49:50 +02:00
schu
27df4275f2 reflog: add API to read or write a reference log
So far libgit2 didn't support reference logs (reflog). Add a new
git_reflog_* API for basic reading and writing of reflogs:

* git_reflog_read
* git_reflog_write
* git_reflog_free

Signed-off-by: schu <schu-github@schulog.org>
2011-07-09 02:40:16 +02:00
nulltoken
2b5af615e1 tag: add pattern based retrieval of list of tag names 2011-07-07 15:37:07 +02:00
Kirill A. Shutemov
245adf4f3c index: introduce git_index_uniq() function
It removes all entries with equal path except last added.

On large indexes git_index_append() + git_index_uniq() before writing is
*much* faster, than git_index_add().

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-05 17:52:39 +03:00
Vicent Martí
f12aa9dc5e Merge pull request #300 from carlosmn/gsoc2011/master
A bit of networking
2011-07-05 04:31:37 -07:00
Carlos Martín Nieto
2601fcfc1e Add tests for deleting a config var
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-07-05 02:32:17 +02:00
Kirill A. Shutemov
932d1baf29 cleanup: remove trailing spaces
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
2011-07-01 18:02:56 +02:00
Vicent Marti
e0fc39da9a config: Fix unmatched parameters in docs 2011-06-30 22:28:19 +02:00
nulltoken
408d733b1f repository: Make head_detached() and head_orphan() convenience methods accessible to bindings 2011-06-30 06:56:58 -07:00
Vicent Marti
cfef5fb779 config: foreach now returns variable values too 2011-06-29 15:09:21 +02:00
Vicent Marti
7376ad9927 refs: Remove duplicate rename method
`git_reference_rename` now takes a `force` flag
2011-06-29 11:01:35 +02:00
Vicent Marti
ab7941b5d9 test: Properly show error messages 2011-06-28 21:10:51 +02:00
Vicent Marti
c682886e8e repo: Rename HEAD-related methods 2011-06-28 21:10:44 +02:00
Vicent Martí
ccd59372d4 Merge pull request #279 from carlosmn/detached-orphan
Add detached and orphan convenience functions
2011-06-28 10:44:19 -07:00
Vicent Marti
d5afc0390c Remove redundant methods from the API
A bunch of redundant methods have been removed from the external API.

- All the reference/tag creation methods with `_f` are gone. The force
flag is now passed as an argument to the normal create methods.

- All the different commit creation methods are gone; commit creation
now always requires a `git_commit` pointer for parents and a `git_tree`
pointer for tree, to ensure that corrupted commits cannot be generated.

- All the different tag creation methods are gone; tag creation now
always requires a `git_object` pointer to ensure that tags are not
created to inexisting objects.
2011-06-28 19:36:27 +02:00
Carlos Martín Nieto
35502d2ec4 Add git_repository_is_detached, git_repository_is_orphan
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-28 16:59:51 +02:00
Carlos Martín Nieto
0ac2726fdf Slim down git_transport
Remove the unused repo and private pointers and make the direction a
flag, as it can only have two states. Change the connect signature to
use an int instead of git_net_direction and remove that enum.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 20:23:47 +02:00
Carlos Martín Nieto
9ba49bb5c8 Add git_remote_connect and git_remote_ls
These allow you to implement git-ls-remote when given a reference name
and a repository.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-27 02:12:40 +02:00
Carlos Martín Nieto
ce90a407c7 Remove the repo param from git_transport_new
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:48:01 +02:00
Carlos Martín Nieto
4e913309b9 Move transports to an inheritance model
Rather than an 'private' pointer, make the private structures inherit
from the generic git_transport struct. This way, we only have to worry
about one memory allocation instead of two. The structures are so
simple that this may even make the code use less memory overall.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:45 +02:00
Carlos Martín Nieto
fd6790210f Move git_pkt_{gen_proto,send_request} to transport_git.c
This is where they really belong. Remvoe the prefix and make them
static.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
cbf742ac4e Use (s)size_t
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
c4d0fa85b1 Implement and use git_pkt_send_request
This makes it easier to send a requqest for an URL. It assumes there
is a socket where the string should go out to.

Make git_pkt_gen_proto accept a command parameter, which defaults to
git-upload-pack

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
7632e2494a Correctly handle network input
Add a parameter to git_pkt_parse_line to tell it how much data you
have in your buffer. If the buffer is too short, it returns an error
saying so. Adapt the git transport to use this and fix the offset
calculation.

Add the GIT_ESHORTBUFFER error code.
2011-06-26 20:43:44 +02:00
Carlos Martín Nieto
be9fe679fc Implement and use git_pkt_free
A git_pkt object can be one of several structs. Add this function for
convenience and clarity.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:13 +02:00
Carlos Martín Nieto
ecb6ca0e1f Implement the git TCP transport up to ls-remote
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:13 +02:00
Carlos Martín Nieto
6a9597c5b5 Add function to generate a request
Add git_pkt_gen_proto to crete a request from an url.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
8b9e8de5ce pkt-line: read capabilities
Try to read the server capabilities and add them to the git_pkt_ref
struct.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
b31803f310 pkt-line: parse other-ref lines
Add support for parsing other-ref lines.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
f7fc68df83 Lay the foundations for pkt-line parsing
This are the types I intend to use for pkt-line parsing and (later)
creation. git_pkt serves as a base pointer type and once you know what
type it is you can use the real one (command, tip list, etc.)

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
d6258debbe Implement ls-remote on local drive
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:12 +02:00
Carlos Martín Nieto
8f866daee5 Lay down the fundations for the network code
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
92cb6aa929 Add git_refspec_transform
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
63f91e1ce8 Add git.git's fnmatch, which is really GNU's and the git__fnmatch wrapper
If the strings match, git__fnmatch returns GIT_SUCCESS and
GIT_ENOMATCH on failure to match.

MSVC fixes: Added a test for _MSC_VER and (in that case) defined
HAVE_STRING_H to 1 so it doesn't try to include <strings.h> which
doesn't exist in the MSVC world. Moved the function declarations to
use the modern inline ones so MSVC doesn't have a fit. Added casts
everywhere so MSVC doesn't crap its pants.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
f8f3feb0d3 Add a to-do list for remotes
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:11 +02:00
Carlos Martín Nieto
9c82357be7 Add a remotes API
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
2011-06-26 18:18:10 +02:00
Ankur Sethi
2c0ec236e9 added defines for Haiku in types.h 2011-06-23 13:36:09 +00:00
Vicent Marti
984ed6b6be odb: Add GIT_EPASSTHROUGH
Allows a custom user backend to passthrough one of the callbacks. Used
for e.g. caching backends.
2011-06-19 12:50:45 +02:00
Vicent Marti
bfd5e3e2a2 config: Fix API docs 2011-06-19 12:50:45 +02:00
Vicent Marti
19cb6857a4 config: Bring back git_config_open_global
Scott commands, I obey.
2011-06-18 01:50:48 +02:00
Vicent Marti
07ff881750 config: Cleanup external API
Do not mess with environment variables anymore. The new external API has
more helper methods, and everything is explicit.
2011-06-18 00:39:39 +02:00
Carlos Martín Nieto
b22d147986 Add git_repository_config API
This function puts the global and repository configurations in one
git_config object and gives it to the user.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-17 22:30:29 +02:00
Vicent Marti
d144c569f3 Update documentation
Fix all the missmatched arguments in the docs
2011-06-16 03:06:22 +02:00
Vicent Marti
f1d018513a oid: Uniformize ncmp methods
Drop redundant methods. The ncmp method is now public
2011-06-16 02:50:08 +02:00
Vicent Marti
fa48608ec3 oid: Rename methods
Yeah. Finally. Fuck the old names, this ain't POSIX
and they don't make any sense at all.
2011-06-16 02:36:21 +02:00
Vicent Marti
43521d0688 refs: Rename git_referece_listcb to _foreach
Same name as `git_config_foreach`
2011-06-16 02:27:43 +02:00
Vicent Marti
536955f9d7 Add method to get the compiled version of the lib 2011-06-16 02:21:33 +02:00
Vicent Martí
ef9a6f4cbc Merge pull request #261 from Romain-Geissler/discovery-path-v2
Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
2011-06-15 13:47:41 -07:00
Romain Geissler
0657e46dee Fix: GIT_PATH_PATH_SEPARATOR is now a semi-colon under Windows.
GIT_PATH_LIST_SEPARATOR and GIT_PATH_MAX are made public so
that it's can be used by a client.
2011-06-15 22:11:18 +02:00
Scott Chacon
737406b7ab fix gid_ misspelling 2011-06-14 09:31:19 -07:00
Vicent Marti
b023321669 Remove custom backends
All the custom backend code will be moved to a separate project,
	together with the new MySQL backend.
2011-06-14 17:40:17 +02:00
Vicent Martí
e3f56a2b57 Merge pull request #216 from glesserd/development
git_tag_create{,_o,_frombuffer} correction and improvement
2011-06-08 08:11:26 -07:00
Carlos Martín Nieto
a2a305fcf4 config: explain the cfg and file relationship better
It's not clear how git_config and git_config_file relate to one
another. Be more explicit about their relationship in the function
documentation.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-07 15:39:40 +02:00
Carlos Martín Nieto
ce78f39e27 config: update the git_config_add_file documentation
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-06-07 14:18:22 +02:00
Vicent Marti
340fc0d40a threads: Cleanup TLS declarations
This time for good.
2011-06-07 03:39:19 +02:00
Vicent Marti
9d77d83a81 Revert "threads: Fix TLS declarations"
This commit uploaded an old broken test. Oops!
2011-06-07 03:38:09 +02:00
Vicent Martí
1097dacd7d Merge pull request #240 from Romain-Geissler/tree-object-type
Tree: Added a function that returns the type of a tree entry.
2011-06-06 18:33:38 -07:00
Vicent Martí
9b1692ebfc Merge pull request #239 from pegonma/oid_prefix
Search objects of different types given OID prefix
2011-06-06 18:31:21 -07:00
Vicent Martí
1b0d92b141 Merge pull request #238 from pegonma/git_oid_ncmp
Better name for git_oid_match
2011-06-06 18:28:11 -07:00
Vicent Martí
00c31dd293 Merge pull request #234 from Romain-Geissler/entry-count-API-uniformisation
[Tree | Index] API uniformisation
2011-06-06 18:26:50 -07:00
Vicent Marti
64fe8c62f9 threads: Fix TLS declarations
Cleanup the thread-utils file. Do not define TLS if libgit2 is not
threadsafe.
2011-06-07 03:22:32 +02:00
Romain Geissler
ff9a4c130d Tree: Added a function that returns the type of a tree entry. 2011-06-06 17:14:30 +02:00
Marc Pegon
c09093cce2 Renamed git_oid_match to git_oid_ncmp.
As suggested by carlosmn, git_oid_ncmp would probably
be a better name than git_oid_match, for it does the same
as git_oid_cmp but only up to a certain amount of hex digits.
2011-06-06 17:04:37 +02:00
Marc Pegon
790c6c95fe Added methods to search objects of different types
given an OID prefix.
2011-06-06 11:55:48 +02:00
Romain Geissler
f11e079733 Index: API uniformisation: Use unsigned int for all index number.
Feature Added: Search an unmerged entry by path (git_index_get_unmerged
renamed to git_index_get_unmerged_bypath) or by index (git_index_get_unmerged_byindex).
2011-06-05 21:19:03 +02:00
Romain Geissler
e5c8009731 Tree: API uniformasation: Use unsigned int for all index number. 2011-06-05 21:18:05 +02:00
Vicent Marti
602ee38b6e repository: Export all internal paths 2011-06-04 20:45:09 +02:00
David Glesser
f4c925c514 Change a dirty indentation 2011-06-04 16:09:19 +02:00
Vicent Martí
793545ef2b Merge pull request #227 from Romain-Geissler/discovery-path-v2
Discovery path v2
2011-06-03 17:41:53 -07:00
Romain Geissler
fd0574e5ad Repository: Added the git_repository_discover function that finds by itself the git directory that manage a given directory path. 2011-06-04 01:05:36 +02:00
Vicent Marti
3a42e0a370 index: Add git_index_entry_stage method
As suggested by Romain-Geissler
2011-06-03 21:38:55 +02:00
Vicent Marti
d0323a5f63 short-oid: Cleanup 2011-06-01 23:40:42 +02:00
Marc Pegon
da03c9f35b Changed return value of git_oid_match to be consistent with the other compare methods (0 means oids match). Added method to compare prefixes of hex formatted oids. 2011-06-01 23:40:42 +02:00
Marc Pegon
ac2b94ad76 Added a GIT_OID_MINPREFIXLEN constant to define the minimum length allowed for oid prefixes (set to 4, like in git). Consequently updated some object lookup methods and their documentation. 2011-06-01 23:40:41 +02:00
Marc Pegon
dd453c4dbf Added git.git sha1 lookup method to replace simple binary search in pack backend.
Implemented find_unique_short_oid for pack backend, based on git sha1 lookup method;
finding an object given its full oid is just a particular case of searching
the unique object matching an oid prefix (short oid).

Added git_odb_read_unique_short_oid, which iterates over all the backends to
find and read the unique object matching the given oid prefix.

Added a git_object_lookup_short_oid method to find the unique object in
the repository matching a given oid prefix : it generalizes git_object_lookup
which now does nothing but calls git_object_lookup_short_oid.
2011-06-01 23:40:41 +02:00
Marc Pegon
53c0bd81a2 Added error for ambiguous oid prefixes. Added methods to compare the first nth hexadecimal characters (i.e. packets of 4 bits) of OIDs. 2011-06-01 23:40:41 +02:00
Marc Pegon
ecd6fdf1f7 Added a read_unique_short_oid method to backends, to make it possible to find objects from sha1 prefixes in the future. Default implementations throw GIT_ENOTIMPLEMENTED for strict prefixes (i.e. length < GIT_OID_HEXSZ). 2011-06-01 23:40:41 +02:00
Vicent Martí
50b7334e51 Merge pull request #206 from nulltoken/topic/is-bare
Add git_repository_is_bare() accessor
2011-06-01 09:58:21 -07:00
Vicent Marti
f7e59c4dcf index: Change the memory management for repo indexes
The `git_repository_index` call now returns a brand new index that must
be manually free'd.
2011-06-01 18:54:47 +02:00
Vicent Marti
ef5ffed39a object: Update documentation 2011-06-01 18:45:23 +02:00
David Glesser
23123151e0 Set the oid when a tag already exists.
When a tag already exists, it can be useful to directly have the oid
of the existed tag, just after trying to add it.
2011-05-30 09:03:55 +02:00
nulltoken
fa9bcd81f5 Add git_repository_is_bare() accessor 2011-05-24 21:50:02 +02:00
Vicent Marti
b0b527e0ad config: Cleanup & renaming of the external API
"git_config_backend" have been renamed to "git_config_file", which
implements a generic interface to access a configuration file -- be it
either on disk, from a DB or whatever mumbojumbo.

I think this makes more sense.
2011-05-20 03:20:12 +03:00
Vicent Martí
274f2c213f Merge pull request #193 from carlosmn/config
A couple of config improvements
2011-05-19 14:18:57 -07:00
Vicent Marti
f4e2aca29c index: Fix issues in the unmerged entries API 2011-05-19 20:38:17 +03:00
Jakob Pfender
050e8877dd Merge branch 'development' into unmerged 2011-05-17 15:31:05 +02:00
Carlos Martín Nieto
f44cbec479 Add documentation for git_config_add_backend 2011-05-17 14:59:23 +02:00
Carlos Martín Nieto
32234541f6 Implement git_config_open_global
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-17 14:31:57 +02:00
Vicent Marti
128d37316b config_file: Fix compilation 2011-05-17 15:11:19 +03:00
Carlos Martín Nieto
94711cad3b Merge upstream/development 2011-05-17 12:12:59 +02:00
Vicent Marti
f87d9beb8d Change error codes from DEFINEs to an enum 2011-05-15 23:46:39 +03:00
Vicent Marti
f31bd03f7e Include "common.h" in "errors.h" 2011-05-13 04:19:50 +03:00
Vicent Marti
6810bf28f8 Move all error-related defines to git2/errors.h 2011-05-11 00:40:07 +03:00
Vicent Marti
f4a936b56a Bring back git_strerror
We cannot totally deprecate this until the new error handling mechanisms
are all in place.
2011-05-11 00:35:40 +03:00
Carlos Martín Nieto
c033500549 Move config to a backend structure
Configuration options can come from different sources. Currently,
there is only support for reading them from a flat file, but it might
make sense to read it from a database at some point.

Move the parsing code into src/config_file.c and create an include
file include/git2/config_backend.h to allow for other backends to be
developed.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-05-10 14:47:20 +02:00
kelly.leahy
ab86f159e5 Fix issue #79 - git_lasterror() isn't appearing in git2.dll in windows.
The GIT_EXPORT macro is used to declare a function to be externally
accessible to other libraries.  This commit uses GIT_EXPORT to declare
the git_lasterror() function as externally exported.  I verified with
depends.exe that the function is available to external callers (i.e.
in the exports table of the PE file).
2011-05-09 23:39:32 -07:00
Vicent Marti
5711ca93d1 Merge branch 'error-handling' into development 2011-05-09 21:58:26 +03:00
Vicent Marti
fa59f18d0d Change error handling mechanism once again
Ok, this is the real deal. Hopefully. Here's how it's going to work:

- One main method, called `git__throw`, that sets the error
	code and error message when an error happens.

	This method must be called in every single place where an error
	code was being returned previously, setting an error message
	instead.

	Example, instead of:

		return GIT_EOBJCORRUPTED;

	Use:

		return git__throw(GIT_EOBJCORRUPTED,
			"The object is missing a finalizing line feed");

	And instead of:

		[...] {
			error = GIT_EOBJCORRUPTED;
			goto cleanup;
		}

	Use:

		[...] {
			error = git__throw(GIT_EOBJCORRUPTED, "What an error!");
			goto cleanup;
		}

	The **only** exception to this are the allocation methods, which
	return NULL on failure but already set the message manually.

		/* only place where an error code can be returned directly,
		   because the error message has already been set by the wrapper */
		if (foo == NULL)
			return GIT_ENOMEM;

- One secondary method, called `git__rethrow`, which can be used to
fine-grain an error message and build an error stack.

	Example, instead of:

		if ((error = foobar(baz)) < GIT_SUCCESS)
			return error;

	You can now do:

		if ((error = foobar(baz)) < GIT_SUCCESS)
			return git__rethrow(error, "Failed to do a major operation");

	The return of the `git_lasterror` method will be a string in the
	shape of:

		"Failed to do a major operation. (Failed to do an internal
		operation)"

	E.g.

		"Failed to open the index. (Not enough permissions to access
		'/path/to/index')."

	NOTE: do not abuse this method. Try to write all `git__throw`
	messages in a descriptive manner, to avoid having to rethrow them to
	clarify their meaning.

	This method should only be used in the places where the original
	error message set by a subroutine is not specific enough.

	It is encouraged to continue using this style as much possible to
	enforce error propagation:

		if ((error = foobar(baz)) < GIT_SUCCESS)
			return error; /* `foobar` has set an error message, and
							 we are just propagating it */

The error handling revamp will take place in two phases:

	- Phase 1: Replace all pieces of code that return direct error codes
	with calls to `git__throw`. This can be done semi-automatically
	using `ack` to locate all the error codes that must be replaced.

	- Phase 2: Add some `git__rethrow` calls in those cases where the
	original error messages are not specific enough.

Phase 1 is the main goal. A minor libgit2 release will be shipped once
Phase 1 is ready, and the work will start on gradually improving the
error handling mechanism by refining specific error messages.

OTHER NOTES:

	- When writing error messages, please refrain from using weasel
	words. They add verbosity to the message without giving any real
	information. (<3 Emeric)

	E.g.

		"The reference file appears to be missing a carriage return"
			Nope.

		"The reference file is missing a carriage return"
			Yes.

	- When calling `git__throw`, please try to use more generic error
	codes so we can eventually reduce the list of error codes to
	something more reasonable. Feel free to add new, more generic error
	codes if these are going to replace several of the old ones.

	E.g.

		return GIT_EREFCORRUPTED;

	Can be turned into:

		return git__throw(GIT_EOBJCORRUPTED,
			"The reference is corrupted");
2011-05-09 21:58:02 +03:00
Vicent Marti
5eb0fab846 errors: Update external API with new git_lasterror 2011-05-09 21:58:02 +03:00
Vicent Marti
02f9e637a1 errors: Add error handling function 2011-05-09 21:58:01 +03:00
Carlos Martín Nieto
ca8d2dfc0c Merge remote-tracking branch 'upstream/development' into config 2011-05-05 16:22:06 +02:00
Jason R. McNeil
773bc20dd3 Fix misspelling of git_index_append2 (was git_index_apppend2). 2011-05-03 22:22:42 -07:00
Vicent Marti
1648fbd344 Re-apply missing patches 2011-05-02 01:12:53 +03:00
Vicent Marti
f7a5058aaf index: Refactor add/replace methods
Removed the optional `replace` argument, we now have 4 add methods:

	`git_index_add`: add or update from path
	`git_index_add2`: add or update from struct
	`git_index_append`: add without replacing from path
	`git_index_append2`: add without replacing from struct

Yes, this breaks the bindings.
2011-04-24 00:31:43 +03:00
Jakob Pfender
4c0b6a6dac index: Add API for unmerged entries
New external functions:
	- git_index_unmerged_entrycount: Counts the unmerged entries in
	  the index
	- git_index_get_unmerged: Gets an unmerged entry from the index
	  by name

New internal functions:
	- read_unmerged: Wrapper for read_unmerged_internal
	- read_unmerged_internal: Reads unmerged entries from the index
	  if the index has the INDEX_EXT_UNMERGED_SIG set
	- unmerged_srch: Search function for unmerged vector
	- unmerged_cmp: Compare function for unmerged vector

New data structures:
	- git_index now contains a git_vector unmerged that stores
	  unmerged entries
	- git_index_entry_unmerged: Representation of an unmerged file
	  entry. It represents all three versions of the file at the
	  same time, with one name, three modes and three OIDs
2011-04-21 10:54:54 +02:00
Jakob Pfender
729b6f4900 index: Allow user to toggle whether to replace an index entry
When in the middle of a merge, the index needs to contain several files
with the same name. git_index_insert() used to prevent this by not adding a new entry if an entry with the same name already existed.
2011-04-21 10:40:54 +02:00
Carlos Martín Nieto
e69ac2439f config: export git_config_[sg]et_long
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-19 16:38:55 +02:00
Vicent Marti
def3fef197 Add git_tag_list
Lists all the tag references in a repository using a custom callback.
Includes unit tests courtesy of Emeric Fermas <3
2011-04-12 15:55:51 -07:00
Carlos Martín Nieto
55c197cdd3 Merge upstream/development 2011-04-11 17:43:56 +02:00
Vicent Marti
8416c9adcc Rename git_signature_new_now
The new name is more cool.
2011-04-09 15:31:12 -07:00
Carlos Martín Nieto
9e9e6ae177 Add API git_signature_new_now
Most tags will have a timestamp of whenever the code is running and
dealing with time and timezones is error-prone. Optimize for this case
by adding a function which causes the signature to be created with a
current timestamp.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:29:48 -07:00
Carlos Martín Nieto
b5c00c6d41 Fix the signature documentation
The parameters are given by '@param name' and not '@name'.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-04-09 15:29:28 -07:00
nulltoken
4a34b3a9ff Add two new accessors to the repository
git_repository_path() and git_repository_workdir() respectively return the path to the git repository and the working directory. Those paths are absolute and normalized.
2011-04-09 15:25:24 -07:00
Vicent Marti
c6e65acae6 Properly check strtol for errors
We are now using a custom `strtol` implementation to make sure we're not
missing any overflow errors.
2011-04-09 15:22:11 -07:00
Vicent Marti
41233c40c0 Add new method git_repository_is_empty 2011-04-08 12:42:18 -07:00
Jakob Pfender
26f2c897b8 index.h: Add IDXENTRY flags needed for index operations
Add several IDXENTRY flags that need to be checked in
order to properly implement update-index --refresh.
2011-04-08 03:33:50 +03:00
Sam
5924b2822c Added git_commit_tree_oid and git_commit_parent_oid. 2011-04-08 03:33:46 +03:00
Carlos Martín Nieto
8bd6c0ab83 Merge remote-tracking branch 'upstream/development' into config 2011-04-06 15:49:29 +02:00
Vicent Marti
0ad6efa110 Build & write custom trees in memory 2011-04-04 19:25:33 +03:00
Vicent Marti
29e1789b34 Fix the git_tree_write implementation 2011-04-04 12:14:43 +03:00
Sarath Lakshman
47d8ec56e9 New external API method: git_tree_create
Creates a tree by scanning the index file. The method handles recursive
creation of trees for subdirectories and adds them to the parent tree.
2011-04-03 17:18:56 +05:30
Vicent Marti
3e3e4631a0 Merge branch 'tagging' of https://github.com/nulltoken/libgit2 into development
Conflicts:
	include/git2/tag.h
	src/tag.c
2011-04-02 12:50:25 +03:00
Vicent Marti
d8ad64d366 Merge branch 'parse-tag-buffer' of https://github.com/carlosmn/libgit2 into development 2011-04-02 12:28:35 +03:00
Carlos Martín Nieto
f026f2b9ee Merge upstream/development
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-31 15:29:13 +02:00
nulltoken
ac26e2454e Rename git_tag_create_o_f() to git_tag_create_fo() 2011-03-30 23:46:54 +02:00
nulltoken
9e680bcc00 Add git_tag_delete() 2011-03-30 23:26:36 +02:00
nulltoken
a50c145855 Add git_tag_create_o_f() and git_tag_create_f() which overwrite existing tag reference, if any 2011-03-30 23:16:30 +02:00
nulltoken
bf4c39f929 Prevent tag_create() from creating a conflicting reference 2011-03-30 22:30:55 +02:00
Carlos Martín Nieto
2974aa94c3 Determine variable type at runtime
Config variables should be interpreted at run-time, as we don't know if a
zero means false or zero, or if yes means true or "yes".

As a variable has no intrinsic type, git_cvtype is gone and the public
API takes care of enforcing a few rules.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-30 13:42:24 +02:00
Vicent Marti
95cde17ca4 Enforce coding conventions in refs.c
Internal methods are static and without the git prefix.
'Force' methods have a `_f` prefix to match the other 'force' methods.
2011-03-29 19:58:19 +03:00
Carlos Martín Nieto
4cd6ed7566 Fix documentation copy error
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
c7db45e862 Match the comment with the error string
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
fa20496200 Allow forcing the creation or renaming of references
Add internal reference create and rename functions which take a force
parameter, telling them to overwrite an existing reference if it
exists.

These functions try to update the reference if it's of the same type
as the one it's going to be replaced by. Otherwise the old reference
becomes invalid.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
baad182cbc Add GIT_EEXISTS error code
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 19:58:18 +03:00
Carlos Martín Nieto
9a3c5e55fd Expose config API for setters, getters and foreach
These functions can be used to query or modify the variables in a
given configuration. No sanity checking is done on the variable names.

This is mostly meant as an API preview.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 18:13:47 +02:00
Carlos Martín Nieto
6d7bb4e039 Move git_cvar_type to include/git2/config.h
Include it in src/config.h and fix the header name #define.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 17:35:02 +02:00
Carlos Martín Nieto
238df5590c Rename git_config_{type,var} to git_cvar{_type,}
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 12:48:47 +02:00
Carlos Martín Nieto
05314b5bf4 Make GIT_EINVALIDTYPE available for use in config
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-29 12:25:46 +02:00
schu
9d80d74da5 signature.h: Fix tiny typo 2011-03-28 17:57:08 +02:00
Carlos Martín Nieto
5d4cd00305 Move the struct declaration outside config.c
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 17:03:08 +02:00
Carlos Martín Nieto
7b4a16e2c8 Add git_tag_create_frombuffer API
Expose the tag parsing capabilities already present in the
library.

Exporting this function makes it possible to implement the
mktag command without duplicating this functionality.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-28 13:59:48 +02:00
Vicent Marti
09e8de0f38 New external API method: git_reference_listcb
List all the references in the repository, calling a custom
callback for each one.

The listed references may be filtered by type, or using
a bitwise OR of several types. Use the magic value
`GIT_REF_LISTALL` to obtain all references, including
packed ones.

The `callback` function will be called for each of the references
in the repository, and will receive the name of the reference and
the `payload` value passed to this method.
2011-03-25 23:53:38 +02:00
Jakob Pfender
051d6915d7 index.h: Fix minor typo 2011-03-25 00:49:47 +02:00
Jakob Pfender
12f6d8e145 index.h: Correct documentation for git_index_open_inrepo()
Fix the doxygen comments for git_index_open_inrepo(). Previously they
referred to a param index_path and omitted index (probably a c&p
error).
2011-03-25 00:49:47 +02:00
Vicent Marti
815c9bc7de Remove circular dependency in includes 2011-03-23 20:18:34 +02:00
Jakob Pfender
ea269511ad odb.h: Fix minor typo
Fix a doxygen typo ("@para" instead of "@param") in odb.h
2011-03-23 18:55:44 +02:00
Jakob Pfender
c585f55ff4 common.h: Fix minor typos
Fix a few minor typos in the documentation of the GIT_ERROR codes.
2011-03-23 18:55:41 +02:00
Vicent Marti
f6f72d7ef8 Improve the ODB writing backend
Temporary files when doing streaming writes are now stored inside the
Objects folder, to prevent issues when moving files between
disks/partitions.

Add support for block writes to the ODB again (for those backends that
cannot implement streaming).
2011-03-23 18:44:53 +02:00
Vicent Marti
c0ffe51853 Do not return on void helper methods
MSVC doesn't swallow that.
2011-03-23 15:44:52 +02:00
Vicent Marti
f0d08b7cec Remove git_repository_gc from the headers 2011-03-23 15:40:47 +02:00
Carlos Martín Nieto
b0b8313583 Add close wappers for commit, tree, tag and blob
In the same spirit that git_repository_lookup is no longer available,
add wrappers so the users don't have to cast when closing their
objects.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
2011-03-23 11:08:42 +01:00
Vicent Marti
7c80c19e1d Fix compilation in MinGW 2011-03-23 01:58:18 +02:00
nulltoken
56d8ca266c Switch from time_t to git_time_t
git_time_t is defined as a signed 64 integer. This allows a true predictable multiplatform behavior.
2011-03-23 00:07:58 +02:00
Vicent Marti
1881f0783b Add getters for git_odb_object 2011-03-22 20:38:33 +02:00
Vicent Marti
72a3fe42fb I broke your bindings
Hey. Apologies in advance -- I broke your bindings.

This is a major commit that includes a long-overdue redesign of the
whole object-database structure. This is expected to be the last major
external API redesign of the library until the first non-alpha release.

Please get your bindings up to date with these changes. They will be
included in the next minor release. Sorry again!

Major features include:

	- Real caching and refcounting on parsed objects
	- Real caching and refcounting on objects read from the ODB
	- Streaming writes & reads from the ODB
	- Single-method writes for all object types
	- The external API is now partially thread-safe

The speed increases are significant in all aspects, specially when
reading an object several times from the ODB (revwalking) and when
writing big objects to the ODB.

Here's a full changelog for the external API:

blob.h
------

	- Remove `git_blob_new`
	- Remove `git_blob_set_rawcontent`
	- Remove `git_blob_set_rawcontent_fromfile`
	- Rename `git_blob_writefile` -> `git_blob_create_fromfile`
	- Change `git_blob_create_fromfile`:
		The `path` argument is now relative to the repository's working dir
	- Add `git_blob_create_frombuffer`

commit.h
--------

	- Remove `git_commit_new`
	- Remove `git_commit_add_parent`
	- Remove `git_commit_set_message`
	- Remove `git_commit_set_committer`
	- Remove `git_commit_set_author`
	- Remove `git_commit_set_tree`

	- Add `git_commit_create`
	- Add `git_commit_create_v`
	- Add `git_commit_create_o`
	- Add `git_commit_create_ov`

tag.h
-----

	- Remove `git_tag_new`
	- Remove `git_tag_set_target`
	- Remove `git_tag_set_name`
	- Remove `git_tag_set_tagger`
	- Remove `git_tag_set_message`

	- Add `git_tag_create`
	- Add `git_tag_create_o`

tree.h
------

	- Change `git_tree_entry_2object`:
		New signature is `(git_object **object_out, git_repository *repo, git_tree_entry *entry)`

	- Remove `git_tree_new`
	- Remove `git_tree_add_entry`
	- Remove `git_tree_remove_entry_byindex`
	- Remove `git_tree_remove_entry_byname`
	- Remove `git_tree_clearentries`
	- Remove `git_tree_entry_set_id`
	- Remove `git_tree_entry_set_name`
	- Remove `git_tree_entry_set_attributes`

object.h
------------

	- Remove `git_object_new
	- Remove `git_object_write`

	- Change `git_object_close`:
		This method is now *mandatory*. Not closing an object causes a
		memory leak.

odb.h
-----

	- Remove type `git_rawobj`
	- Remove `git_rawobj_close`
	- Rename `git_rawobj_hash` -> `git_odb_hash`
	- Change `git_odb_hash`:
		New signature is `(git_oid *id, const void *data, size_t len, git_otype type)`

	- Add type `git_odb_object`
	- Add `git_odb_object_close`

	- Change `git_odb_read`:
		New signature is `(git_odb_object **out, git_odb *db, const git_oid *id)`
	- Change `git_odb_read_header`:
		New signature is `(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)`
	- Remove `git_odb_write`
	- Add `git_odb_open_wstream`
	- Add `git_odb_open_rstream`

odb_backend.h
-------------

	- Change type `git_odb_backend`:
		New internal signatures are as follows

			int (* read)(void **, size_t *, git_otype *, struct git_odb_backend *, const git_oid *)
			int (* read_header)(size_t *, git_otype *, struct git_odb_backend *, const git_oid *)
			int (* writestream)(struct git_odb_stream **, struct git_odb_backend *, size_t, git_otype)
			int (* readstream)( struct git_odb_stream **, struct git_odb_backend *, const git_oid *)

	- Add type `git_odb_stream`
	- Add enum `git_odb_streammode`

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-20 21:45:11 +02:00
Vicent Marti
bb3de0c472 Thread safe cache 2011-03-20 21:45:06 +02:00
Vicent Marti
b5c5f0f808 Fix headers for the new Revision Walker
The "oid.h" header is now included instead of "object.h".

The old "revwalk.h" header has been removed; it was empty.
2011-03-16 23:59:09 +02:00
Vicent Marti
36aaf1ff1a Change the Revwalk reset behavior to the old version
The `reset` call now removes the pushed commits so we can reuse
the revwalker. The API documentation has been updated with the details.
2011-03-16 01:53:25 +02:00
Vicent Marti
8613d4a930 Fix signature in git_repository_gc
The method returns an int with the amount of objects free'd
2011-03-16 01:10:40 +02:00
Vicent Marti
54a1b36c25 Export git_repository_gc properly
One of my brainfarts made me export it as `git_repository_close` instead
of GC. Duh.
2011-03-16 01:07:06 +02:00
Vicent Marti
955f9ae9bd Export git_strarray_free instead of inlining
That way non-C bindings can use it.
2011-03-16 01:06:15 +02:00
Vicent Marti
bbcc7ffc69 Add proper threading support to libgit2
We now depend on libpthread on all Unix platforms (should be installed
by default) and use a simple wrapper for Windows threads under Win32.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-15 21:14:07 +02:00
Vicent Marti
6b2a19418c Fix the retarded object interdependency system
It's no longer retarded. All object interdependencies are stored as OIDs
instead of actual objects. This should be hundreds of times faster,
specially on big repositories. Heck, who knows, maye it doesn't even
segfault -- wouldn't that be awesome?

What has changed on the API?

	`git_commit_parent`, `git_commit_tree`, `git_tag_target` now return
	their values through a pointer-to-pointer, and have an error code.

	`git_commit_set_tree` and `git_tag_set_target` now return an error
	code and may fail.

	`git_repository_free__no_gc` has been deprecated because it's
	stupid. Since there are no longer any interdependencies between
	objects, we don't need internal reference counting, and GC
	never fails or double-free's pointers.

	`git_object_close` now does a very sane thing: marks an object
	as unused. Closed objects will be eventually free'd from the
	object cache based on LRU. Please use `git_object_close` from
	the garbage collector `destroy` method on your bindings. It's
	100% safe.

	`git_repository_gc` is a new method that forces a garbage collector
	pass through the repo, to free as many LRU objects as possible.
	This is useful if we are running out of memory.
2011-03-14 23:52:32 +02:00
Vicent Marti
0057182807 Add new method git_reference_listall
Lists all the references in a repository. Listing may be filtered by
reference type.

This should applease Lord Clem.
2011-03-14 23:52:32 +02:00
Vicent Marti
71db842fac Rewrite the Revision Walker
The new revision walker uses an internal Commit object storage system,
custom memory allocator and much improved topological and time sorting
algorithms. It's about 20x times faster than the previous implementation
when browsing big repositories.

The following external API calls have changed:

	`git_revwalk_next` returns an OID instead of a full commit object.
	The initial call to `git_revwalk_next` is no longer blocking when
	iterating through a repo with a time-sorting mode.

	Iterating with Topological or inverted modes still makes the initial
	call blocking to preprocess the commit list, but this block should be
	mostly unnoticeable on most repositories (topological preprocessing
	times at 0.3s on the git.git repo).

	`git_revwalk_push` and `git_revwalk_hide` now take an OID instead
	of a full commit object.
2011-03-14 23:52:15 +02:00
Vicent Marti
26022f0719 Add git_oid_shorten (unique OID minimzer)
Set of methods to find the minimal-length to uniquely identify every OID
in a list. Useful for GUI applications, commit logs and so on.

Includes stress test.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-14 23:36:10 +02:00
Vicent Marti
d6b5f5cca9 Add git_oid_shorten
Set of methods to find the minimal-length to uniquely identify every OID
in a list.

Includes stress test.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 23:54:49 +02:00
Vicent Marti
545a6915eb Change interface for Tree Index attr (always unsigned)
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:46:37 +02:00
Sakari Jokinen
9de27ad0c4 Check for valid range of attributes for tree entry 2011-03-05 13:46:27 +02:00
Vicent Marti
3490188b3c Change the return type of git_blob_rawcontent
Should return `void *` for raw bytes.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-05 13:29:50 +02:00
Vicent Marti
71d33382a7 Move the external includes folder from src to include
Signed-off-by: Vicent Marti <tanoku@gmail.com>
2011-03-03 20:23:53 +02:00