Commit Graph

9426 Commits

Author SHA1 Message Date
Edward Thomson
62e237e031 Merge pull request #3693 from libgit2/cmn/extract-oneline-sig
commit: fix extraction of single-line signatures
2016-03-17 06:43:54 -07:00
Carlos Martín Nieto
bf804d407e commit: fix extraction of single-line signatures
The function to extract signatures suffers from a similar bug to the
header field finding one by having an unecessary line feed check as a
break condition of its loop.

Fix that and add a test for this single-line signature situation.
2016-03-17 10:48:06 +01:00
Edward Thomson
de143efa88 Merge pull request #3690 from libgit2/cmn/pool-limit
win32: choose the page size as our value for the page size
2016-03-16 14:12:14 -07:00
Carlos Martín Nieto
87c181970d Split the page size from the mmap alignment
While often similar, these are not the same on Windows. We want to use the page
size on Windows for the pools, but for mmap we need to use the allocation
granularity as the alignment.

On the other platforms these values remain the same.
2016-03-16 21:36:25 +01:00
Marc Strapetz
059f33bf75 Option "LIBGIT2_PREFIX" to set the CMAKE's TARGET_PROPERTIES PREFIX
This is especially useful in combination with MinGW to yield the
Windows-compliant DLL name "git2.dll" instead of "libgit2.dll"
2016-03-15 18:32:37 +01:00
Marc Strapetz
08f030ced7 CMake: do not overwrite but only append to CMAKE_C_FLAGS_DEBUG
This is useful to force "smart" IDEs (like CLIon) to use debug
flag -g even it may have decided that "-D_DEBUG" (which is
already present) is sufficient.
2016-03-15 18:23:54 +01:00
Carlos Martín Nieto
02d61a3b66 commit: add function to attach a signature to a commit
In combination with the function which creates a commit into a buffer,
this allows us to more easily create signed commits.
2016-03-15 12:55:03 +01:00
Carlos Martín Nieto
77394a27af Merge pull request #3677 from pks-t/pks/coverity-fixes-round7
Coverity fixes round 7
2016-03-14 19:15:20 +01:00
Carlos Martín Nieto
4848dd326a Merge pull request #3647 from pks-t/pks/coverity-fixes-round6
Coverity fixes round 6
2016-03-14 17:45:15 +01:00
Edward Thomson
fa31ee6835 Merge pull request #3671 from libgit2/cmn/remove-mingw32
Remove CI support for mingw32
2016-03-14 15:00:59 +00:00
Carlos Martín Nieto
ff5a39678b Merge pull request #3683 from dbussink/dbussink/better-openssl-ciphers
Setup better defaults for OpenSSL ciphers
2016-03-14 15:29:30 +01:00
Dirkjan Bussink
c577efbbb5 Use general cl_git_fail because the error is generic 2016-03-14 12:41:41 +00:00
Dirkjan Bussink
8f4cbc76bd Start error string with lower case character 2016-03-14 12:41:12 +00:00
Dirkjan Bussink
fa72d6daf8 Setup better defaults for OpenSSL ciphers
This ensures that when using OpenSSL a safe default set of ciphers
is selected. This is done so that the client communicates securely
and we don't accidentally enable unsafe ciphers like RC4, or even
worse some old export ciphers.

Implements the first part of https://github.com/libgit2/libgit2/issues/3682
2016-03-14 12:07:13 +00:00
Carlos Martín Nieto
b1093e62d5 Remove CI support for mingw32
The tests have never run successfully and we do have successful builds
of mingw-w64, so remove these CI builds which do not add value.
2016-03-14 11:05:58 +01:00
Carlos Martín Nieto
1ddada422c Merge pull request #3636 from nerdishbynature/fix-non-modular-header-in-module
Don't include inttypes if compiling for Mac/iOS
2016-03-11 16:31:32 +01:00
Patrick Steinhardt
13c371dc10 config_cache: check return value of git_config__lookup_entry
Callers of `git_config__cvar` already handle the case where the
function returns an error due to a failed configuration variable
lookup, but we are actually swallowing errors when calling
`git_config__lookup_entry` inside of the function.

