]> git.proxmox.com Git - libgit2.git/log
libgit2.git
8 years agotests: transport: fix memory leaks with registering transports
Patrick Steinhardt [Fri, 11 Mar 2016 08:58:38 +0000 (09:58 +0100)]
tests: transport: fix memory leaks with registering transports

8 years agotests: nsec: correctly free nsec_path
Patrick Steinhardt [Fri, 11 Mar 2016 08:07:29 +0000 (09:07 +0100)]
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.

8 years agoMerge pull request #3623 from ethomson/rebase_with_commit
Carlos Martín Nieto [Wed, 9 Mar 2016 22:45:33 +0000 (23:45 +0100)]
Merge pull request #3623 from ethomson/rebase_with_commit

rebase: additional setup tests of exotic behavior

8 years agoMerge pull request #3672 from libgit2/cmn/do-fail-appveyor
Carlos Martín Nieto [Wed, 9 Mar 2016 20:37:39 +0000 (21:37 +0100)]
Merge pull request #3672 from libgit2/cmn/do-fail-appveyor

appveyor: stop if the first test fails

8 years agoappveyor: stop if the first test fails
Carlos Martín Nieto [Wed, 9 Mar 2016 18:20:38 +0000 (19:20 +0100)]
appveyor: stop if the first test fails

8 years agoMerge pull request #3670 from libgit2/vmg/expand-fixes
Edward Thomson [Wed, 9 Mar 2016 18:12:34 +0000 (18:12 +0000)]
Merge pull request #3670 from libgit2/vmg/expand-fixes

Fixes for `gid_odb_expand_ids`

8 years agoodb: Try to lookup headers in all backends before passthrough
Vicent Marti [Wed, 9 Mar 2016 16:47:53 +0000 (17:47 +0100)]
odb: Try to lookup headers in all backends before passthrough

8 years agoodb: Refactor `git_odb_expand_ids`
Vicent Marti [Wed, 9 Mar 2016 15:41:08 +0000 (16:41 +0100)]
odb: Refactor `git_odb_expand_ids`

8 years agoodb: Implement new helper to read types without refreshing
Vicent Marti [Wed, 9 Mar 2016 10:29:46 +0000 (11:29 +0100)]
odb: Implement new helper to read types without refreshing

8 years agoMerge pull request #3668 from libgit2/cmn/mwindow-try-harder
Edward Thomson [Wed, 9 Mar 2016 14:51:13 +0000 (14:51 +0000)]
Merge pull request #3668 from libgit2/cmn/mwindow-try-harder

mwindow: free unused windows if we fail to mmap

8 years agomwindow: free unused windows if we fail to mmap
Carlos Martín Nieto [Wed, 9 Mar 2016 10:16:16 +0000 (11:16 +0100)]
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.

8 years agoodb: Handle corner cases in `git_odb_expand_ids`
Vicent Marti [Wed, 9 Mar 2016 10:00:27 +0000 (11:00 +0100)]
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.

8 years agoMerge pull request #3656 from ethomson/exists_prefixes
Vicent Marti [Tue, 8 Mar 2016 20:17:38 +0000 (21:17 +0100)]
Merge pull request #3656 from ethomson/exists_prefixes

Introduce `git_odb_expand_ids`

8 years agogit_odb_expand_ids: accept git_odb_expand_id array
Edward Thomson [Tue, 8 Mar 2016 19:09:55 +0000 (14:09 -0500)]
git_odb_expand_ids: accept git_odb_expand_id array

Take (and write to) an array of a struct, `git_odb_expand_id`.

8 years agogit_odb_expand_ids: rename func, return the type
Edward Thomson [Tue, 8 Mar 2016 16:44:21 +0000 (11:44 -0500)]
git_odb_expand_ids: rename func, return the type

8 years agoMerge pull request #3555 from cbargren/ssh-git-protocols
Edward Thomson [Tue, 8 Mar 2016 13:38:55 +0000 (13:38 +0000)]
Merge pull request #3555 from cbargren/ssh-git-protocols

Support for ssh+git and git+ssh protocols

8 years agoMerge pull request #3652 from libgit2/cmn/commit-to-memory
Edward Thomson [Tue, 8 Mar 2016 13:35:11 +0000 (13:35 +0000)]
Merge pull request #3652 from libgit2/cmn/commit-to-memory

