Commit Graph

10132 Commits

Author SHA1 Message Date
Edward Thomson
89d403cce2 win32: enable p_utimes for readonly files
Instead of failing to set the timestamp of a read-only file (like any
object file), set it writable temporarily to update the timestamp.
2017-04-05 11:04:29 +01:00
Edward Thomson
7ece906598 win32: make posix emulation retries configurable
POSIX emulation retries should be configurable so that tests can disable
them.  In particular, maniacally threading tests may end up trying to
open locked files and need retries, which will slow continuous
integration tests significantly.
2017-04-03 23:14:24 +01:00
Edward Thomson
1069ad3c54 win32: do not inherit file descriptors 2017-04-03 23:13:38 +01:00
Sven Strickroth
d5e6ca1e4a Allow to configure default file share mode for opening files
This can prevent FILE_SHARED_VIOLATIONS when used in tools such as TortoiseGit TGitCache and FILE_SHARE_DELETE, because files can be opened w/o being locked any more.

Signed-off-by: Sven Strickroth <email@cs-ware.de>
2017-04-03 23:13:00 +01:00
Sven Strickroth
92d5a6377a win32: deduplicate code: use p_open in p_creat
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2017-04-02 19:42:41 +01:00
Sven Strickroth
ef5cfcdb4f win32: use CreateFile in p_open
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2017-04-02 19:41:26 +01:00
Edward Thomson
fbc6910f6b win32: teach p_open about do_with_retries 2017-04-02 19:38:20 +01:00
Edward Thomson
a0f67e4a26 win32: teach p_unlink about do_with_retries 2017-04-02 19:38:19 +01:00
Edward Thomson
8a4e151301 win32: make p_rename use do_with_retries 2017-04-02 19:38:19 +01:00
Edward Thomson
cc8d9a29e7 win32: introduce do_with_retries macro
Provide a macro that will allow us to run a function with posix-like
return values multiple times in a retry loop, with an optional cleanup
function called between invocations.
2017-04-01 10:47:30 +01:00
Edward Thomson
dcaa90991f win32: map windows error codes to errno
Introduce mapping from windows error codes to errno values.  This
allows us to replace our calls to the Windows posix emulation functions
with calls to the Win32 APIs for more fine-grained control over the
emulation.

These mappings match the Windows CRT's mappings for its posix emulation
as they were described to me.
2017-04-01 10:47:29 +01:00
Edward Thomson
fcb322f5a0 Merge remote-tracking branch 'origin/pr/3790' into win32_posix 2017-03-31 23:39:33 +01:00
Edward Thomson
caf7a7a6b1 Merge pull request #4182 from pks-t/pks/treebuilder
git_treebuilder_write_with_buffer refactorings
2017-03-28 15:16:34 +01:00
Patrick Steinhardt
06abbb7f07 treebuilder: exit early if running OOM in write_with_buffer
While writing the tree inside of a buffer, we check whether the buffer
runs out of memory after each tree entry. While we set the error code as
soon as we detect the OOM situation, we happily proceed iterating over
the entries. This is not useful at all, as we will try to write into the
buffer repeatedly, which cannot work.

