Commit Graph

2140 Commits

Author SHA1 Message Date
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
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
Vicent Martí
54e4d0f25b Merge pull request #629 from nulltoken/issue/index-refcount
Index refcount issue
2012-04-18 17:34:52 -07:00
Russell Belfer
44ef8b1b30 Fix warnings on 64-bit windows builds
This fixes all the warnings on win64 except those in deps, which
come from the regex code.
2012-04-17 10:47:39 -07:00
Russell Belfer
f201d613a8 Add git_reference_lookup_oid and lookup_resolved
Adds a new public reference function `git_reference_lookup_oid`
that directly resolved a reference name to an OID without returning
the intermediate `git_reference` object (hence, no free needed).

Internally, this adds a `git_reference_lookup_resolved` function
that combines looking up and resolving a reference.  This allows
us to be more efficient with memory reallocation.

The existing `git_reference_lookup` and `git_reference_resolve`
are reimplmented on top of the new utility and a few places in the
code are changed to use one of the two new functions.
2012-04-17 10:44:50 -07:00
Russell Belfer
1a6e8f8a54 Update clar and remove old helpers
This updates to the latest clar which includes the helpers
`cl_assert_equal_s` and `cl_assert_equal_i`.  Convert the code
over to use those and remove the old libgit2-only helpers.
2012-04-17 10:35:11 -07:00
Russell Belfer
dbeca79698 Remove old status implementation
This removes the code for the old status implementation.
2012-04-17 10:35:11 -07:00
Russell Belfer
e8c3774f9b Merge pull request #599 from carlosmn/config-quotes
Support config value quoting
2012-04-16 10:10:05 -07:00
Carlos Martín Nieto
2c1075d65a config: parse quoted values
Variable values may be quoted to include newlines, literal quotes and
other characters. Add support for these and test it.
2012-04-16 10:25:52 +02:00
schu
3fa1ec4af6 tests-clar/repo: fix unused warning
ifdef GIT_WIN32 helper unposix_path() to avoid unused-function warning
on non-Windows systems.

Signed-off-by: schu <schu-github@schulog.org>
2012-04-15 20:30:12 +02:00
Carlos Martín Nieto
146f5c75d7 repo: plug a couple of leaks 2012-04-14 15:09:29 +02:00
nulltoken
c1aefb35dd Fix git_repository_set_index() refcount issue
git_repository_free() calls git_index_free() if the owned index is not null.

According to the doc, when setting a new index through git_repository_set_index() the caller has still to take care of releasing the index by itself.

In order to cope with this, this fix makes sure the index refcount is incremented when a new repository is being plugged a new index.
2012-04-14 15:05:38 +02:00
nulltoken
fdd1149c29 Fix MSVC compilation warnings
Removed unreferenced variables.
2012-04-14 13:46:13 +02:00
Vicent Martí
e77e53edb3 Merge pull request #627 from arrbee/diff-with-pathspec
Diff with pathspec
2012-04-13 20:06:49 -07:00
Russell Belfer
14a513e058 Add support for pathspec to diff and status
This adds preliminary support for pathspecs to diff and status.
The implementation is not very optimized (it still looks at
every single file and evaluated the the pathspec match against
them), but it works.
2012-04-13 15:00:29 -07:00
Carlos Martín Nieto
1c9c081a6a indexer: add git_indexer_stream_free() and _hash() 2012-04-13 22:19:45 +02:00
Carlos Martín Nieto
907ebe8556 examples: stream indexer example 2012-04-13 22:19:45 +02:00
Carlos Martín Nieto
453ab98da0 indexer: Add git_indexer_stream_finalize()
Resolve any lingering deltas, write out the index file and rename the
packfile.
2012-04-13 22:19:45 +02:00
Carlos Martín Nieto
3f93e16cff indexer: start writing the stream indexer
This will allow us to index a packfile as soon as we receive it from
the network as well as storing it with its final name so we don't need
to pass temporary file names around.
2012-04-13 22:19:44 +02:00
Carlos Martín Nieto
fa679339c4 Add packfile_unpack_compressed() to the internal header 2012-04-13 22:16:48 +02:00
Carlos Martín Nieto
45d773efea pack: signal a short buffer when needed 2012-04-13 22:16:48 +02:00
Vicent Martí
d1f331564d Merge remote-tracking branch 'carlosmn/revwalk-merge-base' into new-error-handling 2012-04-13 20:41:06 +02:00
Vicent Martí
fcb2164ff1 Merge pull request #623 from arrbee/refactor-open
Update git_repository_open
2012-04-13 10:51:58 -07:00
Carlos Martín Nieto
4d53f3e214 filebuf: add option not to buffer the contents at all
The new indexer needs to be able to bypass any kind of buffering, as
it's trying to map data that it has just written to disk.
2012-04-13 09:50:41 +02:00
Carlos Martín Nieto
6a62543597 branch: simplify error handling for git_branch_move()
The cleanup needs to happen anyway, so set the error code and jump
there instead of copying the code.
2012-04-12 23:40:41 +02:00
Vicent Martí
bf63cd0bd2 Merge pull request #625 from carlosmn/valgrind
Plug a few leaks
2012-04-12 14:28:15 -07:00
Carlos Martín Nieto
a15156930b local transport: plug leak 2012-04-12 20:54:55 +02:00
Carlos Martín Nieto
6a8bcfa48e branch: plug leaks in git_branch_move() and _delete() 2012-04-12 20:47:46 +02:00
Carlos Martín Nieto
eb8117b841 error-handling: revwalk 2012-04-12 20:27:17 +02:00
Carlos Martín Nieto
bf787bd87c Move git_merge_base() to is own header and document it 2012-04-12 20:25:25 +02:00
Carlos Martín Nieto
f9e4bfa39b revwalk: use a priority queue for calculating merge bases
As parents are older than their children, we're appending to the
commit list most of the time, which makes an ordered linked list quite
inefficient.