commit: split creating the commit and writing it out

8 years agocommit: split creating the commit and writing it out
Carlos Martín Nieto [Thu, 3 Mar 2016 21:56:02 +0000 (22:56 +0100)]
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.

8 years agoMerge pull request #3655 from ethomson/nanosecond_defaults
Carlos Martín Nieto [Tue, 8 Mar 2016 09:43:33 +0000 (10:43 +0100)]
Merge pull request #3655 from ethomson/nanosecond_defaults

Enable nanosecond resolution by default

8 years agoindex::racy: force racy entry
Edward Thomson [Mon, 7 Mar 2016 22:37:17 +0000 (17:37 -0500)]
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.

8 years agoMerge pull request #3658 from patrickmckenna/update-pro-git-link
Edward Thomson [Tue, 8 Mar 2016 01:45:29 +0000 (01:45 +0000)]
Merge pull request #3658 from patrickmckenna/update-pro-git-link

Update link to Pro Git's Git internals chapter

8 years agoUpdate link to Pro Git's Git internals chapter.
Patrick McKenna [Tue, 8 Mar 2016 00:34:30 +0000 (16:34 -0800)]
Update link to Pro Git's Git internals chapter.

8 years agoindex::nsec: don't expect shit filesystems to not suck
Edward Thomson [Mon, 7 Mar 2016 22:04:32 +0000 (17:04 -0500)]
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.

8 years agogit_odb_exists_many_prefixes: query odb for multiple short ids
Edward Thomson [Fri, 4 Mar 2016 05:50:35 +0000 (00:50 -0500)]
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.

8 years agoodb: improved not found error messages
Edward Thomson [Fri, 4 Mar 2016 06:18:30 +0000 (01:18 -0500)]
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.

8 years agomerge::workdir::dirty: update to use `st_ctime_nsec`
Edward Thomson [Mon, 7 Mar 2016 14:37:51 +0000 (09:37 -0500)]
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.

8 years agoMerge pull request #3653 from libgit2/cmn/treebuilder-submodule
Edward Thomson [Fri, 4 Mar 2016 13:50:23 +0000 (13:50 +0000)]
Merge pull request #3653 from libgit2/cmn/treebuilder-submodule

treebuilder: don't try to verify submodules exist in the odb

8 years agotreebuilder: don't try to verify submodules exist in the odb
Carlos Martín Nieto [Fri, 4 Mar 2016 11:34:38 +0000 (12:34 +0100)]
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.

8 years agoMerge pull request #3651 from libgit2/cmn/init-libssh2
Edward Thomson [Thu, 3 Mar 2016 22:57:45 +0000 (22:57 +0000)]
Merge pull request #3651 from libgit2/cmn/init-libssh2

ssh: initialize libssh2

8 years agossh: initialize libssh2
Carlos Martín Nieto [Thu, 3 Mar 2016 21:26:31 +0000 (22:26 +0100)]
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.

8 years agoMerge pull request #3639 from srajko/threading-openssl-libssh2
Carlos Martín Nieto [Thu, 3 Mar 2016 20:20:33 +0000 (21:20 +0100)]
Merge pull request #3639 from srajko/threading-openssl-libssh2

Expand OpenSSL and libssh2 thread safety documentation

8 years agoEnable nanosecond resolution by default
Edward Thomson [Thu, 3 Mar 2016 20:08:12 +0000 (15:08 -0500)]
Enable nanosecond resolution by default

Nanosecond resolution is now the default in git itself.  Enable this
as our default as well.

8 years agotests: take the version from our define
Carlos Martín Nieto [Thu, 3 Mar 2016 20:03:10 +0000 (21:03 +0100)]
tests: take the version from our define

8 years agoBump version to 0.24.0
Carlos Martín Nieto [Thu, 3 Mar 2016 19:20:43 +0000 (20:20 +0100)]
Bump version to 0.24.0

8 years agoCHANGELOG: prepre tamplate for release
Carlos Martín Nieto [Thu, 3 Mar 2016 19:18:55 +0000 (20:18 +0100)]
CHANGELOG: prepre tamplate for release