Fix this by returning early when `git_config__lookup_entry`
returns an error. As we call `git_config__lookup_entry` with
`no_errors == false` which leads us to call `get_entry` with
`GET_NO_MISSING` we will not return early when the lookup fails
due to a missing entry. Like this we are still able to set the
default value of the cvar and exit successfully.
2016-03-11 14:20:15 +01:00
Patrick Steinhardt
6ff8a7c4be filebuf: handle write error in lock_file
When writing to a file with locking not check if writing the
locked file actually succeeds. Fix the issue by returning error
code and message when writing fails.
2016-03-11 14:20:15 +01:00
Patrick Steinhardt
836447e586 config_file: handle error when trying to lock strmap
Accessing the current values map is handled through the
`refcounder_strmap_take` function, which first acquires a mutex
before accessing its values. While this assures everybody is
trying to access the values with the mutex only we do not check
if the locking actually succeeds.

Fix the issue by checking if acquiring the lock succeeds and
returning `NULL` if we encounter an error. Adjust callers.
2016-03-11 14:20:15 +01:00
Patrick Steinhardt
e850e98ddb blame: handle error when resoling HEAD in normalize_options
When normalizing options we try to look up HEAD's OID. While this
action may fail in malformed repositories we never check the
return value of the function.

Fix the issue by converting `normalize_options` to actually
return an error and handle the error in `git_blame_file`.
2016-03-11 14:20:15 +01:00
Patrick Steinhardt
8a4a343a2b blame_git: handle error returned by git_commit_parent 2016-03-11 14:20:15 +01:00
Patrick Steinhardt
b27ccad274 refdb_fs: fail if refcache returns NULL pointer
We usually check entries returned by `git_sortedcache_entry` for
NULL pointers. As we have a write lock in `packed_write`, though,
it really should not happen that the function returns NULL.

Assert that ref is not NULL to silence a Coverity warning.
2016-03-11 14:20:15 +01:00
Patrick Steinhardt
2615d0d694 coverity: report errors when uploading tarball
Curl by default does not report errors by setting the error code.
As the upload can fail through several conditions (e.g. the rate
limit, leading to unauthorized access) we should indicate this
information in Travis CI.

To improve upon the behavior, use `--write-out=%{http_code}` to
write out the HTTP code in addition to the received body and
return an error if the code does not equal 201.
2016-03-11 13:31:12 +01:00
Patrick Steinhardt
1a8c11f443 diff_tform: fix potential NULL pointer access
When the user passes in a diff which has no repository associated
we may call `git_config__get_int_force` with a NULL-pointer
configuration. Even though `git_config__get_int_force` is
designed to swallow errors, it is not intended to be called with
a NULL pointer configuration.

Fix the issue by only calling `git_config__get_int_force` only
when configuration could be retrieved from the repository.
2016-03-11 13:30:33 +01:00
Patrick Steinhardt
486302d6af submodule: avoid passing NULL pointers to strncmp
In C89 it is undefined behavior to pass `NULL` pointers to
`strncmp` and later on in C99 it has been explicitly stated that
functions with an argument declared as `size_t nmemb` specifying
the array length shall always have valid parameters, no matter if
`nmemb` is 0 or not (see ISO 9899 §7.21.1.2).

The function `str_equal_no_trailing_slash` always passes its
parameters to `strncmp` if their lengths match. This means if one
parameter is `NULL` and the other one either `NULL` or a string
with length 0 we will pass the pointers to `strncmp` and cause
undefined behavior.

Fix this by explicitly handling the case when both lengths are 0.
2016-03-11 12:14:02 +01:00
Patrick Steinhardt
3fe5768b06 pack-objects: fix memory leak on overflow 2016-03-11 12:14:02 +01:00
Patrick Steinhardt
80a834a5af index: assert required OID are non-NULL 2016-03-11 12:14:01 +01:00
Patrick Steinhardt
61d7328dc3 object: avoid call of memset with ouf of bounds pointer
When computing a short OID we do this by first copying the
leading parts into the new OID structure and then setting the
trailing part to zero. In the case of the desired length being
`GIT_OID_HEXSZ - 1` we will call `memset` with an out of bounds
pointer and a length of 0. While this seems to cause no problems
for common platforms the C89 standard does not explicitly state
that calling `memset` with an out of bounds pointer and
length of 0 is valid.

