Commit Graph

10699 Commits

Author SHA1 Message Date
Patrick Steinhardt
96d0298921 travis: replace use of deprecated homebrew/dupes tap
The formulae provided by the homebrew/dupes tap are deprecated since at
least April 4, 2017, with formulae having been migrated to
homebrew/core.

Replace the deprecated reference to "homebrew/dupes/zlib" with only
"zlib".
2017-06-13 08:13:48 +02:00
Edward Thomson
2ca088bd2b Merge pull request #4265 from pks-t/pks/read-prefix-tests
Read prefix tests
2017-06-12 22:47:54 +01:00
Edward Thomson
99e40a67c7 Merge pull request #4263 from libgit2/ethomson/config_for_inmemory_repo
Allow creation of a configuration object in an in-memory repository
2017-06-12 21:23:44 +01:00
Edward Thomson
d9914fb7c6 Merge pull request #4266 from libgit2/ethomson/travis-explicit-openssl
travis: install openssl explicitly
2017-06-12 21:22:27 +01:00
Edward Thomson
844e85f21d travis: install openssl explicitly 2017-06-12 20:00:21 +01:00
Edward Thomson
fe9a5dd3ca remote: ensure we can create an anon remote on inmemory repo
Given a wholly in-memory repository, ensure that we can create an
anonymous remote and perform actions on it.
2017-06-12 16:51:05 +01:00
Edward Thomson
2d486781df repository: don't fail to create config option in inmemory repo
When in an in-memory repository - without a configuration file - do not
fail to create a configuration object.
2017-06-12 16:51:04 +01:00
Edward Thomson
9d49a43c71 repository_item_path: return ENOTFOUND when appropriate
Disambiguate error values: return `GIT_ENOTFOUND` when the item cannot
exist in the repository (perhaps because the repository is inmemory or
otherwise not backed by a filesystem), return `-1` when there is a hard
failure.
2017-06-12 16:51:04 +01:00
Patrick Steinhardt
f148258a35 tests: odb: add tests with multiple backends
Previous to pulling out and extending the fake backend, it was quite
cumbersome to write tests for very specific scenarios regarding
backends. But as we have made it more generic, it has become much easier
to do so. As such, this commit adds multiple tests for scenarios with
multiple backends for the ODB.

The changes also include a test for a very targeted scenario. When one
backend found a matching object via `read_prefix`, but the last backend
returns `GIT_ENOTFOUND` and when object hash verification is turned off,
we fail to reset the error code to `GIT_OK`. This causes us to segfault
later on, when doing a double-free on the returned object.
2017-06-12 17:24:53 +02:00
Patrick Steinhardt
6e010bb126 tests: odb: allow passing fake objects to the fake backend
Right now, the fake backend is quite restrained in the way how it
works: we pass it an OID which it is to return later as well as an error
code we want it to return. While this is sufficient for existing tests,
we can make the fake backend a little bit more generic in order to allow
us testing for additional scenarios.

To do so, we change the backend to not accept an error code and OID
which it is to return for queries, but instead a simple array of OIDs
with their respective blob contents. On each query, the fake backend
simply iterates through this array and returns the first matching
object.
2017-06-12 17:24:53 +02:00
Patrick Steinhardt
369cb45fc3 tests: do not reuse OID from backend
In order to make the fake backend more useful, we want to enable it
holding multiple object references. To do so, we need to decouple it
from the single fake OID it currently holds, which we simply move up
into the calling tests.
2017-06-12 17:24:53 +02:00
Patrick Steinhardt
2add34d0fb tests: odb: move fake backend into its own file
The fake backend used by the test suite `odb::backend::nonrefreshing` is
useful to have some low-level tests for the ODB layer. As such, we move
the implementation into its own `backend_helpers` module.
2017-06-12 17:24:53 +02:00
Edward Thomson
9927e9587a Merge pull request #4261 from RogerGee/fix_wait_while_ack
smart_protocol: fix parsing of server ACK responses
2017-06-12 16:01:22 +01:00
Patrick Steinhardt
2ade8fb038 Merge pull request #4264 from libgit2/ethomson/read_prefix
odb_read_prefix: reset error in backends loop
2017-06-12 07:33:41 -07:00
Edward Thomson
cb3010c54a odb_read_prefix: reset error in backends loop
When looking for an object by prefix, we query all the backends so that
we can ensure that there is no ambiguity.  We need to reset the `error`
value between backends; otherwise the first backend may find an object
by prefix, but subsequent backends may not.  If we do not reset the
`error` value then it will remain at `GIT_ENOTFOUND` and `read_prefix_1`
will fail, despite having actually found an object.
2017-06-12 12:56:40 +01:00
Edward Thomson
fb3fc837c6 repository_item_path: error messages lowercased 2017-06-12 11:45:09 +01:00
Edward Thomson
bd6928096d Merge pull request #4262 from libgit2/ethomson/bump-v26
Update version number to 0.26
2017-06-11 12:32:00 +01:00
Edward Thomson
2a3cc403bd Update version number to v0.26 2017-06-11 12:23:34 +01:00
Edward Thomson
a1b4cafde5 changelog: add some final 0.26 changes 2017-06-11 12:21:23 +01:00
Edward Thomson
29ef7d3f3b Merge pull request #4254 from pks-t/pks/changelog-v0.26
CHANGELOG: add various changes introduced since v0.25
2017-06-11 10:58:35 +01:00
Edward Thomson
6f960b553b Merge pull request #4088 from chescock/packfile-name-using-complete-hash
Ensure packfiles with different contents have different names
2017-06-11 10:37:46 +01:00
Edward Thomson
d2c4f7645c Merge pull request #4260 from libgit2/ethomson/forced_checkout_2
Update to forced checkout and untracked files
2017-06-11 09:54:04 +01:00
Edward Thomson
4a0df57411 git_futils_rmdir: only allow EBUSY when asked
Only ignore `EBUSY` from `rmdir` when the `GIT_RMDIR_SKIP_NONEMPTY` bit
is set.
2017-06-10 19:18:57 +01:00
Edward Thomson
83989d70ec checkout: cope with untracked files in directory deletion
When deleting a directory during checkout, do not simply delete the
directory, since there may be untracked files.  Instead, go into
the iterator and examine each file.