8 years agoCHANGELOG: add note about WinHTTP cred handling
Carlos Martín Nieto [Thu, 3 Mar 2016 19:17:13 +0000 (20:17 +0100)]
CHANGELOG: add note about WinHTTP cred handling

8 years agoMerge pull request #3648 from libgit2/cmn/auth-retry
Carlos Martín Nieto [Thu, 3 Mar 2016 19:11:18 +0000 (20:11 +0100)]
Merge pull request #3648 from libgit2/cmn/auth-retry

test: make sure we retry the auth callback on all platforms

8 years agotests: create a ctest target for cred_callback
Carlos Martín Nieto [Thu, 3 Mar 2016 18:21:07 +0000 (19:21 +0100)]
tests: create a ctest target for cred_callback

8 years agoMerge pull request #3646 from pks-t/pks/xdiff-fix-from-upstream
Carlos Martín Nieto [Thu, 3 Mar 2016 11:14:02 +0000 (12:14 +0100)]
Merge pull request #3646 from pks-t/pks/xdiff-fix-from-upstream

xdiff: fix memleak on error case

8 years agowinhttp: retry authentication
Carlos Martín Nieto [Thu, 3 Mar 2016 09:48:24 +0000 (10:48 +0100)]
winhttp: retry authentication

If the caller has provided bad authentication, give them another
apportunity to get it right until they give up. This brings WinHTTP in
line with the other transports.

8 years agotest: make sure we retry the auth callback on all platforms
Carlos Martín Nieto [Thu, 3 Mar 2016 09:08:00 +0000 (10:08 +0100)]
test: make sure we retry the auth callback on all platforms

We were missing this test on Windows, which meant we didn't notice that
we never fixed the single authentication attempt it tries, nor its wrong
return code.

Enable this for the unix platforms as well over HTTP. We previously were
doing it locally but disabled it on OS X due to issues with its sshd not
accepting password authentication.

8 years agotests: plug a leak
Carlos Martín Nieto [Thu, 3 Mar 2016 10:17:36 +0000 (11:17 +0100)]
tests: plug a leak

8 years agoMerge pull request #3633 from ethomson/safe_creation
Edward Thomson [Tue, 1 Mar 2016 17:16:27 +0000 (17:16 +0000)]
Merge pull request #3633 from ethomson/safe_creation

Stricter object dependency checking during creation

8 years agoxdiff: fix memleak on error case
Patrick Steinhardt [Tue, 1 Mar 2016 07:54:00 +0000 (08:54 +0100)]
xdiff: fix memleak on error case

Commit 3d1abc5afce fixes a memory leak in the xdiff code. In the
process of upstreaming the fix it was pointed out by Johannes
Schindelin that there is another memory leak present (see [1]).

Fix the second memory leak by applying the upstream fix to our
code base.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/287034

8 years agoMerge pull request #3567 from sba1/few-p_getaddrinfo-fixes
Edward Thomson [Mon, 29 Feb 2016 01:13:24 +0000 (20:13 -0500)]
Merge pull request #3567 from sba1/few-p_getaddrinfo-fixes

Few p_getaddrinfo fixes

8 years agorebase: additional tests for completing a rebase
Edward Thomson [Mon, 29 Feb 2016 01:10:44 +0000 (20:10 -0500)]
rebase: additional tests for completing a rebase

8 years agoturn on strict object validation by default
Edward Thomson [Sun, 28 Feb 2016 20:51:38 +0000 (15:51 -0500)]
turn on strict object validation by default

8 years agotests: use legitimate object ids
Edward Thomson [Sun, 28 Feb 2016 21:02:49 +0000 (16:02 -0500)]
tests: use legitimate object ids

Use legitimate (existing) object IDs in tests so that we have the
ability to turn on strict object validation when running tests.

8 years agorefs: honor strict object creation
Edward Thomson [Sun, 28 Feb 2016 20:11:15 +0000 (15:11 -0500)]
refs: honor strict object creation

8 years agogit_object__is_valid: use `odb_read_header`
Edward Thomson [Sun, 28 Feb 2016 19:37:37 +0000 (14:37 -0500)]
git_object__is_valid: use `odb_read_header`

This allows lighter weight validation in `git_object__is_valid` that
does not require reading the entire object.

