summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
...
| * | blame: check error code when loading the mailmapEtienne Samson2018-07-061-2/+5
| |/ | | | | | | Reported by Coverity, CID 1393484
* | Merge pull request #4704 from nelhage/no-pkt-packPatrick Steinhardt2018-07-193-24/+4
|\ \ | | | | | | Remove GIT_PKT_PACK entirely
| * | No need for this placeholder.Nelson Elhage2018-07-151-1/+0
| | |
| * | This error case is now unneededNelson Elhage2018-06-291-6/+0
| | |
| * | Merge remote-tracking branch 'origin/master' into no-pkt-packNelson Elhage2018-06-299-57/+112
| |\ \
| * | | Small style tweak, and set an errorNelson Elhage2018-06-281-1/+11
| | | |
| * | | Remove GIT_PKT_PACK entirelyNelson Elhage2018-06-262-26/+3
| | | |
* | | | Merge pull request #4722 from boogisha/path-is-ignored-git-analogyEdward Thomson2018-07-161-2/+2
|\ \ \ \ | | | | | | | | | | ignore: improve `git_ignore_path_is_ignored` description Git analogy
| * | | | ignore: improve `git_ignore_path_is_ignored` description Git analogyIgor Djordjevic2018-07-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In attempt to provide adequate Git command analogy in regards to ignored files handling, `git_ignore_path_is_ignored` description mentions doing `git add .` on directory containing the file, and whether the file in question would be added or not - but behavior of the two matches for untracked files only, making the comparison misleading in general sense. For tracked files, Git doesn't subject them to ignore rules, so even if a rule applies, `git add .` would actually add the tracked file changes to index, while `git_ignore_path_is_ignored` would still consider the file being ignored (as it doesn't check the index, as documented). Let's provide `git check-ignore --no-index` as analogous Git command example instead, being more aligned with what `git_ignore_path_is_ignored` is about, no matter if the file in question is already tracked or not. See issue #4720 (git_ignore_path_is_ignored documentation misleading?, 2018-07-10)[1] for additional information. [1] https://github.com/libgit2/libgit2/issues/4720
* | | | | Merge pull request #4724 from libgit2/cmn/allocator-init-orderCarlos Martín Nieto2018-07-151-0/+7
|\ \ \ \ \ | | | | | | | | | | | | alloc: don't overwrite allocator during init if set
| * | | | | alloc: don't overwrite allocator during init if setcmn/allocator-init-orderCarlos Martín Nieto2018-07-151-0/+7
|/ / / / / | | | | | | | | | | | | | | | | | | | | If the allocator has been set before we the library is initialised, we would replace that setting with the standard allocator contrary to the user's wishes.
* | | | | Merge pull request #4700 from pks-t/pks/std-c90Edward Thomson2018-07-1477-200/+239
|\ \ \ \ \ | |/ / / / |/| | | | C90 standard compliance
| * | | | cmake: enforce C90 standardPatrick Steinhardt2018-07-134-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the aim of libgit2 was to conform to C90 code, we never instructed the compiler to enforce C90 compliance. Thus, quite a few violations were able to get into our code base, which have been removed with the previous commits. As we are now able to build libgit2 with C90 enforced, we can set the C_STANDARD property for our own build targets. Note that we explicitly avoid setting the C standard for our third-party dependencies. At least the zlib target does not build with C90 enforced, and we do not want to fix them by deviating from upstream. Thus we simply enforce no standard for them.
| * | | | mbedtls: fix `inline` being used in mbedtls headersPatrick Steinhardt2018-07-131-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The mbedtls headers make direct use of the `inline` attribute to instruct the compiler to inline functions. As this function is not C90 compliant, this can cause the compiler to error as soon as any of these files is included and the `-std=c90` flag is being added. The mbedtls headers declaring functions as inline always have a prelude which define `inline` as a macro in case it is not yet defined. Thus, we can easily replace their define with our own define, which simply copies the logic of our own `GIT_INLINE` macro.
| * | | | cmake: distinguish internal and system include directoriesPatrick Steinhardt2018-07-133-14/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we want to enforce strict C90 mode, this may cause issues with system provided header files which are themselves not strictly conforming. E.g. if a system header has C++ style comments, a compiler in strict C90 mode would produce an error and abort the build. As the user most likely doesn't want to change the system header, this would completely break the build on such systems. One example of this is mbedtls, which provides such header files. The problem can be worked around by distinguishing between system-provided and project-provided include directories. When adding include directories via "-isystem" instead of "-I", the compiler will skip certain checks and print out less warnings. To use system includes, we can simply add the "SYSTEM" flag to CMake's `INCLUDE_DIRECTORIES` and `TARGET_INCLUDE_DIRECTORIES` functions. Note that we have to split the include directories into two variables because of this, as we definitely still want to check for all warnings produced by our own header files.
| * | | | treewide: remove use of C++ style commentsPatrick Steinhardt2018-07-1369-182/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | C++ style comment ("//") are not specified by the ISO C90 standard and thus do not conform to it. While libgit2 aims to conform to C90, we did not enforce it until now, which is why quite a lot of these non-conforming comments have snuck into our codebase. Do a tree-wide conversion of all C++ style comments to the supported C style comments to allow us enforcing strict C90 compliance in a later commit.
| * | | | treewide: avoid use of `inline` attributePatrick Steinhardt2018-07-133-3/+9
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ISO C90 does not specify the `inline` attribute, and as such we cannot use it in our code. While we already use `__inline` when building in Microsoft Visual Studio, we should also be using the `__inline__` attribute from GCC/Clang. Otherwise, if we're using neither MSVC nor GCC/Clang, we should simply avoid using `inline` at all and just define functions as static. This commit adjusts our own `GIT_INLINE` macro as well as the inline macros specified by khash and xdiff. This allows us to enable strict C90 mode in a later commit.
* | | | Merge pull request #4719 from pks-t/pks/delta-oobEdward Thomson2018-07-093-28/+52
|\ \ \ \ | | | | | | | | | | Delta OOB access
| * | | | delta: fix overflow when computing limitPatrick Steinhardt2018-07-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When checking whether a delta base offset and length fit into the base we have in memory already, we can trigger an overflow which breaks the check. This would subsequently result in us reading memory from out of bounds of the base. The issue is easily fixed by checking for overflow when adding `off` and `len`, thus guaranteeting that we are never indexing beyond `base_len`. This corresponds to the git patch 8960844a7 (check patch_delta bounds more carefully, 2006-04-07), which adds these overflow checks. Reported-by: Riccardo Schirone <rschiron@redhat.com>
| * | | | delta: fix out-of-bounds read of deltaPatrick Steinhardt2018-06-292-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When computing the offset and length of the delta base, we repeatedly increment the `delta` pointer without checking whether we have advanced past its end already, which can thus result in an out-of-bounds read. Fix this by repeatedly checking whether we have reached the end. Add a test which would cause Valgrind to produce an error. Reported-by: Riccardo Schirone <rschiron@redhat.com> Test-provided-by: Riccardo Schirone <rschiron@redhat.com>
| * | | | delta: fix sign-extension of big left-shiftPatrick Steinhardt2018-06-293-17/+28
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our delta code was originally adapted from JGit, which itself adapted it from git itself. Due to this heritage, we inherited a bug from git.git in how we compute the delta offset, which was fixed upstream in 48fb7deb5 (Fix big left-shifts of unsigned char, 2009-06-17). As explained by Linus: Shifting 'unsigned char' or 'unsigned short' left can result in sign extension errors, since the C integer promotion rules means that the unsigned char/short will get implicitly promoted to a signed 'int' due to the shift (or due to other operations). This normally doesn't matter, but if you shift things up sufficiently, it will now set the sign bit in 'int', and a subsequent cast to a bigger type (eg 'long' or 'unsigned long') will now sign-extend the value despite the original expression being unsigned. One example of this would be something like unsigned long size; unsigned char c; size += c << 24; where despite all the variables being unsigned, 'c << 24' ends up being a signed entity, and will get sign-extended when then doing the addition in an 'unsigned long' type. Since git uses 'unsigned char' pointers extensively, we actually have this bug in a couple of places. In our delta code, we inherited such a bogus shift when computing the offset at which the delta base is to be found. Due to the sign extension we can end up with an offset where all the bits are set. This can allow an arbitrary memory read, as the addition in `base_len < off + len` can now overflow if `off` has all its bits set. Fix the issue by casting the result of `*delta++ << 24UL` to an unsigned integer again. Add a test with a crafted delta that would actually succeed with an out-of-bounds read in case where the cast wouldn't exist. Reported-by: Riccardo Schirone <rschiron@redhat.com> Test-provided-by: Riccardo Schirone <rschiron@redhat.com>
* | | | Merge pull request #4710 from pks-t/pks/ssl-init-errorsEdward Thomson2018-07-081-21/+16
|\ \ \ \ | |_|_|/ |/| | | streams: report OpenSSL errors if global init fails
| * | | streams: report OpenSSL errors if global init failsPatrick Steinhardt2018-07-061-21/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case when the global initialization of the OpenSSL stream fails, the user is left without any hint as to what went wrong as we do not provide any error message at all. This commit refactors the init function to have a common error path, which now also sets an error message including the error string provided by OpenSSL.
* | | | Merge pull request #4687 from tiennou/fix/4672Edward Thomson2018-07-062-0/+78
|\ \ \ \ | | | | | | | | | | patch_parse: populate line numbers while parsing diffs
| * | | | patch_parse: populate line numbers while parsing diffsEtienne Samson2018-06-192-0/+78
| | |_|/ | |/| |
* | | | Merge pull request #4686 from tiennou/fix/more-worktree-from-barePatrick Steinhardt2018-07-066-68/+117
|\ \ \ \ | | | | | | | | | | Fix git_worktree_validate failing on bare repositories
| * | | | worktree: don't return "untyped" negative numbers as error codesEtienne Samson2018-06-291-11/+4
| | | | |
| * | | | worktree: skip building a buffer when validatingEtienne Samson2018-06-291-4/+1
| | | | |
| * | | | tests: worktree/bare: test some pathsEtienne Samson2018-06-291-0/+18
| | | | |
| * | | | tests: add a helper to build sandbox subpaths quicklyEtienne Samson2018-06-293-20/+39
| | | | |
| * | | | tests: worktree/bare: fix git_worktree_validateEtienne Samson2018-06-292-1/+3
| | | | |
| * | | | tests: worktree/bare: check git_worktree_listEtienne Samson2018-06-291-0/+5
| | | | |
| * | | | tests: worktree/bare: gather all testsEtienne Samson2018-06-292-32/+47
| | | | |
* | | | | Merge pull request #4699 from nelhage/fetch-null-dstPatrick Steinhardt2018-07-062-1/+6
|\ \ \ \ \ | | | | | | | | | | | | git_refspec_transform: Handle NULL dst
| * | | | | formatting fixNelson Elhage2018-06-291-1/+2
| | | | | |
| * | | | | Add a test.Nelson Elhage2018-06-251-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Verified that this breaks before the fix and passes afterwards.
| * | | | | git_refspec_transform: Handle NULL dstNelson Elhage2018-06-251-1/+1
| | |/ / / | |/| | |
* | | | | Merge pull request #4536 from libgit2/ethomson/index_dirtyEdward Thomson2018-06-3015-73/+431
|\ \ \ \ \ | |_|/ / / |/| | | | Add a "dirty" state to the index when it has unsaved changes
| * | | | docs: add unsaved index safety to changelogethomson/index_dirtyEdward Thomson2018-06-291-0/+12
| | | | |
| * | | | settings: optional unsaved index safetyEdward Thomson2018-06-295-3/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the `GIT_OPT_ENABLE_UNSAVED_INDEX_SAFETY` option, which will cause commands that reload the on-disk index to fail if the current `git_index` has changed that have not been saved. This will prevent users from - for example - adding a file to the index then calling a function like `git_checkout` and having that file be silently removed from the index since it was re-read from disk. Now calls that would re-read the index will fail if the index is "dirty", meaning changes have been made to it but have not been written. Users can either `git_index_read` to discard those changes explicitly, or `git_index_write` to write them.
| * | | | index: return a unique error code on dirty indexEdward Thomson2018-06-293-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | When the index is dirty, return GIT_EINDEXDIRTY so that consumers can identify the exact problem programatically.
| * | | | checkout: FORCE doesn't halt on dirty indexEdward Thomson2018-06-293-26/+19
| | | | | | | | | | | | | | | | | | | | | | | | | If the index is dirty, allow `GIT_CHECKOUT_FORCE` to obliterate unsaved changes. This is in keeping with its name and description.
| * | | | index: commit the changes to the index properlyEdward Thomson2018-06-299-15/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the index has a "dirty" state, where it has changes that have not yet been committed or rolled back, our tests need to be adapted to actually commit or rollback the changes instead of assuming that the index can be operated on in its indeterminate state.
| * | | | index: test dirty index bitEdward Thomson2018-06-291-0/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Test that any changes to the index will mark the index as dirty. Also ensure that when we initialize a new index, read the index contents from disk, or write the index contents to disk that we reset the dirty flag to zero. Further ensure that an unforced read with dirty contents (when the on-disk index has not changed) does _not_ reset the dirty flag as we have not updated the contents of our index and our unsaved contents remain intact.
| * | | | index: add a dirty bit reflecting unsaved changesEdward Thomson2018-06-292-6/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Teach the index when it is "dirty", and has unsaved changes. Consider the index dirty whenever a caller has added or removed an entry from the main index, REUC or NAME section, including when the index is completely cleared. Similarly, consider the index _not_ dirty immediately after it is written, or when it is read from the on-disk index. This allows us to ensure that unsaved changes are not lost when we automatically refresh the index.
| * | | | stash: use _an_ index not _the_ indexEdward Thomson2018-06-291-28/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't manipulate the repository's index during stash; instead, manipulate a temporary index and check it out. This allows us to use the checkout mechanism to update the workdir and the repository's index, and allows checkout to use its common mechanisms to write data and handle errors.
| * | | | checkout tests: validate GIT_CHECKOUT_NO_REFRESHEdward Thomson2018-06-291-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add tests that ensure that we re-read the on-disk image by default during checkout, but when the `GIT_CHECKOUT_NO_REFRESH` option is specified, we do _not_ re-read the index.
| * | | | checkout: always set the index in checkout dataEdward Thomson2018-06-261-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always set the `index` in the `checkout_data`, even in the case that we are not reloading the index. Other functionality in checkout examines the index (for example: determining whether the workdir is modified) and we need it even in the (uncommon) case that we are not reloading.
| * | | | index::addall tests: write the indexEdward Thomson2018-06-261-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | When running `git_index_add_all`, we should write the index to disk so that we can re-read it safely during status.
| * | | | index::reuc tests: test that checkout succeedsEdward Thomson2018-06-261-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The index::reuc tests must test that the checkout itself succeeds, otherwise subsequent tests are not valid. In fact, the checkouts were failing because when checking out `SAFE`, they cannot update the files that are in conflict. Change the checkout level to `FORCE` to ensure that they get updated correctly.