Fix this by exiting as soon as we are OOM.
2017-03-28 08:39:29 +02:00
Patrick Steinhardt
8d1e71f5a2 treebuilder: remove shadowing variable in write_with_buffer
The `git_tree_entry *entry` variable is defined twice inside of this
function. While this is not a problem currently, remove the shadowing
variable to avoid future confusion.
2017-03-28 08:39:29 +02:00
Patrick Steinhardt
4f9327faf9 treebuilder: fix memory leaks in write_with_buffer
While we detect errors in `git_treebuilder_write_with_buffer`, we just
exit directly instead of freeing allocated memory. Fix this by
remembering error codes and skipping forward to the function's cleanup
code.
2017-03-28 08:39:29 +02:00
Patrick Steinhardt
a25df009ef Merge pull request #4180 from pks-t/pks/pass-blame-fix
Fix memory leaks
2017-03-28 08:38:24 +02:00
Patrick Steinhardt
fbdf2a79d5 worktree: unconditionally free the worktree's name 2017-03-24 09:26:31 +01:00
Patrick Steinhardt
4004d68f99 blame_git: remove spuriuous goto
The recent addition of an error code to `pass_whole_blame` in ff8d2eb15
(blame_git: check return value of object lookup, 2017-03-20) introduced
a spurious goto. Remove it.
2017-03-24 08:41:10 +01:00
Patrick Steinhardt
1d39a60319 Merge pull request #4175 from libgit2/ethomson/dont_trunc_and_excl
git_futils: don't O_EXCL and O_TRUNC
2017-03-24 08:26:33 +01:00
Carlos Martín Nieto
fa86a095cb Merge pull request #4178 from libgit2/ethomson/enfasten_sha1
sha1dc: perf improvements from upstream
2017-03-23 20:45:28 +01:00
Edward Thomson
d672963535 sha1dc: SHA1DCUpdate now takes a size_t 2017-03-23 17:25:11 +00:00
Edward Thomson
6987368565 Merge branch 'pr/3957' 2017-03-23 09:49:09 +00:00
Edward Thomson
b53d834fca merge: indentation fixup 2017-03-23 09:46:22 +00:00
Edward Thomson
6ad091dceb Merge pull request #4176 from libgit2/ethomson/3872
inet_pton: don't assume addr families don't exist
2017-03-23 09:33:09 +00:00
Edward Thomson
c9efa995e4 sha1dc: perf improvements from upstream
Update SHA-1 collision detection code (cr-marcstevens/sha1collisiondetection)
to master to include performance improvements.
2017-03-23 09:16:24 +00:00
Edward Thomson
f623cf894a Merge pull request #4163 from pks-t/pks/submodules-with-worktrees
Worktree fixes
2017-03-22 20:32:55 +00:00
Edward Thomson
6fd6c67824 Merge pull request #4030 from libgit2/ethomson/fsync
fsync all the things
2017-03-22 20:29:22 +00:00
Edward Thomson
7e53e8ce45 Merge pull request #4167 from pks-t/pks/ci-fixes
Coverity fixes
2017-03-22 20:26:52 +00:00
Edward Thomson
69d0b460f0 Merge pull request #4172 from rcjsuen/patch-1
Fix the documentation for git_cred_acquire_cb
2017-03-22 20:22:45 +00:00
Edward Thomson
983979fa0d inet_pton: don't assume addr families don't exist
Address family 5 might exist on some crazy system like Haiku.
Use `INT_MAX-1` as an unsupported address family.
2017-03-22 19:52:38 +00:00
Edward Thomson
4a26915d34 git_futils: don't O_EXCL and O_TRUNC
`O_EXCL` and `O_TRUNC` are mutually exclusive flags to open(2); you can't
truncate a file if you're asserting that it can't exist in the first place.
Drop `O_TRUNC`.
2017-03-22 19:48:50 +00:00
Remy Suen
84b4e5733d Use proper documentation tags
git_cred_acquire_cb isn't using the standard @param and @return tags.
This is causing the generated documentation to not be formatted
properly.
2017-03-22 06:08:24 +09:00
Patrick Steinhardt
e7330016af diff_parse: check return value of git_diff_init_options 2017-03-21 15:48:16 +01:00
Patrick Steinhardt
723bdf4864 patch_parse: check if advancing over header newline succeeds
While parsing patch header lines, we iterate over each line and check if
the line has trailing garbage. What we do not check though is that the
line is actually a line ending with a trailing newline.

Fix this by checking the return code of `parse_advance_expected_str`.
2017-03-21 15:48:16 +01:00
Patrick Steinhardt
8d452448bb odb_pack: initialize git_rawobj structure
The `pack_entry_find_prefix` function receives a `git_rawobj` structure
as argument. While the function first initializes the structure to a
sensible state, Coverity is unable to correctly detect this, resulting
in a warning.

