summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/git_repo.cpp
AgeCommit message (Collapse)Author
2025-01-13GitCAS: remove friend GitRepoMaksim Denisov
...and access internal state via getters. (cherry-picked from ca952159e778f0ed927082832a195842f6229a94)
2025-01-13GitCAS: remove mutex and locksMaksim Denisov
...since there are no unique_locks any more. (cherry-picked from 9a164558010af84d834dee86f1929bd6582a1ccb)
2025-01-13GitRepo: don't reassign git_repository to git_odbMaksim Denisov
...and remove GuardedRepo. (cherry-picked from d9f39250d302152d19a0aacd76eabae7a013f1a8)
2025-01-13GitCAS: implement method for creation of an empty GitCASMaksim Denisov
...and use it in GitRepo to set custom backends. (cherry-picked 99860b78304817c4d5b27ec4c661b733e30a430a)
2025-01-13GitRepo: keep GuardedRepo unexposed and adjust the interface.Maksim Denisov
(cherry-picked from d9f39250d302152d19a0aacd76eabae7a013f1a8)
2024-12-03Avoid double deletion of git_repository in GuardedRepoMaksim Denisov
(cherry-picked from 59a485598d1a57b78fb60fe7df7dfe08a1cadd83)
2024-12-03Synchronize initialization of a git repo across processesMaksim Denisov
2024-12-03Ensure gitstrarray gets created with alive pointers.Maksim Denisov
(cherry-picked from 9dc61e9faca5e8b05a1a2a2eed83a5468aeb6202)
2024-10-08Name global constants using kCamelCase.Maksim Denisov
2024-10-08Name classes, structs and enums using CamelCase.Maksim Denisov
2024-10-07Enable readability-redundant-member-init check.Maksim Denisov
2024-10-07Enable bugprone-empty-catch check.Maksim Denisov
2024-10-07Replace manual new allocations for git_strarray with std::vectorsMaksim Denisov
...and remove unused code from git_utils
2024-09-26Fix redundant std::optional conversionsMaksim Denisov
...proposed by clang-tidy. Enable bugprone-optional-value-conversion check.
2024-09-12Remove unused variablesKlaus Aehlig
2024-09-11Use ArtifactDigestFactory in GitRepoMaksim Denisov
...to create ArtifactDigests.
2024-08-30Replace bazel_re::Digest in GitRepo::SymlinksCheckFunc callbackMaksim Denisov
...with ArtifactDigest.
2024-08-27Reformat code to comply with clang-format 18Klaus Aehlig
... while keeping our .clang-format file.
2024-08-26GitRepo: Create commit from a directory explicitly...Paul Cristian Sarbu
...by writing its tree directly in the object database instead of working with the index. This allows the creation of trees that contain also entries with 'magic' names, such as the .git folder or .gitignore files. Callers must ensure the given directory only contains the needed entries. In particular, just-mr maps and serve service are updated to separate the import-to-Git repository path from the temporary path containing the content to be committed, to avoid polluting the content path with entries generated on repository initialization.
2024-08-26GitRepo: Add method to create tree from directoryPaul Cristian Sarbu
The tree is traversed bottom-up and each entry is explicitly added to the object database: non-directory entries have their content read and are added as blobs with corresponding permissions based on file type (regular, executable, symlink), while subdirectories are added as trees via CreateTree based on the already added blobs.
2024-08-26GitRepo: Change logic that creates commits to explicitly give directoryPaul Cristian Sarbu
In preparation for subsequent changes, specify the directory path containing the tree content to be committed explicitly. This change will allow eventually to be able to specify paths that are different from the root path of the repository in which the commit is created. This commit renames and refactors StageAndCommitAllAnnonymous to allow a directory path to be passed. The just-mr and serve service logic is updated such that current behaviour is otherwise unchanged.
2024-08-26GitRepo: Create trees by directly writing to object databasePaul Cristian Sarbu
The libgit2 treebuilder has unnecessary validity checks for tree entries, including for Git-specific magic names (such as '.git'), which cannot be disabled. However, in our tool any filesystem entry should be allowed to be part of a tree. Therefore, the treebuilder-based implementation for CreateTree is replaced by a direct writing of trees, by content, into the underlying repository object database. Additionally, as direct insertion into the object dabase does not check the validity of the tree entries, as was done implicitly by the treebuilder before, add a check for existence of the tree entries into the debug-level generic validity check, with the option to not perform it for ReadTree (as it is unnecessary there).
2024-08-26GitRepo: Update to use specific getter for repository root pathPaul Cristian Sarbu
2024-08-07Pass SymlinksCheckFunc to GitRepo as not_nullMaksim Denisov
+ invoke it only if there are symlinks to check + remove the corresponding runtime check since it is replaced by a compile-time check
2024-07-19git_repo: return keep tags on successKlaus Aehlig
... instead of the plain boolean value.
2024-07-05Pass StorageConfig to git_repo and git_repo_remoteMaksim Denisov
2024-07-05Use StorageConfig functionality via Instance()Maksim Denisov
...to track changes during refactoring easier.
2024-06-28Use (un)expected for Git repoOliver Reiche
2024-04-10GitRepo: Add method to keep tree alive by taggingPaul Cristian Sarbu
Also adds an appropriate test for this method.
2024-04-10git_repo: Add blob writer methodPaul Cristian Sarbu
Also extends the tests accordingly.
2024-04-10git_repo: Improve error message for CreateTreePaul Cristian Sarbu
2024-04-08Use properly included standard library types by defaultPaul Cristian Sarbu
2024-03-26Add missing system includesPaul Cristian Sarbu
Main culprits: - std::size_t, std::nullptr_t, and NULL require <cstddef> - std::move and std::forward require <utility> - unordered maps and sets require respective includes - std::for_each and std::all_of require <algorithm>
2024-03-15Clean up more includes and targetsPaul Cristian Sarbu
Some of the more specific issues addressed: - missing log_level target/include - header-only libs wrongly marking deps as private - missing/misplaced gsl includes
2024-03-13Fix tmpdir locationKlaus Aehlig
Commit 2ebf355989eb92ac9967eceee0af14d39477afe0 moved the tmpdir creation for various tasks into the task itself. In doing so, TmpDir was called with a relative path; that was, however, is interpreted relative to the working directory, violating the property that our tool never write anything outside the local build root unless explicitly asked to do so (by specifying the output path in an install or install-cas invocation). Fix this, by calling the the tmp-dir function that is storage-layout aware.
2024-03-08just-mr: Fix shell out executionOliver Reiche
... by avoiding reusing temp dirs for execute. While we are at it, also refactor LocalFetchViaTmpRepo() to create its own empty temp dirs, that cannot be reused by the caller.
2024-01-31serve source tree: Increase server-side granularity in response statusesPaul Cristian Sarbu
For archives and Git repositories we should ensure that not finding the witnessing entity (archive content blob or Git commit, respectively) results in a distinct status in the response to a request that sets up roots on the serve endpoint. This will allow just-mr to better handle its interaction with the serve endpoint.
2024-01-08GitRepo: Add blob lookup methodPaul Cristian Sarbu
2023-11-02GitRepo: Add method for async fetch from local repositoryPaul Cristian Sarbu
This avoids using the more geenric GitRepoRemote method which has libcurl as a dependency, something that is not needed for this Git operation.
2023-11-02GitRepo: Add blob existence checkerPaul Cristian Sarbu
Also fixes a small typo in tree existence checker log messages.
2023-08-07GitRepo: Add method for reading object from tree by its pathPaul Cristian Sarbu
2023-07-11Git: Fix handling of symlinks in tree artifactsPaul Cristian Sarbu
The introduction of non-upwards symlinks as first-class objects should have updated the handling of known git tree artifacts containing symlinks. In particular, one should consider trees in their entirety when uploading (irrespective of the ignore_special flag), and git trees should only be reported as known only if the ignore_special flag is set to false.
2023-07-10just-mr: Fix handling of .gitignore files in git repositoriesPaul Cristian Sarbu
The command 'git add .' does not include paths found in .gitignore files in the directory tree where the command is issued. This is not the desired behaviour, as we expect for a tree with a given commit id to contain all of the entries, irrespective of their meaning to Git. This commit addresses the issue as described. For the just-mr.py script we modified the staging command to 'git add -f .'. For the compiled just-mr, simply adding the force flag to 'git_index_add_all' did not work as intended for files found in ignored subdirectories. This is a known libgit2 issue which has been fixed in v1.6.3. Until we can upgrade our libgit2 version, a workaround was implemented: we recursively read the directory entries ourselves and add each of them iteratively using 'git_index_add_bypath', making sure to ignore the root '.git' subtree (which cannot be staged). At the moment the handling of Git submodules remains an open issue, as Git does not allow '.git' subtrees to be forcefully added to the index, and thus such directory entries will currently not be considered as part of a git tree. This however is consistent behavior between Git and libgit2.
2023-06-26ReadTree: Add check for non-upwards symlinks...Paul Cristian Sarbu
...as early as possible. This ensures that callers always receive only the tree entries for the supported object types. For the symlinks non-upwardness check we pass a lambda capturing the real backend of the tree entries, such that the symlinks can be read. Updates git_tree tests accordingly.
2023-06-26ObjectType: Add non-upwards symlinks as a known object type...Paul Cristian Sarbu
...but make sure it is still considered a special type. The only non-special entry types remain file, executable, and tree.
2023-06-06style: Use designated initializersPaul Cristian Sarbu
This feature has been introduced with C++20.
2023-05-31FileRoot: Add ignore-special roots logicPaul Cristian Sarbu
2023-05-15memcheck: fix race in libgit2...Paul Cristian Sarbu
...caused by incorrectly setting and resetting the library internal state and the misuse of pthreads in libgit2. Normally, git_libgit2_init and git_libgit2_shutdown should span the life of a worker thread in order to be safely used. However, due to an incorrect implementation of libgit2's threadstate with pthreads, on unix systems there is a race condition. Until the use of pthread_key_t is corrected in libgit2, we need to apply a workaround by always ensuring that the main thread is the first thread reaching the GitContext constructor.
2023-04-26imports: Switch to Microsoft GSL implementationOliver Reiche
... with two minor code base changes compared to previous use of gsl-lite: - dag.hpp: ActionNode::Ptr and ArtifactNode::Ptr are not wrapped in gsl::not_null<> anymore, due to lack of support for wrapping std::unique_ptr<>. More specifically, the move constructor is missing, rendering it impossible to use std::vector<>::emplace_back(). - utils/cpp/gsl.hpp: New header file added to implement the macros ExpectsAudit() and EnsureAudit(), asserts running only in debug builds, which were available in gsl-lite but are missing in MS GSL.
2023-03-30GitRepo: Guard fake repository odb wrappingPaul Cristian Sarbu
In the current libgit2 implementation, a fake repository wrapped around an existing odb is being registered as owner the same way as a normal repository object. Therefore, one has to guard both the creation and destruction of the fake repository against all other git operations that might access the internal cache during this transfer of ownership.