Commit Graph

8356 Commits

Author SHA1 Message Date
Carlos Martín Nieto
dfda2f68ea submodule: remove the per-repo cache
Having this cache and giving them out goes against our multithreading
guarantees and it makes it impossible to use submodules in a
multi-threaded environment, as any thread can ask for a refresh which
may reallocate some string in the submodule struct which we've accessed
in a different one via a getter.

This makes the submodules behave more like remotes, where each object is
created upon request and not shared except explicitly by the user. This
means that some tests won't pass yet, as they assume they can affect the
submodule objects in the cache and that will affect later operations.
2015-06-22 17:02:54 +02:00
Carlos Martín Nieto
0c94deb90f Merge pull request #3239 from git-up/stash_index
Write modified index in git_stash_apply()
2015-06-22 16:58:14 +02:00
Pierre-Olivier Latour
e35b947bec Write modified index in git_stash_apply()
Same as with git_stash_save(), there's no reason not to write the index
to disk since it has been modified.
2015-06-21 01:06:20 -07:00
Carlos Martín Nieto
e96a97f18e Merge pull request #3233 from ethomson/status_typechange
Don't propagate workdir's mode to the index during diff's update index
2015-06-20 23:17:42 +02:00
Edward Thomson
96dd171e34 diff: preserve original mode in the index
When updating the index during a diff, preserve the original mode,
which prevents us from dropping the mode to what we have interpreted
as on our system (eg, what the working directory claims it to be,
which may be a lie on some systems.)
2015-06-20 15:37:32 -04:00
Edward Thomson
fc6568021c status: test that symlinks don't lose their mode
Test to ensure that when status updates an index, it does not alter
the original mode for file types that are not supported (eg, symlinks
on Windows).
2015-06-20 15:37:32 -04:00
Edward Thomson
9018529b4e Merge pull request #3238 from git-up/double_free
Fixed index being double-freed in stash tests
2015-06-20 14:34:34 -04:00
Edward Thomson
883cb642cb Merge pull request #3236 from libgit2/cmn/index-checksum
Use the checksum to check whether an index has been modified
2015-06-20 14:05:02 -04:00
Pierre-Olivier Latour
07ea3a7f57 Fixed index being double-freed in stash tests 2015-06-20 10:57:03 -07:00
Carlos Martín Nieto
624c949f01 index: make relative comparison use the checksum as well
This is used by the submodule in order to figure out if the index has
changed since it last read it. Using a timestamp is racy, so let's make
it use the checksum, just like we now do for reloading the index itself.
2015-06-20 16:17:28 +02:00
Carlos Martín Nieto
3e5b553ae1 Merge pull request #3232 from Therzok/patch-2
Quote LIBSSH2_LIBRARIES call
2015-06-20 12:14:49 +02:00
Carlos Martín Nieto
863dd89abf tests: tick over five seconds instead of one
When ticking over one second, it can happen that the actual time ticks
over the same second between the time that we undermine our own race
protections and the time in which we perform the index update. Such
timing would make the time in the entries match the index' timestamp and
we have not gained anything.

Ticking over five seconds makes it so that if real-time rolls over that
second, our index is still ahead. This is still suboptimal as we're
dealing with timing, but five seconds should be long enough for any
reasonable test runner to finish the tests.
2015-06-20 10:46:10 +02:00
Carlos Martín Nieto
5e947c91d4 index: use the checksum to check whether it's been modified
We currently use a timetamp to check whether an index file has been
modified since we last read it, but this is racy. If two updates happen
in the same second and we read after the first one, we won't detect the
second one.

Instead read the SHA-1 checksum of the file, which are its last 20 bytes which
gives us a sure-fire way to detect whether the file has changed since we
last read it.

As we're now keeping track of it, expose an accessor to this data.
2015-06-19 22:05:08 +02:00
Carlos Martín Nieto
46c84c7260 index: user a better assertion when comparing sizes
This will tell us which numbers we were trying to compare, rather than
just telling us that they're different.
2015-06-19 21:56:42 +02:00
Marius Ungureanu
e488bef42c Quote LIBSSH2_LIBRARIES call
Credits to @directhex