Fix this warning by initializing the object to all-zeroes before passing
it to the function.
2017-03-21 15:48:15 +01:00
Patrick Steinhardt
2cf48e1326 config_file: check if section header buffer runs out of memory
While parsing section headers, we use a buffer to store the actual
section name. We do not check though if the buffer runs out of memory at
any stage. Do so.
2017-03-21 15:48:15 +01:00
Patrick Steinhardt
ff8d2eb15f blame_git: check return value of object lookup
The function `pass_whole_blame` performs an object lookup but does not
check if the lookup actually succeeds. Convert the function to return an
error code and check for it in the calling function.
2017-03-21 15:48:15 +01:00
Edward Thomson
33ea4aae37 Merge pull request #4139 from richardipsum/readme-running-tests
README: Mention how to run tests
2017-03-21 13:41:24 +00:00
Patrick Steinhardt
c62179731a Merge pull request #4171 from rcjsuen/patch-1
Fix typo in remote.h API
2017-03-20 14:32:57 +01:00
Remy Suen
12b7394cdd Fix typo in remote.h API 2017-03-20 22:30:37 +09:00
Patrick Steinhardt
dd0b1e8cb6 openssl_stream: fix releasing OpenSSL locks
The OpenSSL library may require multiple locks to work correctly, where
it is the caller's responsibility to initialize and release the locks.
While we correctly initialized up to `n` locks, as determined by
`CRYPTO_num_locks`, we were repeatedly freeing the same mutex in our
shutdown procedure.

Fix the issue by freeing locks at the correct index.
2017-03-20 12:36:14 +01:00
Edward Thomson
1d50f95546 Merge pull request #4166 from pks-t/pks/map-free-fix
Remove `map_free` macros
2017-03-20 11:29:27 +00:00
Patrick Steinhardt
31059923bd Merge pull request #4169 from csware/absolute-symlink 2017-03-20 12:16:18 +01:00
Patrick Steinhardt
c10ce7c21a tests: filebuf: test writing to symlink with absolute paths 2017-03-20 12:14:07 +01:00
Sven Strickroth2
86a8cd9f6a filebuf: fix resolving absolute symlinks
The symlink destination is always concatenated to the original path. Fix
this by using `git_buf_sets` instead of `git_buf_puts`.
2017-03-20 12:14:05 +01:00
Patrick Steinhardt
e30a6ee378 Merge pull request #4160 from pks-t/pks/diff-fixes
Diff fixes
2017-03-20 11:06:23 +01:00
Patrick Steinhardt
44b3b9feca Merge pull request #4162 from pks-t/pks/merge-source-fixes
merge_driver: fix const-correctness for source getters
2017-03-20 11:05:03 +01:00
Patrick Steinhardt
94af9155cf map: remove *map_free macros
The `map_free` functions were not implemented as functions but instead
as macros which also set the map to NULL. While this is most certainly
sensible in most cases, we should prefer the more obvious behavior,
namingly leaving the map pointer intact.

Furthermore, this macro has been refactored incorrectly during the
map-refactorings: the two statements are not actually grouped together
by a `do { ... } while (0)` block, as it is required for macros to
match the behavior of functions more closely. This has led to at least
one subtle nesting error in `pack-objects.c`. The following code block

```
    if (pb->object_ix)
        git_oidmap_free(pb->object_ix);
```

would be expanded to

```
    if (pb->object_ix)
        git_oidmap__free(pb->object_ix); pb->object_ix = NULL;
```

which is not what one woudl expect. While it is not a bug here as it
would simply become a no-op, the wrong implementation could lead to bugs
in other occasions.

Fix this by simply removing the macro altogether and replacing it with
real function calls. This leaves the burden of setting the pointer to
NULL afterwards to the caller, but this is actually expected and behaves
like other `free` functions.
2017-03-20 09:01:18 +01:00
Patrick Steinhardt
77c8ee74ff checkout: fix double-free of checkout_data's mkdir_map
We currently call `git_strmap_free` on `checkout_data.mkdir_map` in the
`checkout_data_clear` function. The only thing protecting us from a
double-free is that the `git_strmap_free` function is in fact not a
function, but a macro that also sets the map to NULL.

Remove the second call to `git_strmap_free` and explicitly set the map
member to NULL.
2017-03-20 08:59:30 +01:00