Fix the potential issue by using the newly introduced
`git_oid__cpy_prefix` function.
2016-03-11 12:14:01 +01:00
Patrick Steinhardt
35b7bca28b tests: transport: fix memory leaks with registering transports 2016-03-11 11:06:42 +01:00
Patrick Steinhardt
e756877dbf tests: nsec: correctly free nsec_path
git_buf_clear does not free allocated memory associated with a
git_buf. Use `git_buf_free` instead to correctly free its memory
and plug the memory leak.
2016-03-11 09:07:42 +01:00
Piet Brauer
0ac4a5ded4 Check for __CLANG_INTTYPES_H
This fixes an issue in Xcode 7.3 in objective-git where we get the error
"Include of non-modular header file in module". Not importing this
header again fixes the issue.
2016-03-11 10:33:37 +08:00
Patrick Steinhardt
e126bc95cd config_file: handle missing quotation marks in section header
When parsing a section header we expect something along the
format of '[section "subsection"]'. When a section is
mal-formated and is entirely missing its quotation marks we catch
this case by observing that `strchr(line, '"') - strrchr(line,
'"') = NULL - NULL = 0` and error out. Unfortunately, the error
message is misleading though, as we state that we are missing the
closing quotation mark while we in fact miss both quotation
marks.

Improve the error message by explicitly checking if the first
quotation mark could be found and, if not, stating that quotation
marks are completely missing.
2016-03-10 10:28:33 +01:00
Patrick Steinhardt
345758ad45 describe: handle error code returned by git_pqueue_insert 2016-03-10 10:28:32 +01:00
Carlos Martín Nieto
2ba9a0ddac Merge pull request #3623 from ethomson/rebase_with_commit
rebase: additional setup tests of exotic behavior
2016-03-09 23:45:33 +01:00
Carlos Martín Nieto
ac6f62dece Merge pull request #3672 from libgit2/cmn/do-fail-appveyor
appveyor: stop if the first test fails
2016-03-09 21:37:39 +01:00
Carlos Martín Nieto
113e16347d appveyor: stop if the first test fails 2016-03-09 19:20:38 +01:00
Edward Thomson
997c67da00 Merge pull request #3670 from libgit2/vmg/expand-fixes
Fixes for `gid_odb_expand_ids`
2016-03-09 18:12:34 +00:00
Vicent Marti
1bbcb2b279 odb: Try to lookup headers in all backends before passthrough 2016-03-09 18:17:37 +01:00
Vicent Marti
e78d2ac939 odb: Refactor git_odb_expand_ids 2016-03-09 16:43:43 +01:00
Vicent Marti
4416aa7749 odb: Implement new helper to read types without refreshing 2016-03-09 16:43:17 +01:00
Edward Thomson
084f2c4b41 Merge pull request #3668 from libgit2/cmn/mwindow-try-harder
mwindow: free unused windows if we fail to mmap
2016-03-09 14:51:13 +00:00
Carlos Martín Nieto
d50fd57174 mwindow: free unused windows if we fail to mmap
The first time may be due to memory fragmentation or just bad luck on a
32-bit system. When we hit the mmap error for the first time, free up
the unused windows and try again.
2016-03-09 11:16:16 +01:00
Vicent Marti
9a78665005 odb: Handle corner cases in git_odb_expand_ids
The old implementation had two issues:

1. OIDs that were too short as to be ambiguous were not being handled
properly.

2. If the last OID to expand in the array was missing from the ODB, we
would leak a `GIT_ENOTFOUND` error code from the function.
2016-03-09 11:00:27 +01:00
Vicent Marti
c68044a879 Merge pull request #3656 from ethomson/exists_prefixes
Introduce `git_odb_expand_ids`
2016-03-08 21:17:38 +01:00
Edward Thomson
62484f52d1 git_odb_expand_ids: accept git_odb_expand_id array
Take (and write to) an array of a struct, `git_odb_expand_id`.
2016-03-08 14:57:20 -05:00
Edward Thomson
4b1f0f79ac git_odb_expand_ids: rename func, return the type 2016-03-08 11:44:21 -05:00
Chris Hescock
9028a8a22a Only buffer if necessary. 2016-03-08 10:43:37 -05:00
Edward Thomson
b7809b8469 Merge pull request #3555 from cbargren/ssh-git-protocols
Support for ssh+git and git+ssh protocols
2016-03-08 13:38:55 +00:00
Edward Thomson
534ca8882d Merge pull request #3652 from libgit2/cmn/commit-to-memory
commit: split creating the commit and writing it out
2016-03-08 13:35:11 +00:00
Carlos Martín Nieto
47cb42da5a commit: split creating the commit and writing it out
Sometimes you want to create a commit but not write it out to the
objectdb immediately. For these cases, provide a new function to
retrieve the buffer instead of having to go through the db.
2016-03-08 13:11:49 +01:00