Commit Graph

2178 Commits

Author SHA1 Message Date
Russell Belfer
3fd99be98a Convert from strnlen to git_text_is_binary
Since strnlen is not supported on all platforms and since we
now have the shiny new git_text_is_binary in the filtering
code, let's convert diff binary detection to use the new stuff.
2012-05-02 15:36:38 -07:00
Russell Belfer
8b2bcfbe68 Copy values to avoid strict aliasing warning
To make this code more resilient to future changes, we'll
explicitly translate the libgit2 structure to the libxdiff
structure.
2012-05-02 15:36:33 -07:00
Russell Belfer
16b83019af Fix usage of "new" for fieldname in public header
This should restore the ability to include libgit2 headers
in C++ projects.

Cherry picked 2de60205df from
development into new-error-handling.
2012-05-02 15:34:58 -07:00
Vicent Martí
b88021463f Merge remote-tracking branch 'carlosmn/remaining-errors' into new-error-handling
Conflicts:
	src/refspec.c
2012-05-01 19:16:14 -07:00
Vicent Martí
5587a9c930 Merge pull request #658 from schu/remote-disconnect
remote: don't free transport on disconnect
2012-05-01 17:55:22 -07:00
Michael Schubert
42ea35c061 remote: don't free transport on disconnect
Currently, git_remote_disconnect not only closes the connection but also
frees the underlying transport object, making it impossible to write
code like

	// fetch stuff
	git_remote_download()

	// close connection
	git_remote_disconnect()

	// call user provided callback for each ref
	git_remote_update_tips(remote, callback)

because remote->refs points to references owned by the transport object.
This means, we have an idling connection while running the callback for
each reference.

Instead, allow immediate disconnect and free the transport later in
git_remote_free().
2012-05-02 01:06:49 +02:00
Michael Schubert
52877c8975 tests-clar/diff: mark output_len unused 2012-05-01 15:13:14 +02:00
Vicent Martí
960d778619 Merge pull request #655 from nulltoken/topic/cr-normalization-test
crlf normalization test coverage
2012-04-30 15:57:20 -07:00
nulltoken
4e7a3c76e7 attr: add test coverage related to crlf normalization while staging 2012-05-01 00:33:25 +02:00
Vicent Martí
ced9da5412 Merge pull request #654 from carlosmn/pkt-err
Recognize and report server-side error messages
2012-04-30 14:38:15 -07:00
Russell Belfer
0dc8e95e19 Merge pull request #652 from nulltoken/topic/diff-callbacks
diff: provide more context to the consumer of the callbacks
2012-04-30 13:32:09 -07:00
Carlos Martín Nieto
39e6af6a7c net: recognize and report server-side error messages
When e.g. a repository isn't found, the server sends an error saying
so. Put that error message in our error buffer.
2012-04-30 18:24:14 +02:00
nulltoken
2de0652bb6 Leverage GIT_UNUSED macro to explicitly mark a function parameter as purposely unused 2012-04-30 07:41:33 +02:00
nulltoken
fa6420f73e buf: deploy git_buf_len() 2012-04-30 07:12:37 +02:00
nulltoken
1d2dd864ad diff: provide more context to the consumer of the callbacks
Update the callback to provide some information related to the file change being processed and the range of the hunk, when applicable.
2012-04-30 07:12:26 +02:00
nulltoken
da3c187d5e buf: add git_buf_len() accessor to expose the current length of the buffer content 2012-04-29 19:16:26 +02:00
Carlos Martín Nieto
8b9ec201ed Add a travis config file
Teach travis how to build the project.
2012-04-29 01:38:36 +02:00
Carlos Martín Nieto
fdc0c5f654 pkt: bring back GIT_ESHORTBUFFER
The recent 64-bit Windows fixes changed the return code in
git_pkt_parse_line() so it wouldn't signal a short buffer, breaking
the network code. Bring it back.
2012-04-29 01:21:53 +02:00
Michael Schubert
8af503bc85 remote: add more doc on git_remote_free 2012-04-28 20:49:05 +02:00
Michael Schubert
9738e2cd2c refs: fix unused-but-set warning 2012-04-27 23:30:08 +02:00
Russell Belfer
821f6bc740 Fix Win32 warnings 2012-04-26 13:04:54 -07:00
Vicent Martí
631ba94e0e Merge pull request #646 from arrbee/ignore-pat-leading-slash
Ignore pat leading slash
2012-04-26 12:08:43 -07:00
Russell Belfer
d58336dda8 Fix leading slash behavior in attrs/ignores
We were not following the git behavior for leading slashes
in path names when matching git ignores and git attribute
file patterns.  This should fix issue #638.
2012-04-26 10:51:45 -07:00
Carlos Martín Nieto
3aa351ea0f error handling: move the missing parts over to the new error handling 2012-04-26 15:38:42 +02:00
nulltoken
eb3d71a5bc diff: fix generation of the header of a removal patch 2012-04-25 15:37:17 -07:00
Russell Belfer
3fc5c65d1a Merge pull request #642 from arrbee/mem-pools
Memory pools and khash hashtables
2012-04-25 15:24:05 -07:00
Russell Belfer
c2b670436f Rename git_khash_str to git_strmap, etc.
This renamed `git_khash_str` to `git_strmap`, `git_hash_oid` to
`git_oidmap`, and deletes `git_hashtable` from the tree, plus
adds unit tests for `git_strmap`.
2012-04-25 15:20:28 -07:00
Vicent Martí
f50087c03b Merge pull request #641 from carlosmn/networking
More Networking updates
2012-04-25 14:29:45 -07:00
Carlos Martín Nieto
19dd4e2833 Include the new config test file 2012-04-25 20:42:33 +02:00
Russell Belfer
01fed0a8f9 Convert hashtable usage over to khash
This updates khash.h with some extra features (like error checking
on allocations, ability to use wrapped malloc, foreach calls, etc),
creates two high-level wrappers around khash: `git_khash_str` and
`git_khash_oid` for string-to-void-ptr and oid-to-void-ptr tables,
then converts all of the old usage of `git_hashtable` over to use
these new hashtables.

