| Commit message (Collapse) | Author | Age | Files | Lines |
| |\
| |
| | |
Fix repo init when template dir is non-existent
|
| | | |
|
| | |
| |
| |
| |
| | |
This mimics the behaviour of git which just prints a
warning and continues with the repo initialisation.
|
| | | |
|
| | | |
|
| |/
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
When `git_repository_hashfile` is handed an absolute path, it determines
whether the path is within the repository's working directory or not.
This is necessary when there is no `as_path` specified.
If the path is within the working directory, then the given path should
be used for attribute lookups (it is the effective `as_path`). If it is
not within the working directory, then it is _not_ eligible.
Importantly, now we will _never_ pass an absolute path down to attribute
lookup functions.
|
| |\
| |
| | |
Support custom git extensions
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Allow users to specify additional repository extensions that they want
to support. For example, callers can specify that they support
`preciousObjects` and then may open repositories that support
`extensions.preciousObjects`.
Similarly, callers may opt out of supporting extensions that the library
itself supports.
|
| |/
|
|
| |
Make some syntax change to follow coding style.
|
| |\
| |
| | |
Fix worktree iteration when repository has no common directory
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When applying an operation to a repository created without a common directory,
which is known to occur in scenarios where custom odb/refdb backends are used,
git_repository_foreach_worktree currently asserts while attempting to open the
repository located in the common directory.
Fix this issue by applying operation to repository supplied when there are no
linked worktrees to iterate (implied by common directory being empty).
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There were some subtle semantic differences between the various
implementations of atomic functions. Now they behave the same, have
tests and are better documented to avoid this from happening again in
the future.
Of note:
* The semantics chosen for `git_atomic_compare_and_swap` match
`InterlockedCompareExchangePointer`/`__sync_cal_compare_and_swap` now.
* The semantics chosen for `git_atomic_add` match
`InterlockedAdd`/`__atomic_add_fetch`.
* `git_atomic_swap` and `git_atomic_load` still have a bit of semantic
difference with the gcc builtins / msvc interlocked operations, since
they require an l-value (not a pointer). If desired, this can be
homogenized.
|
| |\
| |
| | |
Working directory path validation
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Ensure that a repository's path (at initialization or open time) is
valid. On Windows systems, this means that the longest known path
beneath the repository will fit within MAX_PATH: this is a lock file for
a loose object within the repository itself.
Other paths, like a very long loose reference, may fail to be opened
after the repository is opened. These variable length paths will be
checked when they are accessed themselves. This new functionality is
done at open to prevent needlessly checking every file in the gitdir
(eg, `MERGE_HEAD`) for its length when we could instead check once at
repository open time.
|
| | | |
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| | |
Add a simple accessor for workdir paths to get an absolute on-disk path
given a repository and a relative path within it. This is useful to
avoid copy-pasta `git_buf_joinpath` and to ensure that we validate
working directory paths while honoring `core.longpaths` settings.
|
| |\ \
| | |
| | | |
repo: remove an inappropriate use of PASSTHROUGH
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This error code is for callbacks where we should act as though the callback was
not set. This is not something that makes sense for a `_foreach` and checking
for that error message to bubble up mostly is happenstance precisely because
this is not an error code we expect in the callback.
As part of removing this, let's also remove a use of foreach as we can open-code
this check.
|
| |/ /
| |
| |
| |
| |
| |
| | |
We don't want the default branch's refname here but its name as branch.
Returning an error saying it's not a valid reference here suggests we want the
value of `init.defaultbranch` to be something like `refs/heads/default` which is
not the case.
|
| |/
|
|
| |
We already do this in repo_init_head
|
| |
|
|
|
|
| |
The init.defaultbranch option may be set, but empty. In this case, we
should ignore it instead of trying to set our default branch to
`refs/heads/`.
|
| | |
|
| |
|
|
| |
Also repurposed an unused function and deleted another one.
|
| | |
|
| |
|
|
|
|
|
| |
This change adds all the necessary locking to the odb to avoid races in
the backends.
Part of: #5592
|
| | |
|
| |
|
|
|
|
| |
`git_buf_sanitize` is called with user-input, and wants to sanity-check
that input. Allow it to return a value if the input was malformed in a
way that we cannot cope.
|
| | |
|
| | |
|
| |
|
|
|
|
| |
The git_repository_isempty function now respects the init.defaultbranch
setting (instead of hardcoding "master") to understand if a repository
is empty or not.
|
| |
|
|
|
|
| |
Provide a helper function to get the initial branch for a repository,
respecting the `init.defaultBranch` configuration option, if set, and
returning the "default default" (currently `master`) otherwise.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
As part of a push towards more inclusive language, git is reconsidering
using "master" as the default branch name. As a first step, this
setting will be configurable with the `init.defaultBranch` configuration
option. Honor this during repository initialization.
During initialization, we will create an initial branch:
1. Using the `initial_head` setting, if specified;
2. Using the `HEAD` configured in a template, if it exists;
3. Using the `init.defaultBranch` configuration option, if it is set; or
4. Using `master` in the absence of additional configuration.
|
| |
|
|
|
|
|
|
|
|
| |
The function `git_repository_head_for_worktree` currently uses
`git_reference__read_head` to directly read a given worktree's HEAD from
the filesystem. This is broken in case the repository uses a different
refdb implementation than the filesystem-based one, so let's instead
open the worktree as a real repository and use `git_reference_lookup`.
This also fixes the case where the worktree's HEAD is not a symref, but
a detached HEAD, which would have resulted in an error previously.
|
| |
|
|
|
|
|
|
| |
The function `git_repository_foreach_head` is broken, as it directly
interacts with the on-disk representation of the reference database,
thus assuming that no other refdb is used for the given repository. As
this is an internal function only and all users have been replaced,
let's remove this function.
|
| |
|
|
|
|
|
| |
Given a Git repository, it's non-trivial to iterate over all worktrees
that are associated with it, including the "main" repository. This
commit adds a new internal function `git_repository_foreach_worktree`
that does this for us.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When compiling libgit2 with -DDEPRECATE_HARD, we add a preprocessor
definition `GIT_DEPRECATE_HARD` which causes the "git2/deprecated.h"
header to be empty. As a result, no function declarations are made
available to callers, but the implementations are still available to
link against. This has the problem that function declarations also
aren't visible to the implementations, meaning that the symbol's
visibility will not be set up correctly. As a result, the resulting
library may not expose those deprecated symbols at all on some platforms
and thus cause linking errors.
Fix the issue by conditionally compiling deprecated functions, only.
While it becomes impossible to link against such a library in case one
uses deprecated functions, distributors of libgit2 aren't expected to
pass -DDEPRECATE_HARD anyway. Instead, users of libgit2 should manually
define GIT_DEPRECATE_HARD to hide deprecated functions. Using "real"
hard deprecation still makes sense in the context of CI to test we don't
use deprecated symbols ourselves and in case a dependant uses libgit2 in
a vendored way and knows it won't ever use any of the deprecated symbols
anyway.
|
| |
|
|
|
|
| |
We _dispose_ the contents of objects; we _free_ objects (and their
contents). Update `git_strarray_free` to be `git_strarray_dispose`.
`git_strarray_free` remains as a deprecated proxy function.
|
| |\
| |
| | |
Handle repository format v1
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Git has supported repository format version 1 for some time. This
format is just like version 0, but it supports extensions.
Implementations must reject extensions that they don't support.
Add support for this format version and reject any extensions but
extensions.noop, which is the only extension we currently support.
While we're at it, also clean up an error message.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
| |
When checking whether a path is a valid repository path, we try to read
the "commondir" link file. In the process, we neither confirm that
constructing the file's path succeeded nor do we verify that reading the
file succeeded, which might cause us to verify repositories on an empty
or bogus path later on.
Fix this by checking return values. As the function to verify repos
doesn't currently support returning errors, this commit also refactors
the function to return an error code, passing validity of the repo via
an out parameter instead, and adjusts all existing callers.
|
| |
|
|
|
| |
Stop returning a void for functions, future-proofing them to allow them
to fail.
|
| |
|
|
|
|
|
|
| |
Regression introduced in commit dde6d9c706bf1ecab545da55ab874a016587af1f.
This issue causes lots of crashes in TortoiseGit.
Signed-off-by: Sven Strickroth <email@cs-ware.de>
|
| |
|
|
|
| |
Instead of using a signed type (`off_t`) use `uint64_t` for the maximum
size of files.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The flag GIT_FILEBUF_FORCE currently does two things:
1. It will cause the filebuf to create non-existing leading
directories for the file that is about to be written.
2. It will forcibly remove any pre-existing locks.
While most call sites actually do want (1), they do not want to
remove pre-existing locks, as that renders the locking mechanisms
effectively useless.
Introduce a new flag `GIT_FILEBUF_CREATE_LEADING_DIRS` to
separate both behaviours cleanly from each other and convert
callers to use it instead of `GIT_FILEBUF_FORCE` to have them
honor locked files correctly.
As this conversion removes all current users of `GIT_FILEBUF_FORCE`,
this commit removes the flag altogether.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
When initializing a repository, we need to check whether its working
directory supports symlinks to correctly set the initial value of the
"core.symlinks" config variable. The code to check the filesystem is
reusable in other parts of our codebase, like for example in our tests
to determine whether certain tests can be expected to succeed or not.
Extract the code into a new function `git_path_supports_symlinks` to
avoid duplicate implementations. Remove a duplicate implementation in
the repo test helper code.
|