While we're there, don't sort the results list in the main loop, as
we're sorting them afterwards and it creates extra work.
2012-04-12 20:25:25 +02:00
Carlos Martín Nieto
5cf7bccd2b revwalk: add test hiding a commit without a merge base
Nothing should be hidden and this shouldn't bother the merge base
calculation.
2012-04-12 20:25:25 +02:00
Carlos Martín Nieto
2c4ef1dd0d revwalk: use merge bases to speed up processing
There is no need walk down the parents of a merge base to mark them as
uninteresting because we'll never see them. Calculate the merge bases
in prepare_walk() so mark_uninteresting() can stop at a merge base
instead of walking all the way to the root.
2012-04-12 20:25:25 +02:00
Carlos Martín Nieto
de7ab85dc6 Implement git_merge_base()
It's implemented in revwalk.c so it has access to the revision
walker's commit cache and related functions. The algorithm is the one
used by git, modified so it fits better with the library's functions.
2012-04-12 20:25:24 +02:00
Carlos Martín Nieto
06b9d91590 revwalk: allow pushing/hiding a reference by name
The code was already there, so factor it out and let users push an OID
by giving it a reference name. Only refs to commits are
supported. Annotated tags will throw an error.
2012-04-12 20:25:24 +02:00
Carlos Martín Nieto
081d229106 revwalk: don't assume malloc succeeds 2012-04-12 20:25:24 +02:00
Russell Belfer
7784bcbbee Refactor git_repository_open with new options
Add a new command `git_repository_open_ext` with extended options
that control how searching for a repository will be done.  The
existing `git_repository_open` and `git_repository_discover` are
reimplemented on top of it.  We may want to change the default
behavior of `git_repository_open` but this commit does not do that.

Improve support for "gitdir" files where the work dir is separate
from the repo and support for the "separate-git-dir" config.  Also,
add support for opening repos created with `git-new-workdir` script
(although I have only confirmed that they can be opened, not that
all functions work correctly).

There are also a few minor changes that came up:

- Fix `git_path_prettify` to allow in-place prettifying.

- Fix `git_path_root` to support backslashes on Win32.  This fix
  should help many repo open/discover scenarios - it is the one
  function called when opening before prettifying the path.

- Tweak `git_config_get_string` to set the "out" pointer to NULL
  if the config value is not found.  Allows some other cleanup.

- Fix a couple places that should have been calling
  `git_repository_config__weakptr` and were not.

- Fix `cl_git_sandbox_init` clar helper to support bare repos.
2012-04-11 12:11:35 -07:00
Russell Belfer
1de77cd314 Cannot set workdir to a nonexistent dir 2012-04-11 12:10:14 -07:00
Vicent Martí
64b402f856 status: Remove status_old
This is Git yo. You can fetch stuff from the history if you need it.
2012-04-11 19:19:12 +02:00
Vicent Martí
e1f6f94a92 tests: Remove unused file 2012-04-11 19:17:21 +02:00