8 years agogit_index_add: validate objects in index entries (optionally)
Edward Thomson [Tue, 23 Feb 2016 23:29:16 +0000 (18:29 -0500)]
git_index_add: validate objects in index entries (optionally)

When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the index entries given to `git_index_add`.

8 years agoMerge pull request #3644 from ethomson/debug_pool
Carlos Martín Nieto [Sun, 28 Feb 2016 18:43:45 +0000 (19:43 +0100)]
Merge pull request #3644 from ethomson/debug_pool

travis ci: enable debug pool for valgrind builds

8 years agotreebuilder: validate tree entries (optionally)
Edward Thomson [Tue, 23 Feb 2016 20:00:27 +0000 (15:00 -0500)]
treebuilder: validate tree entries (optionally)

When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to treebuilder insertion.

8 years agogit_commit: validate tree and parent ids
Edward Thomson [Tue, 23 Feb 2016 18:34:35 +0000 (13:34 -0500)]
git_commit: validate tree and parent ids

When `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION` is turned on, validate
the tree and parent ids given to commit creation functions.

8 years agogit_object__is_valid: simple object validity test
Edward Thomson [Tue, 23 Feb 2016 18:33:10 +0000 (13:33 -0500)]
git_object__is_valid: simple object validity test

8 years agogit_libgit2_opts: introduce `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION`
Edward Thomson [Tue, 23 Feb 2016 04:46:50 +0000 (23:46 -0500)]
git_libgit2_opts: introduce `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION`

8 years agotravis ci: enable debug pool for valgrind builds
Edward Thomson [Sun, 28 Feb 2016 16:34:36 +0000 (11:34 -0500)]
travis ci: enable debug pool for valgrind builds

8 years agoMerge pull request #3577 from rossdylan/rossdylan/pooldebug
Edward Thomson [Sun, 28 Feb 2016 16:31:10 +0000 (11:31 -0500)]
Merge pull request #3577 from rossdylan/rossdylan/pooldebug

Add a new build flag to disable the pool allocator

8 years agoExpand OpenSSL and libssh2 thread safety documentation
Stjepan Rajko [Thu, 25 Feb 2016 22:19:51 +0000 (15:19 -0700)]
Expand OpenSSL and libssh2 thread safety documentation

8 years agoFixed typo in one of the ifndef's in pool.h used to enable/disable debug mode
Ross Delinger [Fri, 26 Feb 2016 17:51:13 +0000 (12:51 -0500)]
Fixed typo in one of the ifndef's in pool.h used to enable/disable debug mode

8 years agoMerge pull request #3638 from ethomson/nsec
Carlos Martín Nieto [Thu, 25 Feb 2016 17:42:09 +0000 (18:42 +0100)]
Merge pull request #3638 from ethomson/nsec

USE_NSECS fixes

8 years agoMerge pull request #3628 from pks-t/pks/coverity-fixes
Edward Thomson [Thu, 25 Feb 2016 17:09:49 +0000 (12:09 -0500)]
Merge pull request #3628 from pks-t/pks/coverity-fixes

Coverity fixes

8 years agoMerge pull request #3630 from libgit2/cmn/idx-extra-check
Edward Thomson [Thu, 25 Feb 2016 16:59:00 +0000 (11:59 -0500)]
Merge pull request #3630 from libgit2/cmn/idx-extra-check

Extra checks for packfile indices

8 years agonsec: support NDK's crazy nanoseconds
Edward Thomson [Thu, 25 Feb 2016 16:23:19 +0000 (11:23 -0500)]
nsec: support NDK's crazy nanoseconds

Android NDK does not have a `struct timespec` in its `struct stat`
for nanosecond support, instead it has a single nanosecond member inside
the struct stat itself.  We will use that and use a macro to expand to
the `st_mtim` / `st_mtimespec` definition on other systems (much like
the existing `st_mtime` backcompat definition).

8 years agonsec: update staging test for GIT_USE_NSECS
Edward Thomson [Thu, 25 Feb 2016 16:31:18 +0000 (11:31 -0500)]
nsec: update staging test for GIT_USE_NSECS