In the original code (the code with the faulty assumption), we look to
see if there's an index entry beneath the directory that we want to
remove.   Eg, it looks to see if we have a workdir entry foo and an
index entry foo/bar.txt. If this is not the case, then the working
directory must have precious files in that directory. This part is okay.
The part that's not okay is if there is an index entry foo/bar.txt. It
just blows away the whole damned directory.

That's not cool.

Instead, by simply pushing the directory itself onto the stack and
iterating each entry, we will deal with the files one by one - whether
they're in the index (and can be force removed) or not (and are
precious).

The original code was a bad optimization, assuming that we didn't need
to git_iterator_advance_into if there was any index entry in the folder.
That's wrong - we could have optimized this iff all folder entries are
in the index.

Instead, we need to simply dig into the directory and analyze its
entries.
2017-06-10 19:16:48 +01:00
Patrick Steinhardt
0ef405b3c8 checkout: do not delete directories with untracked entries
If the `GIT_CHECKOUT_FORCE` flag is given to any of the `git_checkout`
invocations, we remove files which were previously staged. But while
doing so, we unfortunately also remove unstaged files in a directory
which contains at least one staged file, resulting in potential data
loss.

This commit adds two tests to verify behavior.
2017-06-10 19:16:08 +01:00
Roger Gee
e141f07996 smart_protocol: fix parsing of server ACK responses
Fix ACK parsing in wait_while_ack() internal function. This patch
handles the case where multi_ack_detailed mode sends 'ready' ACKs. The
existing functionality would bail out too early, thus causing the
processing of the ensuing packfile to fail if/when 'ready' ACKs were
sent.
2017-06-10 11:46:09 -05:00
Patrick Steinhardt
a1510880de CHANGELOG: add various changes introduced since v0.25 2017-06-09 08:43:22 +02:00
Edward Thomson
e476d5288c Merge pull request #4259 from pks-t/pks/fsync-option-rename
settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`
2017-06-08 22:54:30 +02:00
Patrick Steinhardt
6c23704df5 settings: rename GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION
Initially, the setting has been solely used to enable the use of
`fsync()` when creating objects. Since then, the use has been extended
to also cover references and index files. As the option is not yet part
of any release, we can still correct this by renaming the option to
something more sensible, indicating not only correlation to objects.

This commit renames the option to `GIT_OPT_ENABLE_FSYNC_GITDIR`. We also
move the variable from the object to repository source code.
2017-06-08 21:40:18 +02:00
Edward Thomson
458cea5c5b Merge pull request #4255 from pks-t/pks/buffer-grow-errors
Buffer growing cleanups
2017-06-08 14:22:24 +02:00
Edward Thomson
90500d81dc Merge pull request #4253 from pks-t/pks/cov-fixes
Coverity fixes
2017-06-08 13:56:22 +02:00
Patrick Steinhardt
90388aa836 refdb_fs: be explicit about using null-OID if we cannot resolve ref 2017-06-08 12:05:35 +02:00
Patrick Steinhardt
78a8f68f06 path: only set dotgit flags when configs were read 2017-06-08 12:05:35 +02:00
Patrick Steinhardt
9be4c3039a worktree: use git__free instead of free 2017-06-08 12:05:35 +02:00
Patrick Steinhardt
0f642f3168 refs: properly report errors from update_wt_heads 2017-06-08 12:05:35 +02:00
Patrick Steinhardt
0c28c72d13 fileops: check return value of git_path_dirname 2017-06-08 12:05:35 +02:00
Patrick Steinhardt
a693b87349 buffer: use git_buf_init with length
The `git_buf_init` function has an optional length parameter, which will
cause the buffer to be initialized and allocated in one step. This can
be used instead of static initialization with `GIT_BUF_INIT` followed by
a `git_buf_grow`. This patch does so for two functions where it is
applicable.
2017-06-08 11:58:23 +02:00
Patrick Steinhardt
4796c916d3 buffer: return errors for git_buf_init and git_buf_attach
Both the `git_buf_init` and `git_buf_attach` functions may call
`git_buf_grow` in case they were given an allocation length as
parameter. As such, it is possible for these functions to fail when we
run out of memory. While it won't probably be used anytime soon, it does
indeed make sense to also record this fact by returning an error code
from both functions. As they belong to the internal API only, this
change does not break our interface.
2017-06-08 11:58:22 +02:00
Patrick Steinhardt
9a8386a2c6 buffer: consistently use ENSURE_SIZE to grow buffers on-demand
The `ENSURE_SIZE` macro can be used to grow a buffer if its currently
allocated size does not suffice a required target size. While most of
the code already uses this macro, the `git_buf_join` and `git_buf_join3`
functions do not yet use it. Due to the macro first checking whether we
have to grow the buffer at all, this has the benefit of saving a
function call when it is not needed. While this is nice to have, it will
probably not matter at all performance-wise -- instead, this only serves
for consistency across the code.
2017-06-08 11:58:22 +02:00
Patrick Steinhardt
e82dd8130f buffer: fix ENSURE_SIZE macro referencing wrong variable
While the `ENSURE_SIZE` macro gets a reference to both the buffer that
is to be resized and a new size, we were not consistently referencing
the passed buffer, but instead a variable `buf`, which is not passed in.
Funnily enough, we never noticed because our buffers seem to always be
named `buf` whenever the macro was being used.

Fix the macro by always using the passed-in buffer. While at it, add
braces around all mentions of passed-in variables as should be done with
macros to avoid subtle errors.

Found-by: Edward Thompson
2017-06-08 11:58:22 +02:00
Patrick Steinhardt
97eb5ef026 buffer: rely on GITERR_OOM set by git_buf_try_grow
The function `git_buf_try_grow` consistently calls `giterr_set_oom`
whenever growing the buffer fails due to insufficient memory being
available. So in fact, we do not have to do this ourselves when a call
to any buffer-growing function has failed due to an OOM situation. But
we still do so in two functions, which this patch cleans up.
2017-06-08 11:58:22 +02:00
Edward Thomson
3a8801aeb7 Merge pull request #4258 from pks-t/pks/sha1dc-update
SHA1DC update
2017-06-08 10:55:47 +02:00
Patrick Steinhardt
db1abffa50 sha1dc: do not use standard includes
The updated SHA1DC library allows us to use custom includes instead of
using standard includes. Due to requirements with cross-platform, we
provide some custom system includes files like for example the
"stdint.h" file on Win32. Because of this, we want to make sure to avoid
breaking cross-platform compatibility when SHA1DC is enabled.

To use the new mechanism, we can simply define
`SHA1DC_NO_STANDARD_INCLUDES`. Furthermore, we can specify custom
include files via two defines, which we now use to include our
"common.h" header.
2017-06-07 15:03:46 +02:00
Patrick Steinhardt
63d86c2703 sha1dc: update to fix errors with endianess and unaligned access
This updates our version of SHA1DC to e139984 (Merge pull request #35
from lidl/master, 2017-05-30).
2017-06-07 14:50:16 +02:00
Edward Thomson
3bc95cfe3e Merge pull request #4236 from pks-t/pks/index-v4-fixes
Fix path computations for compressed index entries
2017-06-07 14:42:12 +02:00
Edward Thomson
6a13cf1e00 Merge pull request #4256 from libgit2/ethomson/unc_tests
(Temporarily) disable UNC tests
2017-06-07 13:56:22 +02:00
Edward Thomson
f218508f4a ctest: temporarily disable UNC path tests
(Temporarily) disable UNC path tests to work around AppVeyor issues.
2017-06-07 10:54:48 +01:00
Patrick Steinhardt
40139fe6e6 Merge pull request #4251 from Keruspe/master
Fix build with libressl
2017-06-07 07:38:06 +02:00
Marc-Antoine Perennou
f28744a5a3 openssl_stream: fix building with libressl
OpenSSL v1.1 has introduced a new way of initializing the library
without having to call various functions of different subsystems. In
libgit2, we have been adapting to that change with 88520151f
(openssl_stream: use new initialization function on OpenSSL version
>=1.1, 2017-04-07), where we added an #ifdef depending on the OpenSSL
version. This change broke building with libressl, though, which has not
changed its API in the same way.

Fix the issue by expanding the #ifdef condition to use the old way of
initializing with libressl.

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2017-06-07 07:36:57 +02:00
Patrick Steinhardt
92d3ea4e39 tests: index::version: improve write test for index v4
The current write test does not trigger some edge-cases in the index
version 4 path compression code. Rewrite the test to start off the an
empty standard repository, creating index entries with interesting paths
itself. This allows for more fine-grained control over checked paths.
Furthermore, we now also verify that entry paths are actually
reconstructed correctly.
2017-06-06 09:38:44 +02:00