Commit Graph

6779 Commits

Author SHA1 Message Date
Vicent Marti
7851e595ad Merge pull request #2351 from linquize/init-var
Initialize local variable
2014-05-14 16:05:23 +02:00
Vicent Marti
2bcc1afd10 Merge pull request #2349 from libgit2/rb/coverity-fixes
Increase config snapshot usage
2014-05-14 12:20:24 +02:00
Vicent Marti
a8af3e0284 Merge pull request #2348 from stewid/add-link-R-bindings
Add R bindings to the README
2014-05-14 12:18:57 +02:00
Russell Belfer
2b52a0bfae Increase use of config snapshots
And decrease extra reload checks of config data.
2014-05-13 16:32:27 -07:00
Russell Belfer
a37aa82ea6 Some coverity inspired cleanups 2014-05-13 15:54:23 -07:00
Stefan Widgren
562516eceb Add R bindings to the README 2014-05-13 22:43:59 +02:00
Linquize
b3f27c4368 Initialize local variable 2014-05-13 21:08:50 +08:00
Vicent Marti
03fcef1889 Merge pull request #2328 from libgit2/rb/how-broken-can-ignores-be
Improve checks for ignore containment
2014-05-13 12:40:13 +02:00
Vicent Marti
bcf9792f08 Merge pull request #2330 from libgit2/cmn/pack-unpack-loop
Make pack object lookup use loops
2014-05-13 12:36:51 +02:00
Vicent Marti
e161962634 Merge pull request #2346 from kitbellew/fix2300
Minor fix for previously merged netops code.
2014-05-13 12:35:56 +02:00
Albert Meltzer
7c57cd97d8 Win32 fix for #2300.
The code doesn't use SSL and a test requires it.
2014-05-12 20:51:03 -07:00
Carlos Martín Nieto
c968ce2c2c pack: don't forget to cache the base object
The base object is a good cache candidate, so we shouldn't forget to add
it to the cache.
2014-05-13 02:48:52 +02:00
Carlos Martín Nieto
15bcced223 pack: use stack allocation for smaller delta chains
This avoid allocating the array on the heap for relatively small
chains. The expected performance increase is sadly not really
noticeable.
2014-05-13 02:48:52 +02:00
Carlos Martín Nieto
a3ffbf230e pack: expose a cached delta base directly
Instead of going through a special entry in the chain, let's pass it as
an output parameter.
2014-05-13 02:48:48 +02:00
Russell Belfer
df3419269b Merge pull request #2336 from libgit2/rb/unicode-branch-names
Pass unconverted Unicode path data when iconv doesn't like it
2014-05-12 10:51:56 -07:00
Russell Belfer
af567e8853 Merge pull request #2334 from libgit2/rb/fix-2333
Be more careful with user-supplied buffers
2014-05-12 10:44:13 -07:00
Russell Belfer
ce3b71d91b Don't scale diff stat when not needed 2014-05-12 10:28:45 -07:00
Russell Belfer
b1914c3651 Minor fixes for warnings and error propagation 2014-05-12 10:24:46 -07:00
Russell Belfer
7bcced44b7 Merge pull request #2300 from libgit2/cmn/match-host-tests
Some improvements to the cert checking
2014-05-12 10:15:30 -07:00
Russell Belfer
d2c4d1c63d Merge pull request #2188 from libgit2/cmn/config-snapshot
Configuration snapshotting
2014-05-12 10:04:52 -07:00
Carlos Martín Nieto
9dbd150f5f pack: simplify delta chain code
The switch makes the loop somewhat unwieldy. Let's assume it's fine and
perform the check when we're accessing the data.

This makes our code look a lot more like git's.
2014-05-09 09:59:24 +02:00
Carlos Martín Nieto
b2559f477a pack: preallocate a 64-element chain
Dependency chains are often large and require a few
reallocations. Allocate a 64-element chain before doing anything else to
avoid allocations during the loop.

This value comes from the stack-allocated one git uses. We still
allocate this on the heap, but it does help performance a little bit.
2014-05-09 09:40:29 +02:00
Carlos Martín Nieto
e6d10c58b5 pack: make sure not to leak the dep chain 2014-05-09 09:40:29 +02:00
Carlos Martín Nieto
a332e91c92 pack: use a cache for delta bases when unpacking
Bring back the use of the delta base cache for unpacking objects. When
generating the delta chain, we stop when we find a delta base in the
pack's cache and use that as the starting point.
2014-05-09 09:40:29 +02:00
Carlos Martín Nieto
2acdf4b854 pack: unpack using a loop
We currently make use of recursive function calls to unpack an object,
resolving the deltas as we come back down the chain. This means that we
have unbounded stack growth as we look up objects in a pack.