The index::nsec::staging_maintains_other_nanos test was created to
ensure that when we stage an entry when GIT_USE_NSECS is *unset* that
we truncate the index entry and do not persist the (old, invalid)
nanosec values.  Ensure that when GIT_USE_NSECS is *set* that we do
not do that, and actually write the correct nanosecond values.

8 years agopack: don't allow a negative offset
Carlos Martín Nieto [Thu, 25 Feb 2016 14:46:59 +0000 (15:46 +0100)]
pack: don't allow a negative offset

8 years agopack: make sure we don't go out of bounds for extended entries
Carlos Martín Nieto [Tue, 23 Feb 2016 17:15:43 +0000 (18:15 +0100)]
pack: make sure we don't go out of bounds for extended entries

A corrupt index might have data that tells us to go look past the end of
the file for data. Catch these cases and return an appropriate error
message.

8 years agoMerge pull request #3637 from libgit2/cmn/conventions
Edward Thomson [Thu, 25 Feb 2016 14:08:23 +0000 (09:08 -0500)]
Merge pull request #3637 from libgit2/cmn/conventions

CONVENTIONS: update to include general public API principles

8 years agoCONVENTIONS: update to include general public API principles
Carlos Martín Nieto [Thu, 25 Feb 2016 13:51:00 +0000 (14:51 +0100)]
CONVENTIONS: update to include general public API principles

8 years agoopenssl: we already had the function, just needed the header
Carlos Martín Nieto [Wed, 24 Feb 2016 16:17:57 +0000 (17:17 +0100)]
openssl: we already had the function, just needed the header

8 years agoopenssl: export the locking function when building without OpenSSL
Carlos Martín Nieto [Wed, 24 Feb 2016 15:38:22 +0000 (16:38 +0100)]
openssl: export the locking function when building without OpenSSL

This got lost duing the move and it lets the users call this function
just in case.

8 years agoMerge pull request #3631 from ethomson/giterr_fixups
Carlos Martín Nieto [Tue, 23 Feb 2016 21:27:36 +0000 (22:27 +0100)]
Merge pull request #3631 from ethomson/giterr_fixups

Minor `giterr` fixups

8 years agogiterr_set_str: remove `GITERR_OS` documentation
Edward Thomson [Tue, 23 Feb 2016 18:05:49 +0000 (13:05 -0500)]
giterr_set_str: remove `GITERR_OS` documentation

The `giterr_set_str` does not actually honor `GITERR_OS`.  Remove
the documentation that claims that we do.

8 years agomap: use `giterr_set` internally
Edward Thomson [Tue, 23 Feb 2016 18:02:07 +0000 (13:02 -0500)]
map: use `giterr_set` internally

Use the `giterr_set` function, which actually supports `GITERR_OS`.
The `giterr_set_str` function is exposed for external users and will
not append the operating system's error message.

8 years agodiff_tform: fix potential NULL pointer access
Patrick Steinhardt [Tue, 23 Feb 2016 10:07:03 +0000 (11:07 +0100)]
diff_tform: fix potential NULL pointer access

The `normalize_find_opts` function in theory allows for the
incoming diff to have no repository. When the caller does not
pass in diff find options or if the GIT_DIFF_FIND_BY_CONFIG value
is set, though, we try to derive the configuration from the
diff's repository configuration without first verifying that the
repository is actually set to a non-NULL value.

Fix this issue by explicitly checking if the repository is set
and if it is not, fall back to a default value of
GIT_DIFF_FIND_RENAMES.

8 years agoxmerge: fix memory leak on error path
Patrick Steinhardt [Mon, 22 Feb 2016 16:13:23 +0000 (17:13 +0100)]
xmerge: fix memory leak on error path

8 years agoopenssl_stream: fix NULL pointer dereference
Patrick Steinhardt [Tue, 23 Feb 2016 10:16:36 +0000 (11:16 +0100)]
openssl_stream: fix NULL pointer dereference

8 years agoopenssl_stream: fix memory leak when creating new stream
Patrick Steinhardt [Mon, 22 Feb 2016 15:08:56 +0000 (16:08 +0100)]
openssl_stream: fix memory leak when creating new stream

8 years agorebase: plug memory leak in `rebase_alloc`
Patrick Steinhardt [Mon, 22 Feb 2016 15:05:13 +0000 (16:05 +0100)]
rebase: plug memory leak in `rebase_alloc`

