Commit Graph

9555 Commits

Author SHA1 Message Date
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
Carlos Martín Nieto
eeff96c474 Merge pull request #3655 from ethomson/nanosecond_defaults
Enable nanosecond resolution by default
2016-03-08 10:43:33 +01:00
Edward Thomson
53fb823bcc index::racy: force racy entry
Instead of hoping that we can get a racy entry by going real fast
and praying real hard, just create a racy entry.
2016-03-08 00:47:55 -05:00
Edward Thomson
eee1799746 Merge pull request #3658 from patrickmckenna/update-pro-git-link
Update link to Pro Git's Git internals chapter
2016-03-08 01:45:29 +00:00
Patrick McKenna
698e0c2777 Update link to Pro Git's Git internals chapter. 2016-03-07 16:34:30 -08:00
Edward Thomson
565c419972 index::nsec: don't expect shit filesystems to not suck
If the underlying filesystem doesn't support better than one
second resolution, then don't expect that turning on `GIT_USE_NSEC`
does anything magical to change that.
2016-03-07 17:04:32 -05:00
Edward Thomson
6c04269c8f git_odb_exists_many_prefixes: query odb for multiple short ids
Query the object database for multiple objects at a time, given their
object ID (which may be abbreviated) and optional type.
2016-03-07 16:10:25 -05:00
Edward Thomson
e10144ae57 odb: improved not found error messages
When looking up an abbreviated oid, show the actual (abbreviated) oid
the caller passed instead of a full (but ambiguously truncated) oid.
2016-03-07 10:20:01 -05:00
Edward Thomson
6abdf52d6e merge::workdir::dirty: update to use st_ctime_nsec
Update unit test to use newfangled `st_ctime_nsec`, which provides
indirection to the platform-correct name.
2016-03-07 09:37:51 -05:00
Edward Thomson
785d8c48ea Merge pull request #3653 from libgit2/cmn/treebuilder-submodule
treebuilder: don't try to verify submodules exist in the odb
2016-03-04 13:50:23 +00:00
Carlos Martín Nieto
ea5bf6bbce treebuilder: don't try to verify submodules exist in the odb
Submodules don't exist in the objectdb and the code is making us try to
look for a blob with its commit id, which is obviously not going to
work.

Skip the test if the user wants to insert a submodule.
2016-03-04 12:38:28 +01:00
Edward Thomson
1609983377 Merge pull request #3651 from libgit2/cmn/init-libssh2
ssh: initialize libssh2
2016-03-03 22:57:45 +00:00
Carlos Martín Nieto
22f3d3aa6b ssh: initialize libssh2
We should have been doing this, but it initializes itself upon first
use, which works as long as nobody's doing concurrent network
operations. Initialize it on our init to make sure it's not getting
initialized concurrently.
2016-03-03 22:26:31 +01:00
Carlos Martín Nieto
839bdb05a0 Merge pull request #3639 from srajko/threading-openssl-libssh2
Expand OpenSSL and libssh2 thread safety documentation
2016-03-03 21:20:33 +01:00
Edward Thomson
2d8807126b Enable nanosecond resolution by default
Nanosecond resolution is now the default in git itself.  Enable this
as our default as well.
2016-03-03 15:08:12 -05:00
Carlos Martín Nieto
e23efa6ddf tests: take the version from our define 2016-03-03 21:03:10 +01:00
Carlos Martín Nieto
1e8255a39b Bump version to 0.24.0 2016-03-03 20:20:43 +01:00
Carlos Martín Nieto
c21c8f67e8 CHANGELOG: prepre tamplate for release 2016-03-03 20:18:55 +01:00
Carlos Martín Nieto
a7ef27af1c CHANGELOG: add note about WinHTTP cred handling 2016-03-03 20:17:13 +01:00
Carlos Martín Nieto
66a530eb4e Merge pull request #3648 from libgit2/cmn/auth-retry
test: make sure we retry the auth callback on all platforms
2016-03-03 20:11:18 +01:00
Carlos Martín Nieto
ba9bb664f3 tests: create a ctest target for cred_callback 2016-03-03 19:31:02 +01:00
Carlos Martín Nieto
778fb695ed Merge pull request #3646 from pks-t/pks/xdiff-fix-from-upstream
xdiff: fix memleak on error case
2016-03-03 12:14:02 +01:00