This is now done in two steps: first we figure out what the dependency
chain is by looking up the delta bases until we reach a non-delta
object, pushing the information we need onto a stack and then we pop
from that stack and apply the deltas until there are no more left.

This version of the code does not make use of the delta base cache so it
is slower than what's in the mainline. A later commit will reintroduce
it.
2014-05-09 09:40:29 +02:00
Carlos Martín Nieto
ae0817393c pack: do not repeat the same error message four times
Repeating this error message makes it harder to find out where we
actually are finding the error, and they don't really describe what
we're trying to do.
2014-05-09 09:40:29 +02:00
Carlos Martín Nieto
86d5810b82 pack: remove misleading comment 2014-05-09 09:40:29 +02:00
Vicent Marti
e18d5e52e3 Merge pull request #2331 from libgit2/rb/dont-stop-diff-on-safecrlf
Add filter options and ALLOW_UNSAFE
2014-05-09 08:59:59 +02:00
Russell Belfer
bb45e39063 Disable threads::refdb::edit_while_iterate test
It seems that with the various recent changes to reference updating
and reflog writing, that the thread safety of refdb updates has
been reduced (either that or it was never thread safe and the
window for error has increased).  Either way, this test is now
sometimes segfaulting which is no good, so let's disable the test
for now.  We don't really make any public promises about thread
safety for this type of operation, so I think this is acceptable,
at least in the short term.
2014-05-08 15:01:07 -07:00
Russell Belfer
8a2ef218b9 Don't always test composed-insensitive lookups
Only on a filesystem that is composed/decomposed insensitive,
should be testing that a branch can be looked up by the opposite
form and still work correctly.
2014-05-08 14:48:27 -07:00
Russell Belfer
be20ac5a1d Allow cl_repo_get_bool to work with missing key
One of the test helpers provides a quick way for looking up a
boolean key.  But if the key way missing completely, the check
would actually raise an error.  Given the way we use this helper,
if the key is missing, this should just return false, I think.
2014-05-08 14:33:37 -07:00
Vicent Marti
4df53a64a1 Merge pull request #2335 from libgit2/cmn/indexer-vector-handling
indexer: avoid memory moves
2014-05-08 23:16:21 +02:00
Russell Belfer
43a0413524 Pass unconverted data when iconv doesn't like it
When using Iconv to convert unicode data and iconv doesn't like
the source data (because it thinks that it's not actual UTF-8),
instead of stopping the operation, just use the unconverted data.
This will generally do the right thing on the filesystem, since
that is the source of the non-UTF-8 path data anyhow.

This adds some tests for creating and looking up branches with
messy Unicode names.  Also, this takes the helper function that
was previously internal to `git_repository_init` and makes it
into `git_path_does_fs_decompose_unicode` which is a useful in
tests to understand what the expected results should be.
2014-05-08 13:52:46 -07:00
Carlos Martín Nieto
2dde1e0c1c indexer: avoid memory moves
Our vector does a move of the rest of the array when we remove an
item. Doing this repeatedly can be expensive, and we do this a lot in
the indexer. Instead, set the value to NULL and skip those entries.

perf reported around 30% of `index-pack` time was going into
memmove. With this change, that goes away and we spent most of the time
hashing and inflating data.
2014-05-08 22:40:13 +02:00
Russell Belfer
5ebe18b72c Merge pull request #2332 from libgit2/peff/iconv
iconv debugging aids
2014-05-08 13:29:09 -07:00
Jeff King
56ec2256f2 examples: add a basic for-each-ref example
This is quite close to running "git for-each-ref" except:

  1. It does not take any formatting or selection options at
     all.

  2. The output is not sorted.

I wrote it to look at debugging some issues with ref
iteration, but there's no reason it can't live on as an
example command.
2014-05-08 15:49:38 -04:00
Jeff King
6bcb098755 cmake: s/ICONV/Iconv/ in FIND_PACKAGE
The cmake module we provide is in the file FindIconv.cmake,
so we must match the case correctly. It happens to work in
practice because we only turn on ICONV on Darwin, and people
generally have case-insensitive filesystems there.

Note that we only need to update the package name here. The
package itself still sets the all-uppercase ICONV_FOUND
flag, so we continue to use uppercase in the rest of cmake.
2014-05-08 15:48:49 -04:00
Russell Belfer
45c53eb6cb Use unsigned type for APIs with opt flag mask 2014-05-08 10:46:04 -07:00
Russell Belfer
1e4976cb01 Be more careful with user-supplied buffers
This adds in missing calls to `git_buf_sanitize` and fixes a
number of places where `git_buf` APIs could inadvertently write
NUL terminator bytes into invalid buffers.  This also changes the
behavior of `git_buf_sanitize` to NUL terminate a buffer if it can
and of `git_buf_shorten` to do nothing if it can.

Adds tests of filtering code with zeroed (i.e. unsanitized) buffer
which was previously triggering a segfault.
2014-05-08 10:17:14 -07:00
Carlos Martín Nieto
ac99d86ba5 repository: introduce a convenience config snapshot method
Accessing the repository's config and immediately taking a snapshot of
it is a common operation, so let's provide a convenience function for
it.
2014-05-07 11:34:32 +02:00
Russell Belfer
ed476c236b Merge pull request #2329 from anuraggup/fix_git_shutdown
Fix the issues in git_shutdown
2014-05-06 16:11:03 -07:00
Russell Belfer
5269008cf6 Add filter options and ALLOW_UNSAFE
Diff and status do not want core.safecrlf to actually raise an
error regardless of the setting, so this extends the filter API
with an additional options flags parameter and adds a flag so that
filters can be applied with GIT_FILTER_OPT_ALLOW_UNSAFE, indicating
that unsafe filter application should be downgraded from a failure
to a warning.
2014-05-06 16:01:49 -07:00
Russell Belfer
1051100025 Merge pull request #2324 from libgit2/cmn/file-in-objects-dir
odb: ignore files in the objects dir
2014-05-06 14:03:58 -07:00
Anurag Gupta
0bf5430dc7 Fix the issues in git_shutdown
1) Call to git_shutdown results in setting git__n_shutdown_callbacks
to -1. Next call to git__on_shutdown results in ABW (Array Bound Write)
for array git__shutdown_callbacks. In the current Implementation,
git_atomic_dec is called git__n_shutdown_callbacks + 1 times. I have
modified it to a for loop so that it is more readable. It would not
set git__n_shutdown_callbacks to a negative number and reset the
elements of git__shutdown_callbacks to NULL.

