summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #4484 from pks-t/pks/fail-creating-branch-HEADEdward Thomson2018-01-201-0/+6
|\ | | | | branch: refuse creating branches named 'HEAD'
| * branch: refuse creating branches named 'HEAD'Patrick Steinhardt2018-01-191-0/+6
| | | | | | | | | | | | | | | | Since a625b092c (branch: correctly reject refs/heads/{-dash,HEAD}, 2017-11-14), which is included in v2.16.0, upstream git refuses to create branches which are named HEAD to avoid ambiguity with the symbolic HEAD reference. Adjust our own code to match that behaviour and reject creating branches names HEAD.
* | Merge pull request #4478 from libgit2/cmn/packed-refs-sortedEdward Thomson2018-01-201-1/+1
|\ \ | |/ |/| refs: include " sorted " in our packed-refs header
| * refs: include " sorted " in our packed-refs headercmn/packed-refs-sortedCarlos Martín Nieto2018-01-121-1/+1
| | | | | | | | | | | | | | This lets git know that we do in fact have written our packed-refs file sorted (which is apparently not necessarily the case) and it can then use the new-ish mmaped access which lets it avoid significant amounts of effort parsing potentially large files to get to a single piece of data.
* | Merge pull request #4451 from libgit2/charliesome/trailer-infoBrian Lopez2018-01-171-0/+416
|\ \ | | | | | | Implement message trailer parsing API
| * | rename find_trailer to extract_trailer_blockcharliesome/trailer-infoBrian Lopez2018-01-171-2/+2
| | |
| * | Change trailer API to return a simple arrayBrian Lopez2018-01-161-5/+19
| | |
| * | Merge remote-tracking branch 'origin/master' into charliesome/trailer-infoBrian Lopez2018-01-109-54/+99
| |\ \ | | |/
| * | make separators const a macro as wellBrian Lopez2018-01-031-5/+4
| | |
| * | make comment_line_char const a macroBrian Lopez2018-01-031-4/+4
| | |
| * | Merge remote-tracking branch 'origin/master' into charliesome/trailer-infoBrian Lopez2018-01-0228-399/+563
| |\ \
| * | | trailer: use git__prefixcmp instead of starts_withCharlie Somerville2017-12-201-15/+3
| | | |
| * | | trailer: remove inline specifier on is_blank_lineCharlie Somerville2017-12-201-1/+1
| | | |
| * | | message: add routine for parsing trailers from messagesCharlie Somerville2017-12-191-0/+415
| | | | | | | | | | | | | | | | | | | | This is implemented in trailer.c and borrows a large amount of logic from Git core to ensure compatibility.
* | | | transports: local: fix memory leak in reference walkPatrick Steinhardt2018-01-121-0/+2
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | Upon downloading the pack file, the local transport will iterate through every reference using `git_reference_foreach`. The function is a bit tricky though in that it requires the passed callback to free the references, which does not currently happen. Fix the memory leak by freeing all passed references in the callback.
* | | cmake: add openssl to the private deps list when it's the TLS implementationCarlos Martín Nieto2018-01-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We might want OpenSSL to be the implementation for SHA-1 and/or TLS. If we only want it for TLS (e.g. we're building with the collision-detecting SHA-1 implementation) then we did not indicate this to the systems including us a static library. Add OpenSSL to the list also during the TLS decision to make sure we say we should link to it if we use it for TLS.
* | | cmake: treat LIBGIT2_PC_REQUIRES as a listCarlos Martín Nieto2018-01-081-2/+5
| | | | | | | | | | | | | | | | | | It is indeed a list of dependencies for those which include the static archive. This is in preparation for adding two possible places where we might add openssl as a dependency.
* | | Merge pull request #4398 from pks-t/pks/generic-sha1Edward Thomson2018-01-051-20/+26
|\ \ \ | | | | | | | | cmake: allow explicitly choosing SHA1 backend
| * | | cmake: allow explicitly choosing SHA1 backendPatrick Steinhardt2018-01-041-20/+26
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | Right now, if SHA1DC is disabled, the SHA1 backend is mostly chosen based on which system libgit2 is being compiled on and which libraries have been found. To give developers and distributions more choice, enable them to request specific backends by passing in a `-DSHA1_BACKEND=<BACKEND>` option instead. This completely replaces the previous auto-selection.
* | | Merge pull request #4437 from pks-t/pks/openssl-hash-errorsEdward Thomson2018-01-032-8/+31
|\ \ \ | | | | | | | | hash: openssl: check return values of SHA1_* functions
| * | | streams: openssl: fix thread-safety for OpenSSL error messagesPatrick Steinhardt2018-01-031-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `ERR_error_string` can be invoked without providing a buffer, in which case OpenSSL will simply return a string printed into a static buffer. Obviously and as documented in ERR_error_string(3), this is not thread-safe at all. As libgit2 is a library, though, it is easily possible that other threads may be using OpenSSL at the same time, which might lead to clobbered error strings. Fix the issue by instead using a stack-allocated buffer. According to the documentation, the caller has to provide a buffer of at least 256 bytes of size. While we do so, make sure that the buffer will never get overflown by switching to `ERR_error_string_n` to specify the buffer's size.
| * | | hash: openssl: check return values of SHA1_* functionsPatrick Steinhardt2018-01-031-3/+18
| | |/ | |/| | | | | | | | | | | | | The OpenSSL functions `SHA1_Init`, `SHA1_Update` and `SHA1_Final` all return 1 for success and 0 otherwise, but we never check their return values. Do so.
* | | Merge pull request #4462 from pks-t/pks/diff-generated-excessive-statsEdward Thomson2018-01-035-10/+20
|\ \ \ | | | | | | | | diff_generate: avoid excessive stats of .gitattribute files
| * | | diff_generate: avoid excessive stats of .gitattribute filesPatrick Steinhardt2018-01-035-10/+20
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generating a diff between two trees, for each file that is to be diffed we have to determine whether it shall be treated as text or as binary files. While git has heuristics to determine which kind of diff to generate, users can also that default behaviour by setting or unsetting the 'diff' attribute for specific files. Because of that, we have to query gitattributes in order to determine how to diff the current files. Instead of hitting the '.gitattributes' file every time we need to query an attribute, which can get expensive especially on networked file systems, we try to cache them instead. This works perfectly fine for every '.gitattributes' file that is found, but we hit cache invalidation problems when we determine that an attribuse file is _not_ existing. We do create an entry in the cache for missing '.gitattributes' files, but as soon as we hit that file again we invalidate it and stat it again to see if it has now appeared. In the case of diffing large trees with each other, this behaviour is very suboptimal. For each pair of files that is to be diffed, we will repeatedly query every directory component leading towards their respective location for an attributes file. This leads to thousands or even hundreds of thousands of wasted syscalls. The attributes cache already has a mechanism to help in that scenario in form of the `git_attr_session`. As long as the same attributes session is still active, we will not try to re-query the gitmodules files at all but simply retain our currently cached results. To fix our problem, we can create a session at the top-most level, which is the initialization of the `git_diff` structure, and use it in order to look up the correct diff driver. As the `git_diff` structure is used to generate patches for multiple files at once, this neatly solves our problem by retaining the session until patches for all files have been generated. The fix has been tested with linux.git by calling `git_diff_tree_to_tree` and `git_diff_to_buf` with v4.10^{tree} and v4.14^{tree}. | time | .gitattributes stats without fix | 33.201s | 844614 with fix | 30.327s | 4441 While execution only improved by roughly 10%, the stat(3) syscalls for .gitattributes files decreased by 99.5%. The benchmarks were quite simple with best-of-three timings on Linux ext4 systems. One can assume that for network based file systems the performance gain will be a lot larger due to a much higher latency.
* | | Merge pull request #4439 from tiennou/fix/4352Patrick Steinhardt2018-01-031-5/+7
|\ \ \ | | | | | | | | cmake: create a dummy file for Xcode
| * | | cmake: create a dummy file for XcodeEtienne Samson2017-12-141-5/+7
| | |/ | |/| | | | Otherwise Xcode will happily not-link our git2 target, resulting in a "missing file" error when building eg. examples
* | | Merge pull request #4457 from libgit2/ethomson/tree_error_messagesPatrick Steinhardt2018-01-031-10/+10
|\ \ \ | |_|/ |/| | tree: standard error messages are lowercase
| * | tree: standard error messages are lowercaseethomson/tree_error_messagesEdward Thomson2017-12-311-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | Our standard error messages begin with a lower case letter so that they can be prefixed or embedded nicely. These error messages were missed during the standardization pass since they use the `tree_error` helper function.
* | | Merge pull request #4453 from libgit2/ethomson/spnegoEdward Thomson2018-01-011-4/+13
|\ \ \ | |/ / |/| | winhttp: properly support ntlm and negotiate
| * | winhttp: properly support ntlm and negotiateethomson/spnegoEdward Thomson2017-12-291-4/+13
| | | | | | | | | | | | | | | | | | | | | When parsing unauthorized responses, properly parse headers looking for both NTLM and Negotiate challenges. Set the HTTP credentials to default credentials (using a `NULL` username and password) with the schemes supported by ourselves and the server.
* | | Merge pull request #4159 from richardipsum/notes-commitEdward Thomson2017-12-301-48/+164
|\ \ \ | | | | | | | | Support using notes via a commit rather than a ref
| * | | notes: Rewrite funcs in terms of note_commit funcsRichard Ipsum2017-12-021-81/+86
| | | |
| * | | notes: Add git_note_commit_iterator_newRichard Ipsum2017-10-071-0/+19
| | | | | | | | | | | | | | | | This also adds tests for this function.
| * | | notes: Add git_note_commit_removeRichard Ipsum2017-10-071-2/+35
| | | | | | | | | | | | | | | | This also adds tests for this function.
| * | | notes: Add git_note_commit_readRichard Ipsum2017-10-071-0/+22
| | | | | | | | | | | | | | | | This also adds tests for this function.
| * | | notes: Add git_note_commit_createRichard Ipsum2017-10-071-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new function that will allow creation of notes without necessarily updating a particular ref, the notes tree is obtained from the git_commit object parameter, a new commit object pointing to the current tip of the notes tree is optionally returned via the 'note_commit_out' parameter, optionally the blob id for the note is returned through the 'note_blob_out' object.
| * | | notes: Make note_write return commit oidRichard Ipsum2017-09-231-4/+10
| | | | | | | | | | | | | | | | | | | | For the new 'commit' API it will be necessary to know the OID of the notes commit that was written as well as the OID of the notes blob.
* | | | Merge pull request #4028 from chescock/improve-local-fetchEdward Thomson2017-12-303-175/+25
|\ \ \ \ | | | | | | | | | | Transfer fewer objects on push and local fetch
| * | | | Use git_packbuilder_insert_walk in queue_objects.Chris Hescock2016-12-201-169/+2
| | | | |
| * | | | Don't fetch objects we don't need in local transport.Chris Hescock2016-12-202-6/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Hide all local refs in the revwalk. Packbuilder should not add hidden trees or blobs.
* | | | | Merge pull request #4455 from libgit2/ethomson/branch_symlinksEdward Thomson2017-12-303-1/+39
|\ \ \ \ \ | | | | | | | | | | | | refs: traverse symlinked directories
| * | | | | iterator: cleanups with symlink dir handlingEdward Thomson2017-12-303-17/+32
| | | | | | | | | | | | | | | | | | | | | | | | Perform some error checking when examining symlink directories.
| * | | | | branches: Check symlinked subdirectoriesAndy Doan2017-12-293-1/+24
| | |_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Native Git allows symlinked directories under .git/refs. This change allows libgit2 to also look for references that live under symlinked directories. Signed-off-by: Andy Doan <andy@opensourcefoundries.com>
* | | | | Merge pull request #4443 from libgit2/ethomson/large_loose_blobsEdward Thomson2017-12-308-136/+196
|\ \ \ \ \ | |/ / / / |/| | | | Inflate large loose blobs
| * | | | hash: commoncrypto hash should support large filesEdward Thomson2017-12-201-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Teach the CommonCrypto hash mechanisms to support large files. The hash primitives take a `CC_LONG` (aka `uint32_t`) at a time. So loop to give the hash function at most an unsigned 32 bit's worth of bytes until we have hashed the entire file.
| * | | | hash: win32 hash mechanism should support large filesEdward Thomson2017-12-201-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Teach the win32 hash mechanisms to support large files. The hash primitives take at most `ULONG_MAX` bytes at a time. Loop, giving the hash function the maximum supported number of bytes, until we have hashed the entire file.
| * | | | odb_loose: reject objects that cannot fit in memoryEdward Thomson2017-12-201-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check the size of objects being read from the loose odb backend and reject those that would not fit in memory with an error message that reflects the actual problem, instead of error'ing later with an unintuitive error message regarding truncation or invalid hashes.
| * | | | zstream: use UINT_MAX sized chunksEdward Thomson2017-12-201-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of paging to zlib in INT_MAX sized chunks, we can give it as many as UINT_MAX bytes at a time. zlib doesn't care how big a buffer we give it, this simply results in fewer calls into zlib.
| * | | | odb: support large loose objectsEdward Thomson2017-12-201-98/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | zlib will only inflate/deflate an `int`s worth of data at a time. We need to loop through large files in order to ensure that we inflate the entire file, not just an `int`s worth of data. Thankfully, we already have this loop in our `git_zstream` layer. Handle large objects using the `git_zstream`.
| * | | | object: introduce git_object_stringn2typeEdward Thomson2017-12-202-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an internal API to get the object type based on a length-specified (not null terminated) string representation. This can be used to compare the (space terminated) object type name in a loose object. Reimplement `git_object_string2type` based on this API.