Convert `rebase_alloc` to use our usual error propagation
patterns, that is accept an out-parameter and return an error
code that is to be checked by the caller. This allows us to use
the GITERR_CHECK_ALLOC macro, which helps static analysis.

8 years agoremote: set error code in `create_internal`
Patrick Steinhardt [Mon, 22 Feb 2016 15:01:03 +0000 (16:01 +0100)]
remote: set error code in `create_internal`

Set the error code when an error occurs in any of the called
functions. This ensures we pass the error up to callers and
actually free the remote when an error occurs.

8 years agoindex: fix contradicting comparison
Patrick Steinhardt [Tue, 23 Feb 2016 10:23:26 +0000 (11:23 +0100)]
index: fix contradicting comparison

The overflow check in `read_reuc` tries to verify if the
`git__strtol32` parses an integer bigger than UINT_MAX. The `tmp`
variable is casted to an unsigned int for this and then checked
for being greater than UINT_MAX, which obviously can never be
true.

Fix this by instead fixing the `mode` field's size in `struct
git_index_reuc_entry` to `uint32_t`. We can now parse the int
with `git__strtol64`, which can never return a value bigger than
`UINT32_MAX`, and additionally checking if the returned value is
smaller than zero.

We do not need to handle overflows explicitly here, as
`git__strtol64` returns an error when the returned value would
overflow.

8 years agoindex: plug memory leak in `read_conflict_names`
Patrick Steinhardt [Mon, 22 Feb 2016 14:59:15 +0000 (15:59 +0100)]
index: plug memory leak in `read_conflict_names`

8 years agotransports: smart_pkt: fix memory leaks on error paths
Patrick Steinhardt [Mon, 22 Feb 2016 14:52:49 +0000 (15:52 +0100)]
transports: smart_pkt: fix memory leaks on error paths

8 years agorefdb_fs: remove unnecessary check for NULL
Patrick Steinhardt [Mon, 22 Feb 2016 13:06:48 +0000 (14:06 +0100)]
refdb_fs: remove unnecessary check for NULL

The fail-label of `reflog_parse` explicitly checks the entry
poitner for NULL before freeing it. When we jump to the label the
variable has to be set to a non-NULL and valid pointer though: if
the allocation fails we immediately return with an error code and
if the loop was not entered we return with a success code,
withouth executing the label's code.

Remove the useless NULL-check to silence Coverity.

8 years agodiff_print: assert patch is non-NULL
Patrick Steinhardt [Mon, 22 Feb 2016 13:01:50 +0000 (14:01 +0100)]
diff_print: assert patch is non-NULL

When invoking `diff_print_info_init_frompatch` it is obvious that
the patch should be non-NULL. We explicitly check if the variable
is set and continue afterwards, happily dereferencing the
potential NULL-pointer.

Fix this by instead asserting that patch is set. This also
silences Coverity.

8 years agopack-objects: return early when computing write order fails
Patrick Steinhardt [Mon, 22 Feb 2016 12:48:45 +0000 (13:48 +0100)]
pack-objects: return early when computing write order fails

The function `compute_write_order` may return a `NULL`-pointer
when an error occurs. In such cases we jump to the `done`-label
where we try to clean up allocated memory. Unfortunately we try
to deallocate the `write_order` array, though, which may be NULL
here.

Fix this error by returning early instead of jumping to the
`done` label. There is no data to be cleaned up anyway.

8 years agopack-objects: check realloc in try_delta with GITERR_CHECK_ALLOC
Patrick Steinhardt [Tue, 23 Feb 2016 09:45:09 +0000 (10:45 +0100)]
pack-objects: check realloc in try_delta with GITERR_CHECK_ALLOC

8 years agocrlf: do not ignore GIT_PASSTHROUGH error
Patrick Steinhardt [Mon, 22 Feb 2016 12:33:48 +0000 (13:33 +0100)]
crlf: do not ignore GIT_PASSTHROUGH error

When no payload is set for `crlf_apply` we try to compute the
crlf attributes ourselves with `crlf_check`. When the function
determines that the current file does not require any treatment
we return the GIT_PASSTHROUGH error code without actually
allocating the out-pointer, which indicates the file should not
be passed through the filter.

The `crlf_apply` function explicitly checks for the
GIT_PASSTHROUGH return code and ignores it. This means we will
try to apply the crlf-filter to the current file, leading us to
dereference the unallocated payload-pointer.

Fix this obviously incorrect behavior by not treating
GIT_PASSTHROUGH in any special way. This is the correct thing to
do anyway, as the code indicates that the file should not be
passed through the filter.

8 years agorefspec: check buffer with GITERR_CHECK_ALLOC_BUF
Patrick Steinhardt [Tue, 23 Feb 2016 09:09:03 +0000 (10:09 +0100)]
refspec: check buffer with GITERR_CHECK_ALLOC_BUF

8 years agorevwalk: use GITERR_CHECK_ALLOC_BUF
Patrick Steinhardt [Tue, 23 Feb 2016 10:48:30 +0000 (11:48 +0100)]
revwalk: use GITERR_CHECK_ALLOC_BUF

8 years agosmart_pkt: check buffer with GITERR_CHECK_ALLOC_BUF
Patrick Steinhardt [Tue, 23 Feb 2016 10:45:43 +0000 (11:45 +0100)]
smart_pkt: check buffer with GITERR_CHECK_ALLOC_BUF

8 years agopath: use GITERR_CHECK_ALLOC_BUF to verify passed in buffer
Patrick Steinhardt [Tue, 23 Feb 2016 09:02:44 +0000 (10:02 +0100)]
path: use GITERR_CHECK_ALLOC_BUF to verify passed in buffer

8 years agocommon: introduce GITERR_CHECK_ALLOC_BUF
Patrick Steinhardt [Tue, 23 Feb 2016 08:54:26 +0000 (09:54 +0100)]
common: introduce GITERR_CHECK_ALLOC_BUF

We commonly have to check if a git_buf has been allocated
correctly or if we ran out of memory. Introduce a new macro
similar to `GITERR_CHECK_ALLOC` which checks if we ran OOM and if
so returns an error. Provide a `#nodef` for Coverity to mark the
error case as an abort path.

