summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* fileops: fix leaking fd in `mmap_ro_file`Patrick Steinhardt2017-04-121-3/+7
| | | | | | | When the `git_futils_mmap_ro_file` function encounters an error after the file has been opened, it will do a simple returns. Instead, we should close the opened file descriptor to avoid a leak. This commit fixes the issue.
* Merge pull request #4183 from pks-t/pks/coverityEdward Thomson2017-04-074-18/+23
|\ | | | | Coverity
| * fileops: do not overwrite correct error message on mmapPatrick Steinhardt2017-04-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When executing `git_futils_mmap_ro_file`, we first try to guess whether the file is mmapable at all. Part of this check is whether the file is too large to be mmaped, which can be true on systems with 32 bit `size_t` types. The check is performed by first getting the file size wtih `git_futils_filesize` and then checking whether the returned size can be represented as `size_t`, returning an error if so. While this test also catches the case where the function returned an error (as `-1` is not representable by `size_t`), we will set the misleading error message "file too large to mmap". But in fact, a negative return value from `git_futils_filesize` will be caused by the inability to fstat the file. Fix the error message by handling negative return values separately and not overwriting the error message in that case.
| * blame_git: check return value of `git__calloc`Patrick Steinhardt2017-04-041-3/+4
| | | | | | | | | | | | We do not check the return value of `git__calloc`, which may return `NULL` in out-of-memory situations. Fix the error by using `GITERR_CHECK_ALLOC`.
| * path: short-circuit `git_path_apply_relative` on errorPatrick Steinhardt2017-04-041-2/+2
| | | | | | | | | | | | | | Short-circuit the call to `git_path_resolve_relative` in case `git_buf_joinpath` returns an error. While this does not fix any immediate errors, the resulting code is easier to read and handles potential new error conditions raised by `git_buf_joinpath`.
| * path: handle error returned by `git_buf_joinpath`Patrick Steinhardt2017-04-041-1/+2
| | | | | | | | | | | | | | | | In the `_check_dir_contents` function, we first allocate memory for joining the directory and subdirectory together and afterwards use `git_buf_joinpath`. While this function in fact should not fail as memory is already allocated, err on the safe side and check for returned errors.
| * config_file: handle errors other than OOM while parsing section headersPatrick Steinhardt2017-04-041-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | The current code in `parse_section_header_ext` is only prepared to properly handle out-of-memory conditions for the `git_buf` structure. While very unlikely and probably caused by a programming error, it is also possible to run into error conditions other than out-of-memory previous to reaching the actual parsing loop. In these cases, we will run into undefined behavior as the `rpos` variable is only initialized after these triggerable errors, but we use it in the cleanup-routine. Fix the issue by unifying the function's cleanup code with an `end_error` section, which will not use the `rpos` variable.
* | Merge pull request #4193 from pks-t/pks/libdirEdward Thomson2017-04-071-2/+2
|\ \ | | | | | | pkgconfig: fix handling of prefixes containing whitespaces
| * | pkgconfig: fix handling of prefixes containing whitespacesPatrick Steinhardt2017-04-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our libgit2.pc.in file is quoting the `libdir` variable in our declared "Libs:" line. The intention is to handle whitespaces here, but pkgconfig already does so by automatically escaping whitespace with backslashes. The correct thing to do is to instead quote the prefix, as this is the one which is being substituted by CMake upon installation. As both libdir and includedir will be expanded to "${prefix}/lib" and "${prefix}/include", respectively, pkgconfig will also correctly escape whitespaces. Note that this will actually break when a user manually wants to override libdir and includedir with a path containing whitespace. But actually, this cannot be helped, as always quoting these variables will actuall break the common case of being prefixed with "${prefix}". So we just bail out here and declare this as unsupported out of the box.
* | | Merge pull request #4188 from rcjsuen/patch-1Edward Thomson2017-04-031-2/+2
|\ \ \ | |/ / |/| | Correct non-existent file references in `odb.h`
| * | Correct typos that reference a non-existing fileRemy Suen2017-04-031-2/+2
|/ / | | | | | | | | There are references to odb_backends.h when the file is actually named odb_backend.h and in the sys folder.
* | Merge pull request #4182 from pks-t/pks/treebuilderEdward Thomson2017-03-281-11/+13
|\ \ | |/ |/| git_treebuilder_write_with_buffer refactorings
| * treebuilder: exit early if running OOM in `write_with_buffer`Patrick Steinhardt2017-03-281-3/+4
| | | | | | | | | | | | | | | | | | | | 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.
| * treebuilder: remove shadowing variable in `write_with_buffer`Patrick Steinhardt2017-03-281-1/+1
| | | | | | | | | | | | 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.
| * treebuilder: fix memory leaks in `write_with_buffer`Patrick Steinhardt2017-03-281-7/+8
|/ | | | | | | 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.
* Merge pull request #4180 from pks-t/pks/pass-blame-fixPatrick Steinhardt2017-03-282-3/+1
|\ | | | | Fix memory leaks
| * worktree: unconditionally free the worktree's namePatrick Steinhardt2017-03-241-2/+1
| |
| * blame_git: remove spuriuous gotoPatrick Steinhardt2017-03-241-1/+0
|/ | | | | | 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.
* Merge pull request #4175 from libgit2/ethomson/dont_trunc_and_exclPatrick Steinhardt2017-03-241-2/+2
|\ | | | | git_futils: don't O_EXCL and O_TRUNC
| * git_futils: don't O_EXCL and O_TRUNCethomson/dont_trunc_and_exclEdward Thomson2017-03-221-2/+2
| | | | | | | | | | | | `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`.
* | Merge pull request #4178 from libgit2/ethomson/enfasten_sha1Carlos Martín Nieto2017-03-235-230/+887
|\ \ | | | | | | sha1dc: perf improvements from upstream
| * | sha1dc: `SHA1DCUpdate` now takes a `size_t`ethomson/enfasten_sha1Edward Thomson2017-03-231-11/+1
| | |
| * | sha1dc: perf improvements from upstreamEdward Thomson2017-03-234-219/+886
| | | | | | | | | | | | | | | Update SHA-1 collision detection code (cr-marcstevens/sha1collisiondetection) to master to include performance improvements.
* | | Merge branch 'pr/3957'Edward Thomson2017-03-231-0/+20
|\ \ \
| * | | merge: indentation fixupEdward Thomson2017-03-231-1/+1
| | | |
| * | | Perf: Don't perform merge operations for trivial merges.Arthur Schreiber2016-10-181-0/+20
| | | | | | | | | | | | | | | | When one side of a merge is treesame to the ancestor, we can take the other side and skip all the expensive merge operations. This optimization can only be performed when the generation of REUC extension data is skipped.
* | | | Merge pull request #4176 from libgit2/ethomson/3872Edward Thomson2017-03-231-4/+1
|\ \ \ \ | |_|/ / |/| | | inet_pton: don't assume addr families don't exist
| * | | inet_pton: don't assume addr families don't existethomson/3872Edward Thomson2017-03-221-4/+1
| | |/ | |/| | | | | | | | | | Address family 5 might exist on some crazy system like Haiku. Use `INT_MAX-1` as an unsupported address family.
* | | Merge pull request #4163 from pks-t/pks/submodules-with-worktreesEdward Thomson2017-03-2210-135/+300
|\ \ \ | | | | | | | | Worktree fixes
| * | | submodule: resolve URLs relative to main worktreePatrick Steinhardt2017-03-173-9/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is possible to specify submodule URLs relative to the repository location. E.g. having a submodule with URL "../submodule" will look for the submodule at "repo/../submodule". With the introduction of worktrees, though, we cannot simply resolve the URL relative to the repository location itself. If the repository for which a URL is to be resolved is a working tree, we have to resolve the URL relative to the parent's repository path. Otherwise, the URL would change depending on where the working tree is located. Fix this by special-casing when we have a working tree while getting the URL base.
| * | | refdb: create references in commondirPatrick Steinhardt2017-03-172-2/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | References for a repository are usually created inside of its gitdir. When using worktrees, though, these references are not to be created inside the worktree gitdir, but instead inside the gitdir of its parent repository, which is the commondir. Like this, branches will still be available after the worktree itself has been deleted. The filesystem refdb currently still creates new references inside of the gitdir. Fix this and have it create references in commondir.
| * | | worktree: write resolved paths into link filesPatrick Steinhardt2017-03-172-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The three link files "worktree/.git", ".git/worktrees/<name>/commondir" and ".git/worktrees/<name>/gitdir" should always contain absolute and resolved paths. Adjust the logic creating new worktrees to first use `git_path_prettify_dir` before writing out these files, so that paths are resolved first.
| * | | worktree: rename variable in `git_worktree_add`Patrick Steinhardt2017-03-171-13/+13
| | | |
| * | | worktree: use fully qualified reference name for created HEADPatrick Steinhardt2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a new worktree, we have to set up the initial data structures. Next to others, this also includes the HEAD pseudo-ref. We currently set it to the worktree respectively branch name, which is actually not fully qualified. Use the fully qualified branch name instead.
| * | | worktree: parent path should point to the working dirPatrick Steinhardt2017-03-173-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The working tree's parent path should not point to the parent's gitdir, but to the parent's working directory. Pointing to the gitdir would not make any sense, as the parent's working directory is actually equal to both repository's common directory. Fix the issue.
| * | | worktree: implement `git_worktree_open_from_repository`Patrick Steinhardt2017-03-173-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we already provide functionality to look up a worktree from a repository, we cannot do so the other way round. That is given a repository, we want to look up its worktree if it actually exists. Getting the worktree of a repository is useful when we want to get certain meta information like the parent's location, getting the locked status, etc.
| * | | worktree: split off function opening working directoryPatrick Steinhardt2017-03-171-17/+38
| | | | | | | | | | | | | | | | | | | | | | | | Separate the logic of finding the worktree directory of a repository and actually opening the working tree's directory. This is a preparatory step for opening the worktree structure of a repository itself.
| * | | worktree: have `is_worktree_dir` accept a string instead of bufferPatrick Steinhardt2017-03-171-7/+16
| | | | | | | | | | | | | | | | | | | | This will be used in later commits, where it becomes cumbersome to always pass in a buffer.
| * | | tests: worktree: use joinpath instead of printf to join pathsPatrick Steinhardt2017-03-151-1/+1
| | | |
| * | | tests: worktree: unify init/cleanup in open testsPatrick Steinhardt2017-03-151-26/+14
| | | |
| * | | tests: worktree: unify init/cleanup in submodule testsPatrick Steinhardt2017-03-151-39/+29
| | | |
| * | | tests: worktree: move submodule tests into own suitePatrick Steinhardt2017-03-152-65/+69
| | | |
* | | | Merge pull request #4030 from libgit2/ethomson/fsyncEdward Thomson2017-03-2228-44/+426
|\ \ \ \ | | | | | | | | | | fsync all the things
| * | | | Honor `core.fsyncObjectFiles`ethomson/fsyncEdward Thomson2017-03-0213-55/+173
| | | | |
| * | | | win32: don't fsync parent directories on WindowsEdward Thomson2017-02-283-3/+28
| | | | | | | | | | | | | | | | | | | | Windows doesn't support it.
| * | | | fsync: call it "synchronous" object writingEdward Thomson2017-02-2810-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | Rename `GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION` -> `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`.
| * | | | fsync parent directories when fsyncingEdward Thomson2017-02-286-5/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When fsync'ing files, fsync the parent directory in the case where we rename a file into place, or create a new file, to ensure that the directory entry is flushed correctly.
| * | | | git_futils_writebuffer: default only when flags==0Edward Thomson2017-02-282-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | Only use defaults for `git_futils_writebuffer` when flags == 0, lest (1 << 31) be treated as the defaults.
| * | | | refdb_fs: optionally fsync packed refsEdward Thomson2017-02-282-2/+20
| | | | |
| * | | | refdb_fs: optionally fsync loose referencesEdward Thomson2017-02-282-4/+40
| | | | |