It is possible for PKG_CHECK_MODULES(LIBSSH2 libssh2) to LIBSSH2_LIBRARIES to a string with more than one library in it - e.g. if your libssh2 was built against libgcrypt, it will be "ssh2;gcrypt"

Quoting the string is needed, or CHECK_LIBRARY_EXISTS will fail.
2015-06-19 12:54:51 +03:00
Carlos Martín Nieto
6e0470e0f5 Merge pull request #3229 from git-up/build_warnings
Fixed Xcode 6.1 build warnings
2015-06-17 21:36:27 +02:00
Pierre-Olivier Latour
85a5e8ebe1 Fixed Xcode 6.1 build warnings 2015-06-17 09:00:23 -07:00
Carlos Martín Nieto
83a04a69da Merge pull request #3227 from jeffhostetler/memory_leak__tests_network_refspecs
Fix memory leak in tests/network/refspecs.c
2015-06-17 16:08:20 +02:00
Jeff Hostetler
534d136da3 Fix memory leak in tests/network/refspecs.c 2015-06-17 08:52:28 -04:00
Carlos Martín Nieto
a56db99234 Merge pull request #3219 from libgit2/cmn/racy-diff
Zero out racily-clean entries' file_size
2015-06-17 08:15:49 +02:00
Edward Thomson
892abf9315 checkout: allow workdir to contain checkout target
When checking out some file 'foo' that has been modified in the
working directory, allow the checkout to proceed (do not conflict)
if 'foo' is identical to the target of the checkout.
2015-06-16 17:23:12 -04:00
Edward Thomson
fef5344c50 merge::workdir::dirty: tick idx to defeat racy-git 2015-06-16 16:39:13 -04:00
Edward Thomson
121c3171e5 Introduce p_utimes and p_futimes
Provide functionality to set the time on a filesystem entry,
using utimes or futimes on POSIX type systems or SetFileTime
on Win32.
2015-06-16 15:32:02 -04:00
Edward Thomson
5f83758fa3 Merge pull request #3209 from libgit2/cmn/double-author
commit: ignore multiple author fields
2015-06-16 10:40:46 -04:00
Edward Thomson
86faea5fce Merge pull request #3225 from libgit2/cmn/url-empty
remote: return EINVALIDSPEC when given an empty URL
2015-06-16 08:45:55 -04:00
Carlos Martín Nieto
47a40d1d44 remote: return EINVALIDSPEC when given an empty URL
This is what we used to return in the settter and there's tests in
bindings which ask for this. There's no particular reason to stop doing
so.
2015-06-16 14:04:23 +02:00
Carlos Martín Nieto
aeb2b991b0 Merge pull request #3221 from git-up/build_warnings
Fixed Xcode 6.1 build warnings
2015-06-16 09:20:36 +02:00
Carlos Martín Nieto
e44abe16bd tests: tick the index when we count OID calculations
These tests want to test that we don't recalculate entries which match
the index already. This is however something we force when truncating
racily-clean entries.

Tick the index forward as we know that we don't perform the
modifications which the racily-clean code is trying to avoid.
2015-06-16 08:51:45 +02:00
Carlos Martín Nieto
c4e6ab5f23 crlf: tick the index forward to work around racy-git behaviour
In order to avoid racy-git, we zero out the file size for entries with
the same timestamp as the index (or during the initial checkout). This
is the case in a couple of crlf tests, as the code is fast enough to do
everything in the same second.

As we know that we do not perform the modification just after writing
out the index, which is what this is designed to work around, tick the
mtime of the index file such that it doesn't agree with the files
anymore, and we do not zero out these entries.
2015-06-16 08:40:45 +02:00
Carlos Martín Nieto
316b820b6f index: zero the size of racily-clean entries
If a file entry has the same timestamp as the index itself, it is
considered racily-clean, as it may have been modified after the index
was written, but during the same second. We take extra steps to check
the contents, but this is just one part of avoiding races.

For files which do have changes but have not been updated in the index,
updating the on-disk index means updating its timestamp, which means we
would no longer recognise these entries as racy and we would trust the
timestamp to tell us whether they have changed.

