Commit Graph

8635 Commits

Author SHA1 Message Date
Edward Thomson
84f8f50046 crlf: include additional test resources
Include additional test data for CRLF tests: files with mixed
line endings and binary files.
2015-06-22 11:59:50 -04:00
Edward Thomson
0b6ed4f96c Merge pull request #3240 from libgit2/cmn/commit-header-field
commit: allow retrieving an arbitrary header field
2015-06-22 11:24:20 -04:00
Carlos Martín Nieto
783672fa5b submodule: remove the RESET enum values
These are not useful anymore, as we don't affect the instance's
configuration.
2015-06-22 17:02:56 +02:00
Carlos Martín Nieto
0496330004 submodule: test unsetting config options
In addition to mapping enums to strings in the configuration, we need to
know to delete the configuration option when given the "none" or "no"
option.
2015-06-22 17:02:56 +02:00
Carlos Martín Nieto
c4e3a3dbfa submodule: handle writing out all enum values for settings
We currently do not handle those enum values which require us to set
"true" or unset variables in all cases. Use a common function which does
understand this by looking at our mapping directly.
2015-06-22 17:02:56 +02:00
Carlos Martín Nieto
15c3810313 config: provide a function to reverse-lookup mapped cvars 2015-06-22 17:02:56 +02:00
Carlos Martín Nieto
7d6dacdc17 examples: adjust to submodule status API change 2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
4536574acc submodule: test more accurately for non-existence
The current code will always fail, but only because it's asking for a
string on a live config. Take a snapshot and make sure we fail with
ENOTFOUND instead of any old error.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
adb58f7d64 submodule: fix potential leak in the tests 2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
961861fafa submodule: get rid of _save()
We no longer have any setters which affect an instance, so
`git_submodule_save()` is no longer relevant.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
d6073b30f3 submodule: make _set_url() affect the configuration
With this one, we can get rid of the edit_and_save test.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
486ba4cdd3 submodule: make _set_branch() affect the configuration 2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
4e63642321 submodule: make _set_update_fetch_recurse_submodules() affect the config
Similarly to the other ones. In this test we copy over testing
`RECURSE_YES` which shows an error in our handling of the `YES` variant
which we may have to port to the rest.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
e8a39f8ed1 submodule: make _set_update() affect the configuration
Moving on with the removal of runtime-changing variables, the update
setting for a remote is whatever it was when it was looked up.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
2278637c4a submodule: correct detection of existing submodules
During the cache deletion, the check for whether we consider a submodule
to exist got changed regarding submodules which are in the worktree but
not configured.

Instead of checking for the url field to be populated, check the
location where we've found it.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
d769a3fdda submodule: bring back finding by path
During the removal of the cache, we also removed the ability to use
`_lookup()` to search by path rather than name. Bring this logic back.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
c6f489c964 submodule: add an ignore option to status
This lets us specify in the status call which ignore rules we want to
use (optionally falling back to whatever the submodule has in its
configuration).

This removes one of the reasons for having `_set_ignore()` set the value
in-memory. We re-use the `IGNORE_RESET` value for this as it is no
longer relevant but has a similar purpose to `IGNORE_FALLBACK`.

Similarly, we remove `IGNORE_DEFAULT` which does not have use outside of
initializers and move that to fall back to the configuration as well.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
64bbd47a32 submodule: don't let status change an existing instance
As submodules are becomes more like values, we should not let a status
check to update its properties. Instead of taking a submodule, have
status take a repo and submodule name.
2015-06-22 17:02:55 +02:00
Carlos Martín Nieto
5a9fc6c83c submodule: make set_ignore() affect the configuration
Instead of affecting a particular instance, make it change the
configuration.
2015-06-22 17:02:55 +02:00
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
Carlos Martín Nieto
bb4896f22c Add a note about racy-git in CHANGELOG 2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
6e611f7c3c index: add a diff test for smudging a file which becomes empty
Even though the file is empty and thus the size in the entry matches, we
should be able to detect it as a difference.
2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
27133caf3c tests: move racy tests to the index
They fit there much better, even though we often check by diffing, it's
about the behaviour of the index.
2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
5b05f95424 merge: work around write-side racy protection when hacking the index
As we attempt to replicate a situation in which an older checkout has
put a file on disk with different filtering settings from us, set the
timestamp on the entry and file to a second before we're performing the
operation so the entry in the index counts as old.

This way we can test that we're not looking at the on-disk file when the
index has the entry and we detect it as clean.
2015-06-22 16:11:58 +02:00
Carlos Martín Nieto
a3f42fe8e4 commit: allow retrieving an arbitrary header field
This allows the user to look up fields which we don't parse in libgit2,
and allows them to access gpgsig or mergetag fields if they wish to
check the signature.
2015-06-22 15:56:31 +02:00
Carlos Martín Nieto
26432a9c62 tests: set racy times manually 2015-06-22 12:47:30 +02:00
Carlos Martín Nieto
6c5eaead49 tests: plug leaks in the racy test 2015-06-22 12:47:30 +02:00
Carlos Martín Nieto
7497584651 index: check racily clean entries more thoroughly
When an entry has a racy timestamp, we need to check whether the file
itself has changed since we put its entry in the index. Only then do we
smudge the size field to force a check the next time around.
2015-06-22 12:47:30 +02:00
Carlos Martín Nieto
ff47537557 diff: check files with the same or newer timestamps
When a file on the workdir has the same or a newer timestamp than the
index, we need to perform a full check of the contents, as the update of
the file may have happened just after we wrote the index.

The iterator changes are such that we can reach inside the workdir
iterator from the diff, though it may be better to have an accessor
instead of moving these structs into the header.
2015-06-22 12:47:30 +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