8 years agocoverity: hint git_vector_foreach does not deref NULL contents
Patrick Steinhardt [Mon, 22 Feb 2016 13:43:28 +0000 (14:43 +0100)]
coverity: hint git_vector_foreach does not deref NULL contents

Coverity does not comprehend the connection between a vector's
size and the contents pointer, that is that the vector's pointer
is non-NULL when its size is positive. As the vector code should
be reasonably well tested and users are expected to not manually
modify a vector's contents it seems save to assume that the
macros will never dereference a NULL pointer.

Fix Coverity warnings by overriding the foreach macros with
macros that explicitly aborting when (v)->contents is NULL.

8 years agoMerge pull request #3629 from ethomson/set_user_agent_doc
Vicent Marti [Tue, 23 Feb 2016 07:16:12 +0000 (08:16 +0100)]
Merge pull request #3629 from ethomson/set_user_agent_doc

git_libgit2_opts: minor documentation & usage fixes

8 years agogit_libgit2_opts: validate key
Edward Thomson [Tue, 23 Feb 2016 04:04:40 +0000 (23:04 -0500)]
git_libgit2_opts: validate key

8 years agogit_libgit2_opts: document GIT_OPT_SET_USER_AGENT
Edward Thomson [Tue, 23 Feb 2016 03:26:01 +0000 (22:26 -0500)]
git_libgit2_opts: document GIT_OPT_SET_USER_AGENT

8 years agoMerge pull request #3627 from libgit2/cmn/typo
Edward Thomson [Mon, 22 Feb 2016 15:16:49 +0000 (10:16 -0500)]
Merge pull request #3627 from libgit2/cmn/typo

Fix a few checkout -> rebase typos

8 years agoFix a few checkout -> rebase typos
Carlos Martín Nieto [Mon, 22 Feb 2016 14:41:01 +0000 (15:41 +0100)]
Fix a few checkout -> rebase typos

8 years agoopenssl: re-export the last-resort locking function
Carlos Martín Nieto [Fri, 19 Feb 2016 15:23:14 +0000 (16:23 +0100)]
openssl: re-export the last-resort locking function

We need to include the header where we define the function. Otherwise it
won't be available on the DLL.