In order to work around this, git zeroes out the file-size field in
entries with the same timestamp as the index in order to force the next
diff to check the contents. Do so in libgit2 as well.
2015-06-16 08:40:45 +02:00
Carlos Martín Nieto
77596fcfd7 diff: add failing test for racy-git in the index
We update the index and then immediately change the contents of the
file. This makes the diff think there are no changes, as the timestamp
of the file agrees with the cached data. This is however a bug, as the
file has obviously changed contents.

The test is a bit fragile, as it assumes that the index writing and the
following modification of the file happen in the same second, but it's
enough to show the issue.
2015-06-16 08:40:45 +02:00
Edward Thomson
b93dcd4ca4 Merge pull request #3216 from dprofeta/fixTransactionVisibility
Fix visibility of transaction symbol
2015-06-15 17:10:35 -04:00
Pierre-Olivier Latour
0f4d9c0367 Fixed Xcode 6.1 build warnings 2015-06-15 09:55:12 -07:00
Edward Thomson
f621f087b2 Merge pull request #3220 from libgit2/cmn/readdir
path: remove unnecessary readdir_r usage
2015-06-15 09:11:32 -04:00
Carlos Martín Nieto
25bd0aaf20 path: remove unnecessary readdir_r usage
Arguably all uses of readdir_r are unnecessary, but in this case
especially so, as the directory handle only exists within this function,
so we don't race with anybody.
2015-06-15 13:43:48 +02:00
Carlos Martín Nieto
2665fefa0f Merge pull request #3171 from libgit2/cmn/link-fallback
clone: fall back to copying when linking does not work
2015-06-15 10:20:58 +02:00
Logan Collins
b224c38869 Fix in stransport_stream.c for usage of SecCopyErrorMessageString(), which is unavailable to iOS targets. 2015-06-15 10:15:57 +02:00
Carlos Martín Nieto
d4723c89d4 Merge pull request #3177 from ethomson/binary_diff
Binary diffs: store deltas in the diff structure, include binary data in diff callbacks
2015-06-15 08:17:45 +02:00
Carlos Martín Nieto
ae22ef0e5a Merge pull request #3217 from jeffhostetler/leak_checkout_icase
Fix leaks in tests/checkout/icase
2015-06-15 08:09:21 +02:00
Carlos Martín Nieto
f2dec48118 Merge pull request #3215 from jeffhostetler/windows_leak_diriter
Fix memory leak on windows in diriter.
2015-06-12 18:35:18 +02:00
Jeff Hostetler
26d5c0b823 Fix leaks in tests/checkout/icase 2015-06-12 09:28:47 -07:00
Damien PROFETA
5c757327fa Fix visibility of transaction symbol
Transaction.c did not include the visibility definition of its symbol
(that are in git2/transaction.h) and so was by default hidden.
2015-06-12 18:14:32 +02:00
Jeff Hostetler
95639dbb9b Fix memory leak on windows in diriter. 2015-06-12 08:50:48 -07:00
Edward Thomson
0e522f6e6a binary diff: document changes in CHANGELOG 2015-06-12 09:39:37 -04:00
Edward Thomson
3208df37fb patch: include diff options on blob->blob diffs 2015-06-12 09:39:33 -04:00
Edward Thomson
391281ae34 binary diff: test binary blob to blob tests 2015-06-12 09:39:29 -04:00
Edward Thomson
8147b1aff5 diff: introduce binary diff callbacks
Introduce a new binary diff callback to provide the actual binary
delta contents to callers.  Create this data from the diff contents
(instead of directly from the ODB) to support binary diffs including
the workdir, not just things coming out of the ODB.
2015-06-12 09:39:20 -04:00
Edward Thomson
ac7012a81f binary diff: test index->workdir binary diffs 2015-06-12 09:24:59 -04:00
Carlos Martín Nieto
6995b18ad2 Merge pull request #3208 from git-up/secure_transport
Fixed some Secure Transport issues on OS X
2015-06-12 14:52:48 +02:00
Carlos Martín Nieto
4ce58244a2 Merge pull request #3214 from libgit2/cmn/push-tests
travis: fail if we fail the push tests
2015-06-12 14:51:59 +02:00