summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* blob: identify binary contentethomson/blob_data_is_binaryEdward Thomson2021-12-101-0/+9
| | | | | Introduce `git_blob_data_is_binary` to examine a blob's data, instead of the blob itself. A replacement for `git_buf_is_binary`.
* object: introduce a raw content validation functionethomson/object_validationEdward Thomson2021-11-301-0/+32
| | | | | Users may want to validate raw object content; provide them a function to do so.
* object: return GIT_EINVALID on parse errorsEdward Thomson2021-11-307-38/+68
| | | | | | | | | | | | | | Return `GIT_EINVALID` on parse errors so that direct callers of parse functions can determine when there was a failure to parse the object. The object parser functions will swallow this error code to prevent it from propagating down the chain to end-users. (`git_merge` should not return `GIT_EINVALID` when a commit it tries to look up is not valid, this would be too vague to be useful.) The only public function that this affects is `git_signature_from_buffer`, which is now documented as returning `GIT_EINVALID` when appropriate.
* Merge pull request #6122 from libgit2/ethomson/cleanupEdward Thomson2021-11-3013-33/+24
|\ | | | | Minor code cleanups
| * cmake: use CMAKE_SOURCE_DIR and CMAKE_BINARY_DIRethomson/cleanupEdward Thomson2021-11-221-13/+13
| | | | | | | | | | | | Instead of using the project-specific `libgit2_SOURCE_DIR` and `libgit2_BINARY_DIR` variables, use `CMAKE_SOURCE_DIR` and `CMAKE_BINARY_DIR`.
| * filebuf: use hashes not oidsEdward Thomson2021-11-224-6/+6
| | | | | | | | | | The filebuf functions should use hashes directly, not indirectly using the oid functions.
| * util: don't include unnecessary system librariesEdward Thomson2021-11-228-14/+5
| | | | | | | | Remove some unnecessary includes from utility code.
* | Merge pull request #6106 from ammgws/fixtemplateerrEdward Thomson2021-11-221-1/+6
|\ \ | |/ |/| Fix repo init when template dir is non-existent
| * repo: minor formatting fixEdward Thomson2021-11-221-2/+1
| |
| * repository: do not copy templates if dir nonexistentJason Nader2021-11-121-1/+7
| | | | | | | | | | This mimics the behaviour of git which just prints a warning and continues with the repo initialisation.
* | date: rfc2822 formatting uses a `git_buf` instead of a static stringethomson/dateEdward Thomson2021-11-194-22/+25
| |
* | date: make it a proper `git_date` utility classEdward Thomson2021-11-185-24/+39
| | | | | | | | Instead of `git__date`, just use `git_date`.
* | tag: set validity to 0 by defaultethomson/tag_validEdward Thomson2021-11-161-0/+2
| | | | | | | | | | `git_tag_name_is_valid` needs to set validity to 0 when it short-circuits.
* | Make enum in src,tests and examples C90 compliant by removing trailing comma.Peter Pettersson2021-11-1533-40/+40
| |
* | cmake: move sha1 source selection into CMakeLists.txtEdward Thomson2021-11-141-0/+15
| | | | | | | | | | The select hashes module selects the hash; the CMakeLists.txt selects the files to implement it.
* | cmake: refactor global variablesEdward Thomson2021-11-141-15/+15
| | | | | | | | | | Update the global variables `LIBGIT2_OBJECTS` to `LIBGIT2_DEPENDENCY_OBJECTS` for clarity and consistency.
* | Merge pull request #6116 from ↵Edward Thomson2021-11-141-1/+1
|\ \ | | | | | | | | | lhchavez/drop-volatile-qualifier-in-atomic-exchange
| * | Fix a gcc 11 warning in src/thread.hlhchavez2021-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building under gcc 11, there is a warning about an incompatible pointer type, since [`__atomic_exchange`](https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html) does not take `volatile` pointers: ``` In file included from ../src/common.h:81, from ../src/transports/winhttp.c:8: ../src/thread-utils.h: In function ‘git___swap’: ../src/thread-utils.h:168:9: warning: argument 3 of ‘__atomic_exchange’ discards ‘volatile’ qualifier [-Wincompatible-pointer-types] 168 | __atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST); | ^~~~~~~~~~~~~~~~~ ``` This change drops the `volatile` qualifier so that the pointer type matches what `__atomic_exchange` expects.
* | | Fix a gcc 11 warning in src/threadstate.clhchavez2021-11-141-2/+2
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When building under gcc 11, there is a warning about a misaligned guard clause because there were mixed spaces and tabs: ``` [128/634] Building C object src/CMakeFiles/git2internal.dir/threadstate.c.o ../src/threadstate.c: In function ‘threadstate_dispose’: ../src/threadstate.c:39:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 39 | if (threadstate->error_t.message != git_str__initstr) | ^~ ../src/threadstate.c:41:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 41 | threadstate->error_t.message = NULL; | ^~~~~~~~~~~ ../src/threadstate.c: At top level: ``` This change indents the code with tabs for consistency with the rest of the code, which makes the warning go away.
* | cmake: move missing-declarations warning to top-levelEdward Thomson2021-11-111-2/+0
| | | | | | | | | | We should enforce declarations throughout the code-base, including examples, fuzzers and tests, not just in the `src` tree.
* | Merge pull request #6112 from libgit2/ethomson/cmake3Edward Thomson2021-11-114-174/+30
|\ \ | | | | | | cmake refactorings
| * | cmake: refactor zlib selectionethomson/cmake3Edward Thomson2021-11-111-33/+1
| | | | | | | | | | | | Move zlib selection into its own cmake module.
| * | cmake: refactor WinHTTP selectionEdward Thomson2021-11-111-18/+1
| | | | | | | | | | | | Move WinHTTP selection into its own cmake module.
| * | cmake: refactor libssh2 selectionEdward Thomson2021-11-111-26/+1
| | | | | | | | | | | | Move SSH selection into its own cmake module.
| * | cmake: refactor regex selectionEdward Thomson2021-11-111-52/+1
| | | | | | | | | | | | Move regex selection into its own cmake module.
| * | cmake: refactor http_parser selectionEdward Thomson2021-11-111-20/+2
| | | | | | | | | | | | Move http_parser selection into its own cmake module.
| * | cmake: HTTP_Parser is now HTTPParserEdward Thomson2021-11-111-1/+1
| | |
| * | cmake: qsort detection in features.hEdward Thomson2021-11-113-20/+15
| | |
| * | cmake: move deprecation definition to src/Edward Thomson2021-11-111-0/+4
| | | | | | | | | | | | | | | There's no need to add the deprecation at the top-level. Our tests add deprecation explicitly.
| * | cmake: standardize USE_WINHTTPEdward Thomson2021-11-111-1/+1
| | | | | | | | | | | | | | | WinHTTP can now be disabled with `USE_WINHTTP=OFF` instead of `WINHTTP=OFF` to better support the other cmake semantics.
| * | cmake: standardize USE_THREADS and USE_NSECEdward Thomson2021-11-112-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | Threading can now be disabled with `USE_THREADS=OFF` instead of `THREADSAFE=OFF` to better support the other cmake semantics. Nanosecond support is the default _if_ we can detect it. This should be our default always - like threads - and people can opt out explicitly.
* | | str: git_str_free is never a functionEdward Thomson2021-11-111-7/+0
|/ /
* | Merge pull request #6104 from libgit2/ethomson/pathEdward Thomson2021-11-1144-2813/+3039
|\ \ | | | | | | path: refactor utility path functions
| * | win32: include correct path headerethomson/pathEdward Thomson2021-11-094-4/+4
| | |
| * | fs_path: remove now-unused validation functionsEdward Thomson2021-11-092-68/+0
| | |
| * | fs_path: add length with suffix validationEdward Thomson2021-11-094-3/+30
| | |
| * | path: use new length validation functionsEdward Thomson2021-11-0910-20/+36
| | |
| * | path: length validation respecting core.longpathsEdward Thomson2021-11-092-0/+50
| | | | | | | | | | | | | | | Teach `git_path_is_valid` to respect `core.longpaths`. Add helper methods to validate length and set the error message appropriately.
| * | path: introduce `git_path_str_is_valid`Edward Thomson2021-11-094-11/+21
| | | | | | | | | | | | | | | Add a `git_str` based validity check; the existing `git_path_is_valid` defers to it.
| * | fs_path: add long path validation on windowsEdward Thomson2021-11-093-4/+37
| | |
| * | fs_path: make empty component validation optionalEdward Thomson2021-11-092-2/+8
| | |
| * | fs_path: introduce `str_is_valid`Edward Thomson2021-11-092-19/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provide a mechanism for users to limit the number of characters that are examined; `git_fs_path_str_is_valid` and friends will only examine up to `str->size` bytes. `git_fs_path_is_valid` delegates to these new functions by passing `SIZE_MAX` (instead of doing a `strlen`), which is a sentinel value meaning "look for a NUL terminator".
| * | path: `validate` -> `is_valid`Edward Thomson2021-11-097-9/+9
| | | | | | | | | | | | | | | Since we're returning a boolean about validation, the name is more properly "is valid".
| * | fs_path: `validate` -> `is_valid`Edward Thomson2021-11-093-6/+6
| | | | | | | | | | | | | | | Since we're returning a boolean about validation, the name is more properly "is valid".
| * | path: separate git-specific path functions from utilEdward Thomson2021-11-0944-2822/+2939
| |/ | | | | | | | | | | Introduce `git_fs_path`, which operates on generic filesystem paths. `git_path` will be kept for only git-specific path functionality (for example, checking for `.git` in a path).
* | Support checking for object existence without refreshJosh Triplett2021-11-081-1/+6
|/ | | | | | | | | | | | Looking up a non-existent object currently always invokes `git_odb_refresh`. If looking up a large batch of objects, many of which may legitimately not exist, this will repeatedly refresh the ODB to no avail. Add a `git_odb_exists_ext` that accepts flags controlling the ODB lookup, and add a flag to suppress the refresh. This allows the user to control if and when they refresh (for instance, refreshing once before starting the batch).
* cmake: stylistic refactoringEdward Thomson2021-10-181-283/+285
| | | | | Ensure that we always use lowercase function names, and that we do not have spaces preceding open parentheses, for consistency.
* trace: always enabledEdward Thomson2021-10-184-37/+0
| | | | There's no need to make tracing opt-in; it should always be included.
* str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstrEdward Thomson2021-10-17148-3723/+4231
| | | | | | | | | | | | | | | | | | | | | | | | | | | libgit2 has two distinct requirements that were previously solved by `git_buf`. We require: 1. A general purpose string class that provides a number of utility APIs for manipulating data (eg, concatenating, truncating, etc). 2. A structure that we can use to return strings to callers that they can take ownership of. By using a single class (`git_buf`) for both of these purposes, we have confused the API to the point that refactorings are difficult and reasoning about correctness is also difficult. Move the utility class `git_buf` to be called `git_str`: this represents its general purpose, as an internal string buffer class. The name also is an homage to Junio Hamano ("gitstr"). The public API remains `git_buf`, and has a much smaller footprint. It is generally only used as an "out" param with strict requirements that follow the documentation. (Exceptions exist for some legacy APIs to avoid breaking callers unnecessarily.) Utility functions exist to convert a user-specified `git_buf` to a `git_str` so that we can call internal functions, then converting it back again.
* Merge pull request #6082 from libgit2/ethomson/oidEdward Thomson2021-10-1721-95/+118
|\ | | | | hash: separate hashes and git_oid