summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* ignore: skip UTF8 BOM in ignore fileethomson/ignore_skip_bomEdward Thomson2019-05-191-1/+12
|
* ignore: test we can handle an ignore file with BOMEdward Thomson2019-05-191-0/+23
| | | | Ensure that we can read and parse an ignore file with a UTF8 BOM.
* Merge branch 'pr/5061'Edward Thomson2019-05-122-1/+26
|\
| * revwalk: update error message for clarityEdward Thomson2019-05-121-1/+1
| |
| * revwalk: fix memory leak in error handlingHeiko Voigt2019-05-102-1/+11
| | | | | | | | | | This is not implemented and should fail, but it should also not leak. To allow the memory debugger to find leaks and fix this one we test this.
| * git_revwalk_push_range: do not crash if range is missingHeiko Voigt2019-05-032-0/+15
| | | | | | | | | | If someone passes just one ref (i.e. "master") and misses passing the range we should be nice and return an error code instead of crashing.
* | Merge pull request #5065 from danielgindi/feature/win32_symlink_dirEdward Thomson2019-05-121-2/+7
|\ \ | | | | | | Support symlinks for directories in win32
| * | Moved dwFlags declaration to beginning of scopeDaniel Cohen Gindi2019-05-061-1/+2
| | |
| * | Support symlinks for directories in win32Daniel Cohen Gindi2019-05-051-2/+6
| | |
* | | Merge pull request #5057 from eaigner/merge-rebase-onto-nameEdward Thomson2019-05-123-0/+54
|\ \ \ | |/ / |/| | rebase: orig_head and onto accessors
| * | rebase: orig_head and onto accessorsErik Aigner2019-04-213-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | The rebase struct stores fields with information about the current rebase process, which were not accessible via a public interface. Accessors for getting the `orig_head` and `onto` branch names and object ids have been added.
* | | Merge pull request #5063 from pks-t/pks/cmake-regcomp-fixPatrick Steinhardt2019-05-021-10/+15
|\ \ \ | | | | | | | | cmake: correctly detect if system provides `regcomp`
| * | | cmake: fix include ordering issues with bundled depsPatrick Steinhardt2019-05-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When linking against bundled libraries, we include their header directories by using "-isystem". The reason for that is that we want to handle our vendored library headers specially, most importantly to ignore warnings generated by including them. By using "-isystem", though, we screw up the order of searched include directories by moving those bundled dependencies towards the end of the lookup order. Like this, chances are high that any other specified include directory contains a file that collides with the actual desired include file. Fix this by not treating the bundled dependencies' include directories as system includes. This will move them to the front of the lookup order and thus cause them to override system-provided headers. While this may cause the compiler to generate additional warnings when processing bundled headers, this is a tradeoff we should make regardless to fix builds on systems hitting this issue.
| * | | cmake: correctly detect if system provides `regcomp`Patrick Steinhardt2019-05-021-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We assume that if we are on Win32, Amiga OS, Solaris or SunOS, that the regcomp(3P) function cannot be provided by the system. Thus we will in these cases always include our own, bundled regex sources to make a regcomp implementation available. This test is obviously very fragile, and we have seen it fail on MSYS2/MinGW systems, which do in fact provide the regcomp symbol. The effect is that during compilation, we will use the "regex.h" header provided by MinGW, but use symbols provided by ourselves. This in fact may cause subtle memory layout issues, as the structure made available via MinGW doesn't match what our bundled code expects. There's one more problem with our regex detection: on the listed platforms, we will incorrectly include the bundled regex code even in case where the system provides regcomp_l(3), but it will never be used for anything. Fix the issue by improving our regcomp detection code. Instead of relying on a fragile listing of platforms, we can just use `CHECK_FUNCTION_EXISTS` instead. This will not in fact avoid the header-ordering problem. But we can assume that as soon as a system-provided "regex.h" header is provided, that `CHECK_FUNCTION_EXISTS` will now correctly find the desired symbol and thus not include our bundled regex code.
* | | | Merge pull request #5023 from ianhattendorf/fix/lock_missing_global_configPatrick Steinhardt2019-05-022-1/+31
|\ \ \ \ | |/ / / |/| | | Correctly write to missing locked global config
| * | | Correctly write to missing locked global configIan Hattendorf2019-04-292-1/+31
|/ / / | | | | | | | | | | | | | | | | | | Opening a default config when ~/.gitconfig doesn't exist, locking it, and attempting to write to it causes an assertion failure. Treat non-existent global config file content as an empty string.
* | | Merge pull request #4561 from pks-t/pks/downcastingPatrick Steinhardt2019-04-297-64/+79
|\ \ \ | |_|/ |/| | [RFC] util: introduce GIT_DOWNCAST macro
| * | iterator: make use the `GIT_CONTAINER_OF` macroEtienne Samson2019-04-161-14/+18
| | |
| * | transports: make use of the `GIT_CONTAINER_OF` macroEtienne Samson2019-04-163-26/+26
| | |
| * | refdb_fs: make use of the `GIT_CONTAINER_OF` macroEtienne Samson2019-04-161-22/+22
| | |
| * | config_file: make use of `GIT_CONTAINER_OF` macroPatrick Steinhardt2019-04-161-2/+2
| | |
| * | util: introduce GIT_CONTAINER_OF macroPatrick Steinhardt2019-04-161-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some parts of our code, we make rather heavy use of casting structures to their respective specialized implementation. One example is the configuration code with the general `git_config_backend` and the specialized `diskfile_header` structures. At some occasions, it can get confusing though with regards to the correct inheritance structure, which led to the recent bug fixed in 2424e64c4 (config: harden our use of the backend objects a bit, 2018-02-28). Object-oriented programming in C is hard, but we can at least try to have some checks when it comes to casting around stuff. Thus, this commit introduces a `GIT_CONTAINER_OF` macro, which accepts as parameters the pointer that is to be casted, the pointer it should be cast to as well as the member inside of the target structure that is the containing structure. This macro then tries hard to detect mis-casts: - It checks whether the source and target pointers are of the same type. This requires support by the compiler, as it makes use of the builtin `__builtin_types_compatible_p`. - It checks whether the embedded member of the target structure is the first member. In order to make this a compile-time constant, the compiler-provided `__builtin_offsetof` is being used for this. - It ties these two checks together by the compiler-builtin `__builtin_choose_expr`. Based on whether the previous two checks evaluate to `true`, the compiler will either compile in the correct cast, or it will output `(void)0`. The second case results in a compiler error, resulting in a compile-time check for wrong casts. The only downside to this is that it relies heavily on compiler-specific extensions. As both GCC and Clang support these features, only define this macro like explained above in case `__GNUC__` is set (Clang also defines `__GNUC__`). If the compiler is not Clang or GCC, just go with a simple cast without any additional checks.
* | | Merge pull request #5051 from pks-t/pks/examples-ssh-authPatrick Steinhardt2019-04-264-26/+48
|\ \ \ | |_|/ |/| | examples: implement SSH authentication
| * | examples: use username provided via URLPatrick Steinhardt2019-04-161-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | The credentials callback may be passed a username in case where the URL already includes the expected username. As we usually cannot use a different username in such context, we should use that one if provided and not ask the user for a diferent username.
| * | examples: implement SSH key credentialsPatrick Steinhardt2019-04-161-8/+8
| | | | | | | | | | | | | | | Implement SSH key credentials. This allows users to use the SSH transport with the lg2 example code.
| * | examples: implement SSH key credentialsPatrick Steinhardt2019-04-161-2/+18
| | | | | | | | | | | | | | | Implement SSH key credentials. This allows users to use the SSH transport with the lg2 example code.
| * | examples: support plain username credentialsPatrick Steinhardt2019-04-161-0/+5
| | | | | | | | | | | | | | | | | | | | | Implement plain username credential types. These type of credentials might be asked for e.g. as some kind of pre-authentication step, before the actual credentials are passed.
| * | examples: honor allowed credential types when prompting userPatrick Steinhardt2019-04-161-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Credential callback are being passed a bitset that indicates which credential types are allowed in the current context. In our examples code, we completely ignore that field and always return username/password credentials, which doesn't necessarily make sense e.g. when only SSH keys are allowed. Refactor the code and only return username/password credentials in the case where `USERPASS_PLAINTEXT` credentials are allowed. Otherwise, return a positive error code to indicate that no credentials could be acquired.
| * | examples: move MSVC compatibility macros into common headerPatrick Steinhardt2019-04-163-9/+5
| | | | | | | | | | | | | | | | | | | | | We currently have two locations in our examples where we define the same compatibility wrappers for MSVC. Move them into "common.h" to avoid duplication and make them available to other examples.
* | | Merge pull request #5050 from libgit2/ethomson/windows_init_traversalEdward Thomson2019-04-172-3/+18
|\ \ \ | | | | | | | | git_repository_init: stop traversing at windows root
| * | | git_repository_init: stop traversing at windows rootethomson/windows_init_traversalEdward Thomson2019-04-172-3/+18
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Stop traversing the filesystem at the Windows directory root. We were calculating the filesystem root for the given directory to create, and walking up the filesystem hierarchy. We intended to stop when the traversal path length is equal to the root path length (ie, stopping at the root, since no path may be shorter than the root path). However, on Windows, the root path may be specified in two different ways, as either `Z:` or `Z:\`, where `Z:` is the current drive letter. `git_path_dirname_r` returns the path _without_ a trailing slash, even for the Windows root. As a result, during traversal, we need to test that the traversal path is _less than or equal to_ the root path length to determine if we've hit the root to ensure that we stop when our traversal path is `Z:` and our calculated root path was `Z:\`.
* | | Merge pull request #5053 from tniessen/cf-check-array-alloc-resultEdward Thomson2019-04-161-0/+1
|\ \ \ | |_|/ |/| | config_file: check result of git_array_alloc
| * | config_file: check result of git_array_allocTobias Nießen2019-04-161-0/+1
|/ / | | | | | | | | | | | | git_array_alloc can return NULL if no memory is available, causing a segmentation fault in memset. This adds GIT_ERROR_CHECK_ALLOC similar to how other parts of the code base deal with the return value of git_array_alloc.
* | Merge pull request #5027 from ddevault/masterPatrick Steinhardt2019-04-163-1/+30
|\ \ | |/ |/| patch_parse.c: Handle CRLF in parse_header_start
| * patch_parse.c: Handle CRLF in parse_header_startDrew DeVault2019-04-053-1/+30
| |
* | Merge pull request #5045 from cheese1/patch-1Edward Thomson2019-04-081-1/+1
|\ \ | | | | | | fix typo
| * | fix typocheese12019-04-071-1/+1
|/ /
* | Merge pull request #5039 from libgit2/ethomson/win32_hashEdward Thomson2019-04-072-14/+16
|\ \ | | | | | | sha1: don't inline `git_hash_global_init` for win32
| * | sha1: don't inline `git_hash_global_init` for win32ethomson/win32_hashEdward Thomson2019-04-042-14/+16
| | | | | | | | | | | | | | | Users of the Win32 hash cannot be inlined, as it uses a static struct. Don't inline it, but continue to declare the function in the header.
* | | Merge pull request #5040 from pks-t/pks/ignore-treat-dirpaths-as-dirEdward Thomson2019-04-072-1/+19
|\ \ \ | |_|/ |/| | ignore: treat paths with trailing "/" as directories
| * | ignore: treat paths with trailing "/" as directoriesPatrick Steinhardt2019-04-052-1/+19
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function `git_ignore_path_is_ignored` is there to test the ignore status of paths that need not necessarily exist inside of a repository. This has the implication that for a given path, we cannot always decide whether it references a directory or a file, and we need to distinguish those cases because ignore rules may treat those differently. E.g. given the following gitignore file: * !/**/ we'd only want to unignore directories, while keeping files ignored. But still, calling `git_ignore_path_is_ignored("dir/")` will say that this directory is ignored because it treats "dir/" as a file path. As said, the `is_ignored` function cannot always decide whether the given path is a file or directory, and thus it may produce wrong results in some cases. While this is unfixable in the general case, we can do better when we are being passed a path name with a trailing path separator (e.g. "dir/") and always treat them as directories.
* | Merge pull request #4874 from tiennou/test/4615Edward Thomson2019-04-045-0/+181
|\ \ | | | | | | Test that largefiles can be read through the tree API
| * | tests: test largefiles on win32Edward Thomson2019-04-041-4/+0
| | |
| * | p_fallocate: compatibility fixes for macOSEdward Thomson2019-02-221-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On macOS, fcntl(..., F_PREALLOCATE, ...) will only succeed when followed by an ftruncate(), even when it reports success. However, that syscall will fail when the file already exists. Thus, we must ignore the error code and simply let ftruncate extend the size of the file itself (albeit slowly). By calling ftruncate, we also need to prevent against file shrinkage, for compatibility with posix_ftruncate, which will only extend files, never shrink them.
| * | p_fallocate: add a test for our implementationEdward Thomson2019-02-221-0/+41
| | |
| * | p_fallocate: don't duplicate definitions for win32Edward Thomson2019-02-221-17/+17
| | |
| * | p_fallocate: add Windows emulationEdward Thomson2019-02-221-2/+48
| | | | | | | | | | | | | | | Emulate `p_fallocate` on Windows by seeking beyond the end of the file and setting the size to the current seek position.
| * | tests: test that largefiles can be read through the tree APIEtienne Samson2019-01-304-0/+77
| | |
* | | Merge pull request #5034 from pks-t/pks/symlinked-user-configEdward Thomson2019-04-042-0/+62
|\ \ \ | | | | | | | | Tests for symlinked user config
| * | | tests: config: assure that we can read symlinked global configurationPatrick Steinhardt2019-03-291-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | According to reports, libgit2 is unable to read a global configuration file that is simply a symlink to the real configuration. Write a (succeeding) test that shows that libgit2 _is_ correctly able to do so.