2) In function git_sysdir_get, shutdown function is registered only if
git_sysdir__dirs_shutdown_set is set to 0. However, after this variable
is set to 1, it is never reset to 0. If git_sysdir_global_init is
called again from synchronized_threads_init it does not register
shutdown function for this subsystem.
2014-05-06 13:41:07 -07:00
Russell Belfer
f554611a27 Improve checks for ignore containment
The diff code was using an "ignored_prefix" directory to track if
a parent directory was ignored that contained untracked files
alongside tracked files. Unfortunately, when negative ignore rules
were used for directories inside ignored parents, the wrong rules
were applied to untracked files inside the negatively ignored
child directories.

This commit moves the logic for ignore containment into the workdir
iterator (which is a better place for it), so the ignored-ness of
a directory is contained in the frame stack during traversal.  This
allows a child directory to override with a negative ignore and yet
still restore the ignored state of the parent when we traverse out
of the child.

Along with this, there are some problems with "directory only"
ignore rules on container directories.  Given "a/*" and "!a/b/c/"
(where the second rule is a directory rule but the first rule is
just a generic prefix rule), then the directory only constraint
was having "a/b/c/d/file" match the first rule and not the second.
This was fixed by having ignore directory-only rules test a rule
against the prefix of a file with LEADINGDIR enabled.

Lastly, spot checks for ignores using `git_ignore_path_is_ignored`
were tested from the top directory down to the bottom to deal with
the containment problem, but this is wrong. We have to test bottom
to top so that negative subdirectory rules will be checked before
parent ignore rules.

This does change the behavior of some existing tests, but it seems
only to bring us more in line with core Git, so I think those
changes are acceptable.
2014-05-06 12:41:26 -07:00
Carlos Martín Nieto
6e9afb97d1 object: fix a brace
The brace in the check for peel's return was surrounding the wrong
thing, which made 'error' be set to 1 when there was an error instead of
the error code.
2014-05-06 21:29:55 +02:00
Anurag Gupta
001befcdd5 Fix the issues in git__on_shutdown 2014-05-06 12:16:24 -07:00
Carlos Martín Nieto
ee311907ee odb: ignore files in the objects dir
We assume that everything under GIT_DIR/objects/ is a directory. This is
not necessarily the case if some process left a stray file in there.

Check beforehand if we do have a directory and ignore the entry
otherwise.
2014-05-05 16:34:18 +02:00
Russell Belfer
d2c16e9ac4 Doc fixes 2014-05-02 15:15:43 -07:00
Vicent Marti
272b462db7 Merge pull request #2308 from libgit2/rb/diff-update-index-stat-cache
Reduce excessive OID calculation for diff and stat
2014-05-02 09:50:15 -07:00