For `git_khash_str`, I've tried to create a set of macros that
yield an API not too unlike the old `git_hashtable` API.  Since
the oid hashtable is only used in one file, I haven't bother to
set up all those macros and just use the khash APIs directly for
now.
2012-04-25 11:18:08 -07:00
Russell Belfer
ada488bfe7 Import khash.h from attractivechaos/klib 2012-04-25 11:14:34 -07:00
Russell Belfer
c16c8b9a7e Adding stash to hashtable implementation
Adding a small stash of nodes with key conflicts has been
demonstrated to greatly increase the efficiency of a cuckoo
hashtable.  See:

  http://research.microsoft.com/pubs/73856/stash-full.9-30.pdf

for more details.
2012-04-25 11:14:34 -07:00
Russell Belfer
25f258e735 Moving power-of-two bit utilities into util.h 2012-04-25 11:14:34 -07:00
Russell Belfer
da3b391c32 Convert revwalk to use git_pool
This removes the custom paged allocator from revwalk and
replaces it with a `git_pool`.
2012-04-25 11:14:34 -07:00
Russell Belfer
19fa2bc111 Convert attrs and diffs to use string pools
This converts the git attr related code (including ignores) and
the git diff related code (and implicitly the status code) to use
`git_pools` for storing strings.  This reduces the number of small
blocks allocated dramatically.
2012-04-25 10:42:37 -07:00
Russell Belfer
2bc8fa0227 Implement git_pool paged memory allocator
This adds a `git_pool` object that can do simple paged memory
allocation with free for the entire pool at once.  Using this,
you can replace many small allocations with large blocks that
can then cheaply be doled out in small pieces.  This is best
used when you plan to free the small blocks all at once - for
example, if they represent the parsed state from a file or data
stream that are either all kept or all discarded.

There are two real patterns of usage for `git_pools`: either
for "string" allocation, where the item size is a single byte
and you end up just packing the allocations in together, or for
"fixed size" allocation where you are allocating a large object
(e.g. a `git_oid`) and you generally just allocation single
objects that can be tightly packed.  Of course, you can use it
for other things, but those two cases are the easiest.
2012-04-25 10:42:37 -07:00
Carlos Martín Nieto
a7d19b975a config: also allow escaping outside of a quoted string
This limitation was a misparsing of the documentation.
2012-04-25 15:47:53 +02:00
Carlos Martín Nieto
f184836bd2 remote: run a callback when updating the branch tips
This allows the caller to update an internal structure or update the
user output with the tips that were updated.

While in the area, only try to update the ref if the value is
different from its old one.
2012-04-25 13:25:45 +02:00
Carlos Martín Nieto
2e3a0055d1 revwalk: return GIT_EREVWALKER earlier if no references were pushed
In the case that walk->one is NULL, we know that we have no positive
references, so we already know that the revwalk is over.
2012-04-25 12:45:03 +02:00
Carlos Martín Nieto
bf4ef0c567 examples: run fetch in a background thread
This allows us to give updates on how it's doing
2012-04-25 12:44:52 +02:00
Carlos Martín Nieto
dee5515a23 transports: buffer the git requests before sending them
Trying to send every single line immediately won't give us any speed
improvement and duplicates the code we need for other transports. Make
the git transport use the same buffer functions as HTTP.
2012-04-25 12:44:27 +02:00
Carlos Martín Nieto
db0f96a6af examples: port 'fetch' to the new API 2012-04-25 12:39:17 +02:00
Carlos Martín Nieto
7a520f5d8a fetch: use the streaming indexer when downloading a pack
This changes the git_remote_download() API, but the existing one is
silly, so you don't get to complain.

The new API allows to know how much data has been downloaded, how many
objects we expect in total and how many we've processed.
2012-04-25 12:39:11 +02:00
Vicent Martí
f9f2344bd4 Merge pull request #632 from arrbee/win64-cleanup
Code clean up, including fixing warnings on Windows 64-bit build
2012-04-23 17:28:11 -07:00
Vicent Martí
4795807ad5 Merge pull request #637 from nulltoken/issue/odb-refcount
Fix git_repository_set_odb() refcount issue
2012-04-23 17:25:11 -07:00
Russell Belfer
26515e73a1 Rename to git_reference_name_to_oid 2012-04-23 10:06:31 -07:00
nulltoken
baf861a511 Fix git_repository_set_odb() refcount issue
git_repository_free() calls git_odb_free() if the owned odb is not null.

According to the doc, when setting a new odb through git_repository_set_odb() the caller has to take care of releasing the odb by himself.
2012-04-23 11:07:19 +02:00
schu
5c9a794d0b tests-clar: update to latest version of clar
Signed-off-by: schu <schu-github@schulog.org>
2012-04-21 18:36:13 +02:00
Carlos Martín Nieto
0586215662 tree-cache: don't error out on a childless invalidated entry
The code used to assume that there had to be data after the newline in
a tree cache extension entry. This isn't true for a childless
invalidated entry if it's the last one, as there won't be any children
nor a hash to take up space.

Adapt the off-by-one comparison to also work in this case. Fixes #633.
2012-04-20 02:23:14 +02:00
Vicent Martí
d59305544e Merge remote-tracking branch 'carlosmn/indexer-stream' into new-error-handling 2012-04-19 11:40:56 -07:00