summaryrefslogtreecommitdiff
path: root/src/win32
Commit message (Collapse)AuthorAgeFilesLines
* refactor: `src` is now `src/libgit2`Edward Thomson2022-02-2230-4540/+0
|
* win32: `find_system_dirs` does not return `GIT_ENOTFOUND`Edward Thomson2022-02-211-1/+1
| | | | | | | | Allow for no Git for Windows installation. When there is no GfW found in the path or registry, `git_win32__find_system_dirs` would return a `GIT_ENOTFOUND`. Callers were not expecting this. Since this is no error, we simply return `0` so that callers can move on with their lives.
* util: remove `p_mktemp` / `p_mkstemp`Edward Thomson2022-02-092-15/+0
| | | | | | We have our own temporary file creation function now in `git_futils_mktmp`, remove the others since they may be terrible on some platforms.
* win32: improve impl & tests for system path / g4w interopethomson/win32_findfile_fixesEdward Thomson2022-01-172-170/+152
| | | | | | | | | | | | | | | | | We look for a Git for Windows installation to use its git config, so that clients built on libgit2 can interoperate with the Git for Windows CLI (and clients that are built on top of _it_). Look for `git` both in the `PATH` and in the registry. Use the _first_ git install in the path, and the first git install in the registry. Look in both the `etc` dir and the architecture-specific `etc` dirs (`mingw64/etc` and `mingw32/etc`) beneath the installation root. Prefer the git in the `PATH` to the git location in the registry so that users can override that. Include more tests for this behavior.
* path: introduce git_fs_path_find_executableEdward Thomson2022-01-172-0/+133
| | | | | Provide a helper function to find an executable in the current process's PATH.
* win32: remove unnecessary findfile structureEdward Thomson2022-01-171-42/+37
|
* win32: test system paths for gvfs compatibilityEdward Thomson2022-01-172-26/+53
|
* Correctly detect the share/template folderSven Strickroth2022-01-171-9/+50
| | | | | | | | With Git for Windows >= 2 the share folder is in an architecture specific subfolder. This also add support for Git for Windows versions between 2 and 2.24 where also the etc folder is in an architecture specific subfolder. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Detect installed x64 versions of Git for WindowsSven Strickroth2022-01-171-0/+6
| | | | Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Do not unconditionally remove the last 4 chars of the directory where ↵Sven Strickroth2022-01-171-3/+11
| | | | | | | | | | git.exe was found Removal of the last 4 chars is only required for Git for Windows installations in order to find the "root" folder of the Git installation. Fixes issue #5127. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Prevent possible buffer overflowSven Strickroth2022-01-171-1/+1
| | | | | | Could happen if the path to git.exe is near to MAX_PATH and we append a longer subdir such as "share/git-core" to it. Signed-off-by: Sven Strickroth <email@cs-ware.de>
* Fix typosDimitris Apostolou2022-01-053-3/+3
|
* win32: include correct path headerethomson/pathEdward Thomson2021-11-093-4/+3
|
* path: separate git-specific path functions from utilEdward Thomson2021-11-093-13/+13
| | | | | | 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).
* str: introduce `git_str` for internal, `git_buf` is externalethomson/gitstrEdward Thomson2021-10-175-37/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* win32: posixify the output of p_getcwdEdward Thomson2021-09-251-0/+3
| | | | | | | Make p_getcwd match the rest of our win32 path handling semantics. (This is currently only used in tests, which is why this disparity went unnoticed.)
* Fix coding style for pointerpunkymaniac2021-09-093-13/+13
| | | | Make some syntax change to follow coding style.
* Merge pull request #6006 from boretrk/c11-warningsEdward Thomson2021-08-252-10/+10
|\ | | | | GCC C11 warnings
| * win32: name the dummy union in GIT_REPARSE_DATA_BUFFERPeter Pettersson2021-08-252-10/+10
| | | | | | | | | | | | | | | | Instead of buf->"typeofbuffer"ReparseBuffer the members will be referenced with buf->ReparseBuffer."typeofbuffer" https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_reparse_data_buffer?redirectedfrom=MSDN calls the union DUMMYUNIONNAME but that looks a bit cluttered.
* | Merge pull request #5802 from lhchavez/git-warn-unused-resultEdward Thomson2021-08-251-1/+0
|\ \ | | | | | | Introduce GIT_WARN_UNUSED_RESULT
| * | Get Win32 builds to buildlhchavez2021-08-081-1/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Previously, the location of `GIT_WARN_UNUSED_RESULT` was causing it to be included _after_ a bunch of other headers (namely `src/vector.h`), which broke the build. This change does two things: * Moves the `GIT_WARN_UNUSED_RESULT` above most of the `$include`s in `src/common.h`. * Stops including `vector.h` from `src/win32/path_w32.c` since the header itself does not use it.
* | tests: optional test for p_open() with empty path segmentsPeter Pettersson2021-08-081-0/+7
|/
* Convert long long constant specifiers to stdint macrosCalvin Buckley2021-07-071-5/+5
|
* Initial pass at using int64_t instead of long longCalvin Buckley2021-07-061-2/+2
| | | | | | | | | Even on systems without C99 where long long and stdint are both missing, we can shim stdint and point it to any compiler-specific type (i.e long long, _int64, etc.). Also next is constant suffixes and determining what needs to include stdint.
* tests: exit with error on win32 leakcheckEdward Thomson2021-05-182-0/+7
|
* path: bump most Win32 unicode buffer sizes from MAX_PATH to GIT_PATH_MAXIan Hattendorf2021-05-052-19/+28
|
* Fix some typosAaron Franke2021-02-151-1/+1
|
* Support build with NO_MMAP to disable use of system mmapDhruva Krishnamurthy2020-12-301-0/+70
| | | | | * Use pread/pwrite to avoid updating position in file descriptor * Emulate missing pread/pwrite on win32 using overlapped file IO
* win32: provide macros for calling conventionsEdward Thomson2020-12-081-1/+9
| | | | | | | Provide more clarity for Win32 calling conventions - now that we always compile to __cdecl on Win32, we'll define that as the the libgit2 calling convention. Also offer NTAPI (__stdcall) calling conventions for things that need callbacks from NTAPI code (eg fiber-local storage).
* win32: use GIT_ASSERTEdward Thomson2020-11-276-23/+19
|
* cmake: rename MSVC_CRTDBG to WIN32_LEAKCHECKEdward Thomson2020-11-212-2/+2
|
* win32: consolidate leak checking initializationEdward Thomson2020-11-212-39/+54
| | | | | Move leak check initialization into git_win32_leakcheck_global_init, and call it on library initialization.
* win32: "crtdbg" is now "leakcheck"Edward Thomson2020-11-215-485/+466
| | | | | msvc crtdbg is a mouthfull that is not particularly indicative of what it does. Let's rename it to "win32 leakcheck".
* Merge pull request #5546 from libgit2/ethomson/initEdward Thomson2020-10-143-9/+20
|\ | | | | Refactor "global" state
| * runtime: move init/shutdown into the "runtime"Edward Thomson2020-10-112-4/+2
| | | | | | | | | | Provide a mechanism for system components to register for initialization and shutdown of the libgit2 runtime.
| * thread: don't use the global tlsdata for thread exitEdward Thomson2020-10-111-5/+18
| | | | | | | | | | | | We want to store a pointer to emulate `pthread_exit` on Windows. Do this within the threading infrastructure so that it could potentially be re-used outside of the context of libgit2 itself.
| * global: separate global state from thread-local stateEdward Thomson2020-10-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Our "global initialization" has accumulated some debris over the years. It was previously responsible for both running the various global initializers (that set up various subsystems) _and_ setting up the "global state", which is actually the thread-local state for things like error reporting. Separate the thread local state out into "threadstate". Use the normal subsystem initialization functions that we already have to set it up. This makes both the global initialization system and the threadstate system simpler to reason about.
| * init: move thread init to git_global_threads_initEdward Thomson2020-10-112-2/+2
| | | | | | | | | | Instead of treating win32 thread initialization specially in the win32 git_libgit2_init function, add a git_global_threads_init function.
* | Make the Windows leak detection more robustlhchavez2020-10-111-1/+1
|/ | | | | | | | | | | | | | | This change: * Increases MY_ROW_LIMIT to 2M, since it has been failing in #5595's tests since it's _super_ close to the limit. * Calls `git_repository_free()` on a `git_repository` that was being leaked only in Windows. * Marks the global `git_repository` on `tests/repo/init.c` as `NULL` after being freed to make any accidental access more noisy. * Uses `cl_assert_equal_i()` in `test_trace_windows_stacktrace__leaks` to make the test failures more actionable. * Renames the globals in `tests/repo/init.c` so that they don't start with an underscore.
* Use __GNUC__ macro in the resource scriptAlexander Ovchinnikov2020-07-011-3/+7
| | | | Fix the default LIBGIT2_FILENAME for GNU windres
* Review: Rename the stringize macroAlexander Ovchinnikov2020-07-011-5/+5
|
* Enable building git2.rc resource script with GCCAlexander Ovchinnikov2020-07-011-2/+13
|
* tree-wide: mark local functions as staticPatrick Steinhardt2020-06-091-2/+2
| | | | | | | We've accumulated quite some functions which are never used outside of their respective code unit, but which are lacking the `static` keyword. Add it to reduce their linkage scope and allow the compiler to optimize better.
* win32: don't canonicalize symlink targetsEdward Thomson2020-03-101-2/+1
| | | | | | | | | | | Don't canonicalize symlink targets; our win32 path canonicalization routines expect an absolute path. In particular, using the path canonicalization routines for symlink targets (introduced in commit 7d55bee6d, "win32: fix relative symlinks pointing into dirs", 2020-01-10). Now, use the utf8 -> utf16 relative path handling functions, so that paths like "../foo" will be translated to "..\foo".
* win32: introduce relative path handling functionEdward Thomson2020-03-102-2/+41
| | | | | | | Add a function that takes a (possibly) relative UTF-8 path and emits a UTF-16 path with forward slashes translated to backslashes. If the given path is, in fact, absolute, it will be translated to absolute path handling rules.
* win32: clarify usage of path canonicalization funcsEdward Thomson2020-03-081-0/+3
| | | | | | | | | | | The path canonicalization functions on win32 are intended to canonicalize absolute paths; those with prefixes. In other words, things start with drive letters (`C:\`), share names (`\\server\share`), or other prefixes (`\\?\`). This function removes leading `..` that occur after the prefix but before the directory/file portion (eg, turning `C:\..\..\..\foo` into `C:\foo`). This translation is not appropriate for local paths.
* win32: fix relative symlinks pointing into dirsPatrick Steinhardt2020-01-101-1/+9
| | | | | | | | | | | | | | | | | | On Windows platforms, we need some logic to emulate symlink(3P) defined by POSIX. As unprivileged symlinks on Windows are a rather new feature, our current implementation is comparatively new and still has some rough edges in special cases. One such case is relative symlinks. While relative symlinks to files in the same directory work as expected, libgit2 currently fails to create reltaive symlinks pointing into other directories. This is due to the fact that we forgot to translate the Unix-style target path to Windows-style. Most importantly, we are currently not converting directory separators from "/" to "\". Fix the issue by calling `git_win32_path_canonicalize` on the target. Add a test that verifies our ability to create such relative links across directories.
* global: convert to fiber-local storage to fix exit racesPatrick Steinhardt2019-11-291-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows platforms, we automatically clean up the thread-local storage upon detaching a thread via `DllMain()`. The thing is that this happens for every thread of applications that link against the libgit2 DLL, even those that don't have anything to do with libgit2 itself. As a result, we cannot assume that these unsuspecting threads make use of our `git_libgit2_init()` and `git_libgit2_shutdow()` reference counting, which may lead to racy situations: Thread 1 Thread 2 git_libgit2_shutdown() DllMain(DETACH_THREAD) git__free_tls_data() git_atomic_dec() == 0 git__free_tls_data() TlsFree(_tls_index) TlsGetValue(_tls_index) Due to the second thread never having executed `git_libgit2_init()`, the first thread will clean up TLS data and as a result also free the `_tls_index` variable. When detaching the second thread, we unconditionally access the now-free'd `_tls_index` variable, which is obviously not going to work out well. Fix the issue by converting the code to use fiber-local storage instead of thread-local storage. While FLS will behave the exact same as TLS if no fibers are in use, it does allow us to specify a destructor similar to the one that is accepted by pthread_key_create(3P). Like this, we do not have to manually free indices anymore, but will let the FLS handle calling the destructor. This allows us to get rid of `DllMain()` completely, as we only used it to keep track of when threads were exiting and results in an overall simplification of TLS cleanup.
* internal: use off64_t instead of git_off_tethomson/off_tEdward Thomson2019-11-253-3/+3
| | | | Prefer `off64_t` internally.
* mmap: use a 64-bit signed type `off64_t` for mmapEdward Thomson2019-11-251-3/+3
| | | | Prefer `off64_t` to `git_off_t` for internal visibility.