|
KiCad PCB EDA Suite
|
Classes | |
| struct | CHANGED_FILE |
| struct | MERGE_BLOBS |
| Decoded ancestor/ours/theirs blob contents for a 3-way merge driver. More... | |
| class | PROJECT_GIT_UTILS |
| Utility class with helper functions for project level git operations. More... | |
Typedefs | |
| using | GitRepositoryPtr |
| A unique pointer for git_repository objects with automatic cleanup. | |
| using | GitReferencePtr |
| A unique pointer for git_reference objects with automatic cleanup. | |
| using | GitObjectPtr |
| A unique pointer for git_object objects with automatic cleanup. | |
| using | GitCommitPtr |
| A unique pointer for git_commit objects with automatic cleanup. | |
| using | GitTreePtr |
| A unique pointer for git_tree objects with automatic cleanup. | |
| using | GitIndexPtr |
| A unique pointer for git_index objects with automatic cleanup. | |
| using | GitRebasePtr |
| A unique pointer for git_rebase objects with automatic cleanup. | |
| using | GitRevWalkPtr |
| A unique pointer for git_revwalk objects with automatic cleanup. | |
| using | GitDiffPtr |
| A unique pointer for git_diff objects with automatic cleanup. | |
| using | GitSignaturePtr |
| A unique pointer for git_signature objects with automatic cleanup. | |
| using | GitConfigPtr |
| A unique pointer for git_config objects with automatic cleanup. | |
| using | GitRemotePtr |
| A unique pointer for git_remote objects with automatic cleanup. | |
| using | GitAnnotatedCommitPtr |
| A unique pointer for git_annotated_commit objects with automatic cleanup. | |
| using | GitOidPtr |
| A unique pointer for git_oid objects with automatic cleanup. | |
| using | GitBufPtr |
| A unique pointer for git_buf objects with automatic cleanup. | |
| using | GitBlamePtr |
| A unique pointer for git_blame objects with automatic cleanup. | |
| using | GitBlobPtr |
| A unique pointer for git_blob objects with automatic cleanup. | |
| using | GitBranchIteratorPtr |
| A unique pointer for git_branch_iterator objects with automatic cleanup. | |
| using | GitConfigEntryPtr |
| A unique pointer for git_config_entry objects with automatic cleanup. | |
| using | GitConfigIteratorPtr |
| A unique pointer for git_config_iterator objects with automatic cleanup. | |
| using | GitCredentialPtr |
| A unique pointer for git_credential objects with automatic cleanup. | |
| using | GitOidArrayPtr |
| A unique pointer for git_oidarray objects with automatic cleanup. | |
| using | GitStrArrayPtr |
| A unique pointer for git_strarray objects with automatic cleanup. | |
| using | GitDescribeResultPtr |
| A unique pointer for git_describe_result objects with automatic cleanup. | |
| using | GitDiffStatsPtr |
| A unique pointer for git_diff_stats objects with automatic cleanup. | |
| using | GitFilterListPtr |
| A unique pointer for git_filter_list objects with automatic cleanup. | |
| using | GitIndexerPtr |
| A unique pointer for git_indexer objects with automatic cleanup. | |
| using | GitIndexIteratorPtr |
| A unique pointer for git_index_iterator objects with automatic cleanup. | |
| using | GitIndexConflictIteratorPtr |
| A unique pointer for git_index_conflict_iterator objects with automatic cleanup. | |
| using | GitStatusListPtr |
| A unique pointer for git_status_list objects with automatic cleanup. | |
| using | MERGE_APPLY_FN |
| Signature for a KiCad merge-driver apply function. | |
Enumerations | |
| enum class | FILE_CHANGE_STATUS { UNCHANGED , ADDED , REMOVED , MODIFIED , RENAMED , COPIED , TYPECHANGE } |
Functions | |
| const char * | FileChangeStatusToString (FILE_CHANGE_STATUS aStatus) |
| std::vector< CHANGED_FILE > | CompareRefs (git_repository *aRepo, const wxString &aBaseRef, const wxString &aHeadRef) |
| Compare two git refs (branch / tag / commit OID) within a repository and return the per-file change list. | |
| git_tree * | ResolveRefToTree (git_repository *aRepo, const wxString &aRef) |
| Resolve a string ref (branch name, short OID, full OID, tag) to its tree. | |
| void | CollectDiffDeltas (git_diff *aDiff, const std::function< void(const git_diff_delta &)> &aCallback) |
Walk every delta in a computed diff, invoking aCallback once per delta. | |
| bool | RegisterMergeDriver (const char *aName, MERGE_APPLY_FN aApply) |
| Register a KiCad merge driver with libgit2. | |
| std::string | BlobToString (git_blob *aBlob) |
| Copy a libgit2 blob's raw bytes into a std::string. | |
| int | WriteToGitBuf (git_buf *aBuf, const std::string &aContent) |
Allocate a libgit2-owned buffer big enough for aContent and copy the bytes plus a trailing NUL. | |
| int | LoadMergeBlobs (const git_merge_driver_source *aSource, MERGE_BLOBS &aBlobs) |
Look up the ancestor/ours/theirs blobs of a merge-driver source and decode them into aBlobs. | |
| bool | TryTrivialMerge (const MERGE_BLOBS &aBlobs, git_buf *aResult, int *aRc) |
| Resolve the trivial 3-way cases (identical sides, or one side unchanged from the ancestor). | |
| template<typename DRIVER> | |
| int | ApplyMergeDriver (const git_merge_driver_source *aSrc, const char **aPathOut, unsigned int *aModeOut, git_buf *aMergedOut) |
Shared libgit2 merge-driver apply callback shim. | |
A unique pointer for git_annotated_commit objects with automatic cleanup.
Definition at line 120 of file kicad_git_memory.h.
| using KIGIT::GitBlamePtr |
A unique pointer for git_blame objects with automatic cleanup.
Definition at line 144 of file kicad_git_memory.h.
| using KIGIT::GitBlobPtr |
A unique pointer for git_blob objects with automatic cleanup.
Definition at line 152 of file kicad_git_memory.h.
A unique pointer for git_branch_iterator objects with automatic cleanup.
Definition at line 160 of file kicad_git_memory.h.
| using KIGIT::GitBufPtr |
A unique pointer for git_buf objects with automatic cleanup.
Definition at line 136 of file kicad_git_memory.h.
| using KIGIT::GitCommitPtr |
A unique pointer for git_commit objects with automatic cleanup.
Definition at line 48 of file kicad_git_memory.h.
| using KIGIT::GitConfigEntryPtr |
A unique pointer for git_config_entry objects with automatic cleanup.
Definition at line 168 of file kicad_git_memory.h.
A unique pointer for git_config_iterator objects with automatic cleanup.
Definition at line 176 of file kicad_git_memory.h.
| using KIGIT::GitConfigPtr |
A unique pointer for git_config objects with automatic cleanup.
Definition at line 104 of file kicad_git_memory.h.
| using KIGIT::GitCredentialPtr |
A unique pointer for git_credential objects with automatic cleanup.
Definition at line 184 of file kicad_git_memory.h.
A unique pointer for git_describe_result objects with automatic cleanup.
Definition at line 208 of file kicad_git_memory.h.
| using KIGIT::GitDiffPtr |
A unique pointer for git_diff objects with automatic cleanup.
Definition at line 88 of file kicad_git_memory.h.
| using KIGIT::GitDiffStatsPtr |
A unique pointer for git_diff_stats objects with automatic cleanup.
Definition at line 216 of file kicad_git_memory.h.
| using KIGIT::GitFilterListPtr |
A unique pointer for git_filter_list objects with automatic cleanup.
Definition at line 224 of file kicad_git_memory.h.
A unique pointer for git_index_conflict_iterator objects with automatic cleanup.
Definition at line 248 of file kicad_git_memory.h.
| using KIGIT::GitIndexerPtr |
A unique pointer for git_indexer objects with automatic cleanup.
Definition at line 232 of file kicad_git_memory.h.
A unique pointer for git_index_iterator objects with automatic cleanup.
Definition at line 240 of file kicad_git_memory.h.
| using KIGIT::GitIndexPtr |
A unique pointer for git_index objects with automatic cleanup.
Definition at line 64 of file kicad_git_memory.h.
| using KIGIT::GitObjectPtr |
A unique pointer for git_object objects with automatic cleanup.
Definition at line 41 of file kicad_git_memory.h.
| using KIGIT::GitOidArrayPtr |
A unique pointer for git_oidarray objects with automatic cleanup.
Definition at line 192 of file kicad_git_memory.h.
| using KIGIT::GitOidPtr |
A unique pointer for git_oid objects with automatic cleanup.
Definition at line 128 of file kicad_git_memory.h.
| using KIGIT::GitRebasePtr |
A unique pointer for git_rebase objects with automatic cleanup.
Definition at line 72 of file kicad_git_memory.h.
| using KIGIT::GitReferencePtr |
A unique pointer for git_reference objects with automatic cleanup.
Definition at line 33 of file kicad_git_memory.h.
| using KIGIT::GitRemotePtr |
A unique pointer for git_remote objects with automatic cleanup.
Definition at line 112 of file kicad_git_memory.h.
| using KIGIT::GitRepositoryPtr |
A unique pointer for git_repository objects with automatic cleanup.
Definition at line 25 of file kicad_git_memory.h.
| using KIGIT::GitRevWalkPtr |
A unique pointer for git_revwalk objects with automatic cleanup.
Definition at line 80 of file kicad_git_memory.h.
| using KIGIT::GitSignaturePtr |
A unique pointer for git_signature objects with automatic cleanup.
Definition at line 96 of file kicad_git_memory.h.
| using KIGIT::GitStatusListPtr |
A unique pointer for git_status_list objects with automatic cleanup.
Definition at line 256 of file kicad_git_memory.h.
| using KIGIT::GitStrArrayPtr |
A unique pointer for git_strarray objects with automatic cleanup.
Definition at line 200 of file kicad_git_memory.h.
| using KIGIT::GitTreePtr |
A unique pointer for git_tree objects with automatic cleanup.
Definition at line 56 of file kicad_git_memory.h.
| using KIGIT::MERGE_APPLY_FN |
Signature for a KiCad merge-driver apply function.
Mirrors the libgit2 merge driver apply callback, but with simpler args because we only need the source + a target buffer.
src - libgit2 merge driver source (ancestor/ours/theirs blobs) path_out - destination for the resulting path mode_out - destination for the resulting file mode merged_out - destination buffer for the merged blob
Returns 0 on success, GIT_EMERGECONFLICT (-13) on unresolved conflicts, or any other negative git error code on failure. uint32_t for mode_out per libgit2; included via <cstdint> by callers.
Definition at line 47 of file kigit_driver_registry.h.
|
strong |
| Enumerator | |
|---|---|
| UNCHANGED | |
| ADDED | |
| REMOVED | |
| MODIFIED | |
| RENAMED | |
| COPIED | |
| TYPECHANGE | |
Definition at line 37 of file git_compare_handler.h.
| int KIGIT::ApplyMergeDriver | ( | const git_merge_driver_source * | aSrc, |
| const char ** | aPathOut, | ||
| unsigned int * | aModeOut, | ||
| git_buf * | aMergedOut ) |
Shared libgit2 merge-driver apply callback shim.
Constructs DRIVER over the source, runs its Merge(), and on success or conflict copies ours' path and mode to the outputs. DRIVER must expose a (git_merge_driver_source*, git_buf*) constructor and an int Merge() method.
Definition at line 88 of file kigit_merge_blob_utils.h.
Referenced by KIGIT_PCB_MERGE::Apply(), and KIGIT_TRIVIAL_MERGE_BASE< DERIVED >::Apply().
| KICOMMON_API std::string KIGIT::BlobToString | ( | git_blob * | aBlob | ) |
Copy a libgit2 blob's raw bytes into a std::string.
Returns an empty string if the blob is null.
Definition at line 36 of file kigit_merge_blob_utils.cpp.
Referenced by LoadMergeBlobs().
| APIEXPORT void KIGIT::CollectDiffDeltas | ( | git_diff * | aDiff, |
| const std::function< void(const git_diff_delta &)> & | aCallback ) |
Walk every delta in a computed diff, invoking aCallback once per delta.
Centralizes the git_diff_num_deltas / git_diff_get_delta loop. Null deltas are skipped. A null diff is a no-op.
The callback is a std::function rather than a header-inline template because this helper lives behind the APIEXPORT/libkicommon ABI boundary; a template would have to re-expose the git2 loop in the header to every caller.
Definition at line 1186 of file kicad_git_common.cpp.
References delta.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CompareRefs(), KIGIT_COMMON::GetDifferentFiles(), and PROJECT_TREE_PANE::onGitAmendCommit().
| KICOMMON_API std::vector< CHANGED_FILE > KIGIT::CompareRefs | ( | git_repository * | aRepo, |
| const wxString & | aBaseRef, | ||
| const wxString & | aHeadRef ) |
Compare two git refs (branch / tag / commit OID) within a repository and return the per-file change list.
Used by the git PR-review dialog (Phase 10) to populate the "changed files" list a user clicks through to open the file-compare dialog.
aRepo must not be null. Returns an empty vector on error and logs via wxLogTrace( traceGit ).
Definition at line 76 of file git_compare_handler.cpp.
References CollectDiffDeltas(), KIGIT_COMMON::GetLastGitError(), KIGIT::CHANGED_FILE::oldPath, KIGIT::CHANGED_FILE::path, ResolveRefToTree(), result, KIGIT::CHANGED_FILE::status, and traceGit.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and DIALOG_GIT_MR_REVIEW::populateFileList().
| KICOMMON_API const char * KIGIT::FileChangeStatusToString | ( | FILE_CHANGE_STATUS | aStatus | ) |
Definition at line 38 of file git_compare_handler.cpp.
References ADDED, COPIED, MODIFIED, REMOVED, RENAMED, TYPECHANGE, and UNCHANGED.
Referenced by DIALOG_GIT_MR_REVIEW::populateFileList().
| KICOMMON_API int KIGIT::LoadMergeBlobs | ( | const git_merge_driver_source * | aSource, |
| MERGE_BLOBS & | aBlobs ) |
Look up the ancestor/ours/theirs blobs of a merge-driver source and decode them into aBlobs.
The blobs are freed before returning (only the strings are kept), so callers need no cleanup.
Returns 0 on success, GIT_PASSTHROUGH when ours/theirs are missing, or GIT_ENOTFOUND when a blob lookup fails.
Definition at line 62 of file kigit_merge_blob_utils.cpp.
References KIGIT::MERGE_BLOBS::ancestor, BlobToString(), KIGIT::MERGE_BLOBS::ours, and KIGIT::MERGE_BLOBS::theirs.
Referenced by KIGIT_PCB_MERGE::Merge(), and KIGIT_TRIVIAL_MERGE_BASE< DERIVED >::Merge().
| KICOMMON_API bool KIGIT::RegisterMergeDriver | ( | const char * | aName, |
| MERGE_APPLY_FN | aApply ) |
Register a KiCad merge driver with libgit2.
The driver name must match the merge=<name> attribute set in .gitattributes (e.g. "kicad-pcb", "kicad-sch", "kicad-sym", "kicad-fp-lib").
Idempotent: calling twice with the same name is a no-op. Thread-safety: libgit2's git_merge_driver_register is NOT thread-safe; this function holds an internal mutex around the call, but callers should still ensure it runs once at process init, before any thread fan-out (libgit2 may not tolerate concurrent registration even with our local mutex if its global driver table is read by a parallel merge).
Returns true on success.
Definition at line 80 of file kigit_driver_registry.cpp.
References KIGIT_COMMON::GetLastGitError(), name, and traceGit.
Referenced by PCB::IFACE::OnKifaceStart(), and SCH::IFACE::OnKifaceStart().
| APIEXPORT git_tree * KIGIT::ResolveRefToTree | ( | git_repository * | aRepo, |
| const wxString & | aRef ) |
Resolve a string ref (branch name, short OID, full OID, tag) to its tree.
Runs git_revparse_single followed by git_object_peel( GIT_OBJECT_TREE ), so a commit, tag or tree ref all resolve to the underlying tree. Returns nullptr on error and logs via wxLogTrace( traceGit ).
The caller owns the returned tree and must free it with git_tree_free (wrap in KIGIT::GitTreePtr for RAII). The return type is a raw pointer rather than GitTreePtr because the lambda-deleter closure type backing GitTreePtr is distinct per translation unit, so it cannot cross the kicommon ABI boundary.
Definition at line 1157 of file kicad_git_common.cpp.
References KIGIT_COMMON::GetLastGitError(), and traceGit.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CompareRefs(), and DIALOG_GIT_MR_REVIEW::populateFileList().
| KICOMMON_API bool KIGIT::TryTrivialMerge | ( | const MERGE_BLOBS & | aBlobs, |
| git_buf * | aResult, | ||
| int * | aRc ) |
Resolve the trivial 3-way cases (identical sides, or one side unchanged from the ancestor).
On a trivial hit the resolved content is written to aResult, aRc is set to the WriteToGitBuf return code, and true is returned. Returns false when a real merge is required.
Definition at line 99 of file kigit_merge_blob_utils.cpp.
References KIGIT::MERGE_BLOBS::ancestor, KIGIT::MERGE_BLOBS::ours, KIGIT::MERGE_BLOBS::theirs, and WriteToGitBuf().
Referenced by KIGIT_TRIVIAL_MERGE_BASE< DERIVED >::Merge().
| KICOMMON_API int KIGIT::WriteToGitBuf | ( | git_buf * | aBuf, |
| const std::string & | aContent ) |
Allocate a libgit2-owned buffer big enough for aContent and copy the bytes plus a trailing NUL.
Uses git_buf_grow so libgit2 disposes the buffer correctly via git_buf_dispose.
Returns 0 on success, -1 on allocation failure.
Definition at line 47 of file kigit_merge_blob_utils.cpp.
Referenced by KIGIT_PCB_MERGE::Merge(), KIGIT_TRIVIAL_MERGE_BASE< DERIVED >::Merge(), and TryTrivialMerge().