src/sysdir.c


Log

Author Commit Date CI Message
Edward Thomson fc983542 2020-04-05T22:12:57 sysdir: use GIT_ASSERT
Edward Thomson e316b0d3 2020-05-15T11:47:09 runtime: move init/shutdown into the "runtime" Provide a mechanism for system components to register for initialization and shutdown of the libgit2 runtime.
Patrick Steinhardt b254a585 2020-09-18T10:43:34 sysdir: fix formatting error message with NULL string When trying to the template dir, we pass in a `NULL` pointer for the filename. That's perfectly fine, but if we're failing to find the template directory then we'll creat an error message with the `NULL` pointer passed in. Fix the issue by setting different error messages based on whether the filename is given or not. This even makes sense, as we're not searching for a file in case we have no `name`, but for a directory. So the error would've been misleading anyway.
Edward Thomson b6f18db9 2020-04-05T11:16:29 sysdir: remove unused git_sysdir_get_str
Erik Aigner 952fbbfb 2019-08-01T20:04:11 config: check if we are running in a sandboxed environment On macOS the $HOME environment variable returns the path to the sandbox container instead of the actual user $HOME for sandboxed apps. To get the correct path, we have to get it from the password file entry.
Edward Thomson f673e232 2018-12-27T13:47:34 git_error: use new names in internal APIs and usage Move to the `git_error` name in the internal API for error-related functions.
Patrick Steinhardt ecf4f33a 2018-02-08T11:14:48 Convert usage of `git_buf_free` to new `git_buf_dispose`
Patrick Steinhardt 0967459e 2018-01-25T13:11:34 sysdir: do not use environment in setuid case In order to derive the location of some Git directories, we currently use the environment variables $HOME and $XDG_CONFIG_HOME. This might prove to be problematic whenever the binary is run with setuid, that is when the effective user does not equal the real user. In case the environment variables do not get sanitized by the caller, we thus might end up using the real user's configuration when doing stuff as the effective user. The fix is to use the passwd entry's directory instead of $HOME in this situation. As this might break scenarios where the user explicitly sets $HOME to another path, this fix is only applied in case the effective user does not equal the real user.
Patrick Steinhardt 0c7f49dd 2017-06-30T13:39:01 Make sure to always include "common.h" first Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
Edward Thomson 5135ddaa 2017-03-23T11:48:41 Introduce `git_sysdir_expand_global_file` Provide a mechanism for callers to expand the full path of a file in the global configuration directory (that is to say, the home directory) even if the file doesn't necessarily exist. This lets callers use their own logic for building paths separate from handling file existence.
Edward Thomson 909d5494 2016-12-29T12:25:15 giterr_set: consistent error messages Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
Carlos Martín Nieto 9f09f290 2016-12-17T18:20:29 sysdir: don't guess the paths again when $PATH is specified We should replace it with whatever the user set, not start again.
Edward Thomson 031d34b7 2016-07-29T12:59:42 sysdir: use the standard `init` pattern Don't try to determine when sysdirs are uninitialized. Instead, simply initialize them all at `git_libgit2_init` time and never try to reinitialize, except when consumers explicitly call `git_sysdir_set`. Looking at the buffer length is especially problematic, since there may no appropriate path for that value. (For example, the Windows-specific programdata directory has no value on non-Windows machines.) Previously we would continually trying to re-lookup these values, which could get racy if two different threads are each calling `git_sysdir_get` and trying to lookup / clear the value simultaneously.
Carlos Martín Nieto 8c7c5fa5 2015-10-20T17:42:42 config: add a ProgramData level This is where portable git stores the global configuration which we can use to adhere to it even though git isn't quite installed on the system.
Edward Thomson e069c621 2015-07-02T09:25:48 git__getenv: utf-8 aware env reader Introduce `git__getenv` which is a UTF-8 aware `getenv` everywhere. Make `cl_getenv` use this to keep consistent memory handling around return values (free everywhere, as opposed to only some platforms).
Anurag Gupta 001befcd 2014-05-06T12:16:24 Fix the issues in git__on_shutdown
Russell Belfer 0f603132 2014-05-01T14:47:33 Improve handling of fake home directory There are a few tests that set up a fake home directory and a fake GLOBAL search path so that we can test things in global ignore or attribute or config files. This cleans up that code to work more robustly even if there is a test failure. This also fixes some valgrind warnings where scanning search paths for separators could end up doing a little bit of sketchy data access when coming to the end of search list.
Carlos Martín Nieto a15d3537 2014-04-21T15:48:05 sysdir: free the path if we cannot find the file Returning an error cleared the buf, but this operation does not free the memory associated with it. Use git_buf_free() instead.
Edward Thomson 83634d38 2014-02-24T17:43:10 Move system directory cache out of utils