summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* tree: plug leaks in the tree updatercmn/tree-update-basenameCarlos Martín Nieto2016-05-191-3/+11
|
* tree: use the basename for the entry removalCarlos Martín Nieto2016-05-191-1/+1
| | | | | | When we want to remove the file, use the basename as the name of the entry to remove, instead of the full one, which includes the directories we've inserted into the stack.
* Introduce a function to create a tree based on a different onecmn/tree-updateCarlos Martín Nieto2016-05-171-0/+245
| | | | | | | | | | | Instead of going through the usual steps of reading a tree recursively into an index, modifying it and writing it back out as a tree, introduce a function to perform simple updates more efficiently. `git_tree_create_updated` avoids reading trees which are not modified and supports upsert and delete operations. It is not as versatile as modifying the index, but it makes some common operations much more efficient.
* Merge pull request #3767 from pks-t/pks/misc-fixesEdward Thomson2016-05-096-23/+21
|\ | | | | Misc fixes
| * diff: simplify code for handling empty dirsPatrick Steinhardt2016-05-031-10/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When determining diffs between two iterators we may need to recurse into an unmatched directory for the "new" iterator when it is either a prefix to the current item of the "old" iterator or when untracked/ignored changes are requested by the user and the directory is untracked/ignored. When advancing into the directory and no files are found, we will get back `GIT_ENOTFOUND`. If so, we simply skip the directory, handling resulting unmatched old items in the next iteration. The other case of `iterator_advance_into` returning either `GIT_NOERROR` or any other error but `GIT_ENOTFOUND` will be handled by the caller, which will now either compare the first directory entry of the "new" iterator in case of `GIT_ENOERROR` or abort on other cases. Improve readability of the code to make the above logic more clear.
| * delta-apply: fix sign extensionPatrick Steinhardt2016-05-021-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We compute offsets by executing `off |= (*delta++ << 24)` for multiple constants, where `off` is of type `size_t` and `delta` is of type `unsigned char`. The usual arithmetic conversions (see ISO C89 §3.2.1.5 "Usual arithmetic conversions") kick in here, causing us to promote both operands to `int` and then extending the result to an `unsigned long` when OR'ing it with `off`. The integer promotion to `int` may result in wrong size calculations for big values. Fix the issue by making the constants `unsigned long`, causing both operands to be promoted to `unsigned long`.
| * odb_loose: fix undefined behavior when computing sizePatrick Steinhardt2016-05-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An object's size is computed by reading the object header's size field until the most significant bit is not set anymore. To get the total size, we increase the shift on each iteration and add the shifted value to the total size. We read the current value into a variable of type `unsigned char`, from which we then take all bits except the most significant bit and shift the result. We will end up with a maximum shift of 60, but this exceeds the width of the value's type, resulting in undefined behavior. Fix the issue by instead reading the values into a variable of type `unsigned long`, which matches the required width. This is equivalent to git.git, which uses an `unsigned long` as well.
| * checkout: set ignorecase=0 when config lookup failsPatrick Steinhardt2016-05-021-2/+4
| | | | | | | | | | | | | | | | | | | | When `git_repository__cvar` fails we may end up with a `ignorecase` value of `-1`. As we subsequently check if `ignorecase` is non-zero, we may end up reporting that data should be removed when in fact it should not. Err on the safer side and set `ignorecase = 0` when `git_repository__cvar` fails.
| * merge_file: do not unnecessarily check ours/theirs for NULLPatrick Steinhardt2016-05-021-4/+4
| | | | | | | | | | | | | | | | | | The `merge_file__xdiff` function checks if either `ours` or `theirs` is `NULL`. The function is to be called with existing files, though, and in fact already unconditionally dereferences both pointers. Remove the unnecessary check to silence warnings.
| * index: fix memory leak on error casePatrick Steinhardt2016-05-021-1/+1
| |
* | Merge pull request #3773 from lucasderraugh/patch-1Edward Thomson2016-05-081-0/+1
|\ \ | | | | | | Fix unused variable 'message' warning
| * | Fix unused variable 'message' warningLucas Derraugh2016-05-051-0/+1
| | |
* | | Merge pull request #3757 from johnhaley81/jh/fix-create-initial-commitCarlos Martín Nieto2016-05-061-1/+1
|\ \ \ | |/ / |/| | Fix `git_commit_create` for an initial commit
| * | Fix `git_commit_create` for an initial commitJohn Haley2016-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | When calling `git_commit_create` with an empty array of `parents` and `parent_count == 0` the call will segfault at https://github.com/libgit2/libgit2/blob/master/src/commit.c#L107 when it's trying to compare `current_id` to a null parent oid. This just puts in a check to stop that segfault.
* | | rebase: handle no common ancestor for inmemoryethomson/rebase_inmemory_no_baseEdward Thomson2016-05-031-4/+15
|/ /
* | Merge pull request #3759 from libgit2/cmn/faster-headerEdward Thomson2016-05-023-6/+48
|\ \ | |/ |/| odb: avoid inflating the full delta to read the header
| * odb: avoid inflating the full delta to read the headercmn/faster-headerCarlos Martín Nieto2016-05-023-6/+48
| | | | | | | | | | | | | | | | | | | | When we read the header, we want to know the size and type of the object. We're currently inflating the full delta in order to read the first few bytes. This can mean hundreds of kB needlessly inflated for large objects. Instead use a packfile stream to read just enough so we can read the two varints in the header and avoid inflating most of the delta.
* | Merge pull request #3763 from libgit2/ethomson/signature_from_bufferCarlos Martín Nieto2016-04-291-1/+26
|\ \ | | | | | | Introduce `git_signature_from_buffer`
| * | Introduce `git_signature_from_buffer`ethomson/signature_from_bufferEdward Thomson2016-04-281-1/+26
| |/ | | | | | | | | Allow users to construct a signature from the type of signature lines that actually appear in commits.
* | Merge pull request #3760 from backhub/bug/openssl_readEdward Thomson2016-04-281-1/+1
|\ \ | |/ |/| Fix return value of openssl_read (infinite loop)
| * Fix style: no bracesChristian Schlack2016-04-271-2/+1
| |
| * Fix return value of openssl_read (infinite loop)Christian Schlack2016-04-261-2/+3
| | | | | | | | | | | | | | | | | | | | openssl_read should return -1 in case of error. SSL_read returns values <= 0 in case of error. A return value of 0 can lead to an infinite loop, so the return value of ssl_set_error will be returned if SSL_read is not successful (analog to openssl_write).
* | annotated_commit: provide refs and descriptionethomson/annotated_commit_refsEdward Thomson2016-04-265-85/+108
|/ | | | | | | | | | | Differentiate between the ref_name used to create an annotated_commit (that can subsequently be used to look up the reference) and the description that we resolved this with (which _cannot_ be looked up). The description is used for things like reflogs (and may be a ref name, and ID something that we revparsed to get here), while the ref name must actually be a reference name, and is used for things like rebase to return to the initial branch.
* Merge pull request #3749 from arthurschreiber/arthur/add-git-reference-dupCarlos Martín Nieto2016-04-261-1/+13
|\ | | | | Allow creating copies of `git_reference` objects.
| * Allow creating copies of `git_reference` objects.Arthur Schreiber2016-04-221-1/+13
| |
* | Merge pull request #3748 from libgit2/ethomson/rebase_detachedCarlos Martín Nieto2016-04-261-27/+46
|\ \ | | | | | | Rebase improvements with IDs
| * | rebase: correctly finish rebasing detached headsethomson/rebase_detachedEdward Thomson2016-04-211-24/+35
| | | | | | | | | | | | | | | When rebasing with IDs, we do not return to the `branch`, we remain in a detached HEAD state.
| * | rebase: handle detached HEADs in `init`Edward Thomson2016-04-211-3/+11
| |/ | | | | | | | | | | When `init`ing a rebase from a detached HEAD, be sure to remember that we were in a detached HEAD state so that we can correctly `abort` the object that we just created.
* | tag: ignore extra header fieldscmn/silly-tagsCarlos Martín Nieto2016-04-251-2/+8
| | | | | | | | | | | | | | While no extra header fields are defined for tags, git accepts them by ignoring them and continuing the search for the message. There are a few tags like this in the wild which git parses just fine, so we should do the same.
* | transport: cast away constness for freeEdward Thomson2016-04-211-1/+1
| |
* | stransport: pass proxy opts instead of char*Edward Thomson2016-04-211-2/+4
| |
* | iterator: ignore submodule in has_endedEdward Thomson2016-04-211-4/+3
|/
* Merge pull request #3110 from libgit2/cmn/proxy-configEdward Thomson2016-04-1913-48/+345
|\ | | | | Proxy configuration
| * proxy: don't specify the protocol in the typeCarlos Martín Nieto2016-04-192-2/+2
| | | | | | | | | | | | We leave this up to the scheme in the url field. The type should only tell us about whether we want a proxy and whether we want to auto-detect it.
| * winhttp: correctly detect HTTPS usageCarlos Martín Nieto2016-04-191-2/+14
| |
| * curl: ask for proxy credentialsCarlos Martín Nieto2016-04-191-4/+81
| |
| * net: use proxy options struct in the stream configCarlos Martín Nieto2016-04-194-15/+44
| |
| * proxy: don't require the trailing slash on WinHTTPCarlos Martín Nieto2016-04-191-1/+2
| | | | | | | | | | The path is not something that you use for proxies, so make use of the new optionality of the path when extracting URL parts.
| * netops: make the path optional in URLsCarlos Martín Nieto2016-04-191-10/+12
| | | | | | | | | | | | When we're dealing with proxy addresses, we only want a hostname and port, and the user would not provide a path, so make it optional so we can use this same function to parse git as well as proxy URLs.
| * proxy: use poxy to test our Windows proxy supportCarlos Martín Nieto2016-04-191-0/+1
| |
| * proxy: ask the user for credentials if necessaryCarlos Martín Nieto2016-04-198-19/+178
| |
| * proxy: introduce a proxy options structCarlos Martín Nieto2016-04-191-0/+16
| | | | | | | | It is currently unused; it will go into the remote's options.
* | ignore: move star-star matching closer to it usecmn/ignore-starstarCarlos Martín Nieto2016-04-191-16/+11
| | | | | | | | | | Instead of threading the state down to the larger loop, let's have the loop where we detect the double star so each of them are easier to read.
* | ignore: fix directory limits when searching for star-starCarlos Martín Nieto2016-04-191-6/+24
|/ | | | | | | | | | | | In order to match the star-star, we disable the flag that's looking for a single path element, but that leads to searching for the pattern in the middle of elements in the input string. Mark when we're handing a star-star so we jump over the elements in our attempt to match the part of the pattern that comes after the star-star. While here, tighten up the check so we don't allow invalid rules through.
* refs: provide a more general error message for dwimcmn/dwim-general-messageCarlos Martín Nieto2016-04-111-0/+3
| | | | | | | If we cannot dwim the input, set the error message to be explicit about that. Otherwise we leave the error for the last failed lookup, which can be rather unexpected as it mentions a remote when the user thought they were trying to look up a branch.
* Merge pull request #3724 from ethomson/submodule_start_supports_silly_slashesCarlos Martín Nieto2016-04-021-10/+26
|\ | | | | iterator/diff: allow trailing `/` on start/end paths to match submodules
| * iterator: support trailing `/` in start for submodEdward Thomson2016-04-021-10/+26
| | | | | | | | | | | | Allow callers to specify a start path with a trailing slash to match a submodule, instead of just a directory. This is for some legacy behavior that's sort of dumb, but there it is.
* | ignore: don't use realpath to canonicalize pathcmn/ignore-symlinkCarlos Martín Nieto2016-04-021-3/+11
|/ | | | | | If we're looking for a symlink, realpath will give us the resolved path, which is not what we're after, but a canonicalized version of the path the user asked for.
* Merge pull request #3720 from pks-t/pks/merge-driver-memleaksCarlos Martín Nieto2016-04-011-0/+1
|\ | | | | merge_driver: fix missing `goto done;`
| * merge_driver: fix missing `goto done;`Patrick Steinhardt2016-04-011-0/+1
| | | | | | | | | | | | | | | | | | | | The code initializing the merge driver registry accidentally forgot a `goto done` in case of an error. Because of this the next line, which registers the global shutdown callback for the merge drivers, is only called when an error occured. Fix this by adding the missing `goto done`. This fixes some memory leaks when the global state is shut down.