KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KIGIT Namespace Reference

Classes

struct  CHANGED_FILE
 
struct  GIT_IDENTITY
 Repository values and whether Git can use them to record a commit. More...
 
struct  HOST_KEY_FAILURE
 A server key the connection refused, for the UI to offer to trust or to report. More...
 
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...
 
struct  TEXT_DIFF_LINE
 

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 GitPatchPtr
 A unique pointer for git_patch objects with automatic cleanup.
 
using GitReferenceIteratorPtr
 A unique pointer for git_reference_iterator 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 GitTreeEntryPtr
 A unique pointer for git_tree_entry 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
}
 
enum class  KNOWN_HOST_STATE {
  UNKNOWN , MATCH , MISMATCH , OTHER_KEY_TYPE ,
  REVOKED
}
 How a server's host key stands against known_hosts. More...
 
enum class  TEXT_DIFF_KIND { CONTEXT , ADDED , REMOVED }
 

Functions

bool PromptForCredentials (wxWindow *aParent, KIGIT_COMMON *aCommon, PROJECT *aProject=nullptr, const wxString &aExplanation=wxEmptyString)
 Ask the user for the credentials of the session's remote and apply them to the session.
 
bool PromptToTrustHost (wxWindow *aParent, const HOST_KEY_FAILURE &aFailure, bool aRetriedAfterTrust)
 Ask whether to trust a server seen for the first time, and remember its key when the user agrees.
 
void ClearSyncWarnings (wxWindow *aWindow)
 Clear the background fetch's warnings from the frame holding aWindow.
 
void ClearSyncWarnings (const KIGIT_COMMON *aCommon)
 A transfer that reached the remote answers the background fetch's warnings, so they go from every frame open on the project whose session aCommon is.
 
GIT_IDENTITY ReadGitIdentity (KIGIT_COMMON &aCommon)
 Read on a worker while holding the session's action lock.
 
GitUserConfig ResolveGitIdentity (const GIT_IDENTITY &aIdentity, const COMMON_SETTINGS::GIT &aPreferences, const wxString &aUserName)
 Fill missing values from custom preferences, then use the OS user name if needed.
 
bool EditGitIdentity (wxWindow *aParent, EDA_BASE_FRAME *aFrame, const std::shared_ptr< KIGIT_COMMON > &aCommon, const GIT_IDENTITY &aIdentity)
 Edit the repository's author and refresh Git views after saving.
 
bool EnsureGitIdentity (wxWindow *aParent, EDA_BASE_FRAME *aFrame, const std::shared_ptr< KIGIT_COMMON > &aCommon, const GIT_IDENTITY &aIdentity)
 Open the same editor when the worker snapshot has no usable Git identity.
 
void CallOnUi (std::function< void()> aFn)
 Run aFn on the UI thread.
 
void CallIfAlive (const std::weak_ptr< bool > &aWatch, std::function< void()> aFn)
 As CallOnUi, for work that touches the window that started the transfer.
 
bool StartTransfer (const std::string &aLabel, std::function< void()> aWork)
 Run aWork on a thread the orphan registry owns.
 
void ShowBusyMessage (wxWindow *aParent)
 Show a busy message for a user action. UI thread only.
 
std::unique_lock< std::mutex > TryLockAction (KIGIT_COMMON &aCommon, wxWindow *aParent)
 Try the action lock and show a busy message if it is unavailable.
 
std::unique_lock< std::mutex > WaitForActionLock (KIGIT_COMMON &aCommon, wxWindow *aParent)
 TryLockAction that first waits a moment for a status read or fetch to let go.
 
void SortBranchesForDisplay (std::vector< KIGIT_BRANCH_INFO > &aBranches)
 Put the current branch first, then local and remote branches with the newest tips first.
 
wxString RelativeDate (const wxDateTime &aWhen)
 "just now", "3 hours ago", or the ISO date once it is more than a month old.
 
wxString RelativeDate (const wxDateTime &aWhen, const wxDateTime &aNow)
 
void UnsplitKeepingSash (wxSplitterWindow *aSplitter, wxWindow *aPane, int &aSashPos)
 Close a splitter's second pane, keeping the sash where the user left it for next time.
 
void MarkDestructive (wxButton *aButton)
 Paint a button's text the diff's red, for one that throws something away.
 
wxString SelectedText (wxListCtrl *aList, int aColumn)
 The text of the selected row in a report list, or empty when nothing is selected.
 
bool ValidateIdentity (const wxString &aName, const wxString &aEmail, wxString &aError)
 Check a name and email for recording commits. False leaves the reason in aError.
 
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.
 
bool IsPrivateKeyEncrypted (const wxString &aKeyText)
 Report whether an SSH private key is protected by a passphrase.
 
git_tree * ResolveRefToTree (git_repository *aRepo, const wxString &aRef)
 Resolve a string ref (branch name, short OID, full OID, tag) to its tree.
 
std::vector< wxString > CompareBranchRefs (git_repository *aRepo)
 Refs to offer when comparing branches, base first and head second.
 
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.
 
wxString BranchNameError (const wxString &aName)
 Empty when aName is a branch name git would accept, otherwise why it would not, in the words to show the user.
 
wxString DecodeRepoText (const char *aText)
 Decode text that came out of a repository.
 
wxString BusyMessage ()
 What every caller says when it finds the session already busy.
 
wxString ComposeCommitMessage (const wxString &aSummary, const wxString &aDescription, const wxString &aSignOff)
 Join a summary line, an optional description and an optional sign-off into one commit message.
 
void SplitCommitMessage (const wxString &aMessage, wxString &aSummary, wxString &aDescription)
 Split a commit message into its first line and the description after the first blank line.
 
APIEXPORT wxWindow *& ActiveAdvancedGitWindow ()
 The advanced git window, or null when none is open.
 
bool RegisterMergeDriver (const char *aName, MERGE_APPLY_FN aApply)
 Register a KiCad merge driver with libgit2.
 
APIEXPORT KIGIT_FAILURE_REPORT DescribeGitFailure (const KIGIT_ERROR_INFO &aError, const KIGIT_AUTH_ATTEMPT &aAuth, const KIGIT_FAILURE_CONTEXT &aContext)
 Turn a failed transfer into a message the user can act on.
 
APIEXPORT wxString UnexplainedFailure (KIGIT_OPERATION aOperation, const wxString &aUrl)
 The summary for an operation that failed without saying why, naming the server it was talking to.
 
APIEXPORT bool IsCredentialFailure (KIGIT_FAILURE aKind)
 True for the failures another login, key or passphrase can fix, which the credential prompt answers.
 
APIEXPORT wxString DecodeServerText (const char *aData, size_t aLength)
 Bytes a server sent, as UTF-8 or, when they are not valid UTF-8, one character for each byte.
 
APIEXPORT wxString StripEmbeddedUserinfo (const wxString &aText)
 Remove the user and password from every URL quoted in a message, since the remote's can carry a password.
 
APIEXPORT wxString PrintableServerText (const wxString &aText)
 Text a server sent, made safe to show: no terminal escapes, control or bidi characters, and no URL userinfo.
 
APIEXPORT KIGIT_OWNERSHIP_REFUSAL DescribeOwnershipRefusal (const wxString &aStartDir, const wxString &aGitDir)
 The message for a repository git refuses to open because another user owns it.
 
APIEXPORT std::array< uint8_t, 20 > HmacSha1 (const std::string &aKey, const std::string &aData)
 HMAC-SHA1 (RFC 2104), as OpenSSH hashes host names in known_hosts.
 
APIEXPORT KNOWN_HOST_STATE LookupKnownHost (const wxString &aKnownHostsText, const wxString &aHost, int aPort, const wxString &aKeyType, const std::string &aRawKey)
 Classify a server's key against the text of a known_hosts file, as OpenSSH reads it.
 
APIEXPORT wxString FormatKnownHostsLine (const wxString &aHost, int aPort, const wxString &aKeyType, const wxString &aBase64Key)
 The known_hosts line ssh would write for a key, without a line ending.
 
APIEXPORT wxString HostKeyType (const std::string &aRawKey)
 The type a raw SSH key names for itself, such as ssh-ed25519. Empty when the key is malformed.
 
APIEXPORT wxString HostKeyFingerprint (const std::string &aRawKey)
 SHA256 of a raw key in unpadded base64, as ssh shows it after "SHA256:".
 
APIEXPORT wxString KnownHostsPath ()
 The known_hosts file libgit2 checks host keys against. Empty when it has no home folder.
 
APIEXPORT bool MayOfferTrust (const HOST_KEY_FAILURE &aFailure, bool aRetriedAfterTrust)
 Whether the user may be asked to trust a refused key.
 
APIEXPORT wxString HostKeyRefusalMessage (const HOST_KEY_FAILURE &aFailure)
 Why a key the user may not trust was refused, and what to do next.
 
APIEXPORT wxString Libgit2LegacyHome (int aRevision)
 The home folder libgit2 1.5 reads .ssh/known_hosts under, which it has no option to report.
 
APIEXPORT wxString ReadKnownHosts ()
 The text of KnownHostsPath(). Empty when it is missing or cannot be read.
 
APIEXPORT bool AddKnownHost (const HOST_KEY_FAILURE &aKey)
 Append the refused key to KnownHostsPath(), creating the file and its folder when missing.
 
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.
 
APIEXPORT std::vector< wxString > ParseSSHConfigIdentityFiles (const wxString &aConfigText, const wxString &aHost, const wxString &aHomeDir)
 The IdentityFile entries an ssh config gives aHost, in file order.
 
APIEXPORT std::vector< wxString > DefaultSSHKeyCandidates (const wxString &aHomeDir, const wxString &aHost)
 Private keys to offer aHost, best first.
 
APIEXPORT bool IsSameSSHKey (const wxString &aKey, const wxString &aOther)
 Whether two key paths name the same file.
 
APIEXPORT wxString HomeDir ()
 The user's home folder, where ssh looks for its config and default keys.
 
APIEXPORT bool IsOfferableSSHKey (const wxString &aKey)
 Whether aKey can be offered to a server.
 
static wxString canonicalDir (const wxString &aPath)
 
static bool pathIsUnder (const wxString &aAbsPath, const wxString &aProjectPath)
 
static std::optional< wxString > prefixUnder (const wxString &aWorkDir, const wxString &aProjectPath)
 
std::vector< wxString > SplitTextLines (const std::string &aContent)
 Tolerates CRLF endings and content that is not valid UTF-8.
 
bool TextLooksBinary (const std::string &aContent)
 
std::vector< TEXT_DIFF_LINE > BuildTextDiff (const std::vector< wxString > &aOld, const std::vector< wxString > &aNew)
 Every line of both sides appears once. There are no hunks and nothing is elided.
 

Variables

constexpr const wxChar * SYNC_WARNING_SOURCE = wxS( "git" )
 The status bar source under which background fetch failures are listed.
 
constexpr size_t MAX_SERVER_TEXT = 4096
 The longest server text a failure keeps. A refusal's explanation comes last, after any transfer progress.
 

Typedef Documentation

◆ GitAnnotatedCommitPtr

Initial value:
std::unique_ptr<git_annotated_commit,
decltype([](git_annotated_commit* aCommit) {
git_annotated_commit_free(aCommit);
})>

A unique pointer for git_annotated_commit objects with automatic cleanup.

Definition at line 136 of file kicad_git_memory.h.

◆ GitBlamePtr

Initial value:
std::unique_ptr<git_blame,
decltype([](git_blame* aBlame) {
git_blame_free(aBlame);
})>

A unique pointer for git_blame objects with automatic cleanup.

Definition at line 160 of file kicad_git_memory.h.

◆ GitBlobPtr

Initial value:
std::unique_ptr<git_blob,
decltype([](git_blob* aBlob) {
git_blob_free(aBlob);
})>

A unique pointer for git_blob objects with automatic cleanup.

Definition at line 168 of file kicad_git_memory.h.

◆ GitBranchIteratorPtr

Initial value:
std::unique_ptr<git_branch_iterator,
decltype([](git_branch_iterator* aIter) {
git_branch_iterator_free(aIter);
})>

A unique pointer for git_branch_iterator objects with automatic cleanup.

Definition at line 176 of file kicad_git_memory.h.

◆ GitBufPtr

Initial value:
std::unique_ptr<git_buf,
decltype([](git_buf* aBuf) {
git_buf_free(aBuf);
})>

A unique pointer for git_buf objects with automatic cleanup.

Definition at line 152 of file kicad_git_memory.h.

◆ GitCommitPtr

Initial value:
std::unique_ptr<git_commit,
decltype([](git_commit* aCommit) {
git_commit_free(aCommit);
})>

A unique pointer for git_commit objects with automatic cleanup.

Definition at line 48 of file kicad_git_memory.h.

◆ GitConfigEntryPtr

Initial value:
std::unique_ptr<git_config_entry,
decltype([](git_config_entry* aEntry) {
git_config_entry_free(aEntry);
})>

A unique pointer for git_config_entry objects with automatic cleanup.

Definition at line 184 of file kicad_git_memory.h.

◆ GitConfigIteratorPtr

Initial value:
std::unique_ptr<git_config_iterator,
decltype([](git_config_iterator* aIter) {
git_config_iterator_free(aIter);
})>

A unique pointer for git_config_iterator objects with automatic cleanup.

Definition at line 192 of file kicad_git_memory.h.

◆ GitConfigPtr

Initial value:
std::unique_ptr<git_config,
decltype([](git_config* aConfig) {
git_config_free(aConfig);
})>

A unique pointer for git_config objects with automatic cleanup.

Definition at line 120 of file kicad_git_memory.h.

◆ GitCredentialPtr

Initial value:
std::unique_ptr<git_credential,
decltype([](git_credential* aCred) {
git_credential_free(aCred);
})>

A unique pointer for git_credential objects with automatic cleanup.

Definition at line 200 of file kicad_git_memory.h.

◆ GitDescribeResultPtr

Initial value:
std::unique_ptr<git_describe_result,
decltype([](git_describe_result* aResult) {
git_describe_result_free(aResult);
})>

A unique pointer for git_describe_result objects with automatic cleanup.

Definition at line 224 of file kicad_git_memory.h.

◆ GitDiffPtr

Initial value:
std::unique_ptr<git_diff,
decltype([](git_diff* aDiff) {
git_diff_free(aDiff);
})>

A unique pointer for git_diff objects with automatic cleanup.

Definition at line 88 of file kicad_git_memory.h.

◆ GitDiffStatsPtr

Initial value:
std::unique_ptr<git_diff_stats,
decltype([](git_diff_stats* aStats) {
git_diff_stats_free(aStats);
})>

A unique pointer for git_diff_stats objects with automatic cleanup.

Definition at line 232 of file kicad_git_memory.h.

◆ GitFilterListPtr

Initial value:
std::unique_ptr<git_filter_list,
decltype([](git_filter_list* aFilters) {
git_filter_list_free(aFilters);
})>

A unique pointer for git_filter_list objects with automatic cleanup.

Definition at line 240 of file kicad_git_memory.h.

◆ GitIndexConflictIteratorPtr

Initial value:
std::unique_ptr<git_index_conflict_iterator,
decltype([](git_index_conflict_iterator* aIterator) {
git_index_conflict_iterator_free(aIterator);
})>

A unique pointer for git_index_conflict_iterator objects with automatic cleanup.

Definition at line 264 of file kicad_git_memory.h.

◆ GitIndexerPtr

Initial value:
std::unique_ptr<git_indexer,
decltype([](git_indexer* aIdx) {
git_indexer_free(aIdx);
})>

A unique pointer for git_indexer objects with automatic cleanup.

Definition at line 248 of file kicad_git_memory.h.

◆ GitIndexIteratorPtr

Initial value:
std::unique_ptr<git_index_iterator,
decltype([](git_index_iterator* aIterator) {
git_index_iterator_free(aIterator);
})>

A unique pointer for git_index_iterator objects with automatic cleanup.

Definition at line 256 of file kicad_git_memory.h.

◆ GitIndexPtr

Initial value:
std::unique_ptr<git_index,
decltype([](git_index* aIndex) {
git_index_free(aIndex);
})>

A unique pointer for git_index objects with automatic cleanup.

Definition at line 64 of file kicad_git_memory.h.

◆ GitObjectPtr

Initial value:
std::unique_ptr<git_object,
decltype([](git_object* aObject) {
git_object_free(aObject);
})>

A unique pointer for git_object objects with automatic cleanup.

Definition at line 41 of file kicad_git_memory.h.

◆ GitOidArrayPtr

Initial value:
std::unique_ptr<git_oidarray,
decltype([](git_oidarray* aArray) {
git_oidarray_free(aArray);
})>

A unique pointer for git_oidarray objects with automatic cleanup.

Definition at line 208 of file kicad_git_memory.h.

◆ GitOidPtr

Initial value:
std::unique_ptr<git_oid,
decltype([](git_oid* aOid) {
delete aOid;
})>

A unique pointer for git_oid objects with automatic cleanup.

Definition at line 144 of file kicad_git_memory.h.

◆ GitPatchPtr

Initial value:
std::unique_ptr<git_patch,
decltype([](git_patch* aPatch) {
git_patch_free(aPatch);
})>

A unique pointer for git_patch objects with automatic cleanup.

Definition at line 96 of file kicad_git_memory.h.

◆ GitRebasePtr

Initial value:
std::unique_ptr<git_rebase,
decltype([](git_rebase* aRebase) {
git_rebase_free(aRebase);
})>

A unique pointer for git_rebase objects with automatic cleanup.

Definition at line 72 of file kicad_git_memory.h.

◆ GitReferenceIteratorPtr

Initial value:
std::unique_ptr<git_reference_iterator,
decltype([](git_reference_iterator* aIter) {
git_reference_iterator_free(aIter);
})>

A unique pointer for git_reference_iterator objects with automatic cleanup.

Definition at line 104 of file kicad_git_memory.h.

◆ GitReferencePtr

Initial value:
std::unique_ptr<git_reference,
decltype([](git_reference* aRef) {
git_reference_free(aRef);
})>

A unique pointer for git_reference objects with automatic cleanup.

Definition at line 33 of file kicad_git_memory.h.

◆ GitRemotePtr

Initial value:
std::unique_ptr<git_remote,
decltype([](git_remote* aRemote) {
git_remote_free(aRemote);
})>

A unique pointer for git_remote objects with automatic cleanup.

Definition at line 128 of file kicad_git_memory.h.

◆ GitRepositoryPtr

Initial value:
std::unique_ptr<git_repository,
decltype([](git_repository* aRepo) {
git_repository_free(aRepo);
})>

A unique pointer for git_repository objects with automatic cleanup.

Definition at line 25 of file kicad_git_memory.h.

◆ GitRevWalkPtr

Initial value:
std::unique_ptr<git_revwalk,
decltype([](git_revwalk* aWalker) {
git_revwalk_free(aWalker);
})>

A unique pointer for git_revwalk objects with automatic cleanup.

Definition at line 80 of file kicad_git_memory.h.

◆ GitSignaturePtr

Initial value:
std::unique_ptr<git_signature,
decltype([](git_signature* aSignature) {
git_signature_free(aSignature);
})>

A unique pointer for git_signature objects with automatic cleanup.

Definition at line 112 of file kicad_git_memory.h.

◆ GitStatusListPtr

Initial value:
std::unique_ptr<git_status_list,
decltype([](git_status_list* aList) {
git_status_list_free(aList);
})>

A unique pointer for git_status_list objects with automatic cleanup.

Definition at line 280 of file kicad_git_memory.h.

◆ GitStrArrayPtr

Initial value:
std::unique_ptr<git_strarray,
decltype([](git_strarray* aArray) {
git_strarray_free(aArray);
})>

A unique pointer for git_strarray objects with automatic cleanup.

Definition at line 216 of file kicad_git_memory.h.

◆ GitTreeEntryPtr

Initial value:
std::unique_ptr<git_tree_entry,
decltype([](git_tree_entry* aEntry) {
git_tree_entry_free(aEntry);
})>

A unique pointer for git_tree_entry objects with automatic cleanup.

Definition at line 272 of file kicad_git_memory.h.

◆ GitTreePtr

Initial value:
std::unique_ptr<git_tree,
decltype([](git_tree* aTree) {
git_tree_free(aTree);
})>

A unique pointer for git_tree objects with automatic cleanup.

Definition at line 56 of file kicad_git_memory.h.

◆ MERGE_APPLY_FN

Initial value:
int ( * )( const git_merge_driver_source* src,
const char** path_out,
unsigned int* mode_out,
git_buf* merged_out )

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.

Enumeration Type Documentation

◆ FILE_CHANGE_STATUS

enum class KIGIT::FILE_CHANGE_STATUS
strong
Enumerator
UNCHANGED 
ADDED 
REMOVED 
MODIFIED 
RENAMED 
COPIED 
TYPECHANGE 

Definition at line 37 of file git_compare_handler.h.

◆ KNOWN_HOST_STATE

enum class KIGIT::KNOWN_HOST_STATE
strong

How a server's host key stands against known_hosts.

Enumerator
UNKNOWN 

No entry names the host with a key of this type.

MATCH 

An entry names the host with this key.

MISMATCH 

Entries name the host with another key of this type, and none with this one.

OTHER_KEY_TYPE 

Entries name the host only with keys of other types.

REVOKED 

A @revoked entry carries this key.

Definition at line 35 of file kigit_known_hosts.h.

◆ TEXT_DIFF_KIND

enum class KIGIT::TEXT_DIFF_KIND
strong
Enumerator
CONTEXT 
ADDED 
REMOVED 

Definition at line 36 of file text_diff.h.

Function Documentation

◆ ActiveAdvancedGitWindow()

wxWindow *& KIGIT::ActiveAdvancedGitWindow ( )

The advanced git window, or null when none is open.

Kept here because libcommon is linked into the project manager and into each editor separately, so a static there would give every one of them a window of its own.

Definition at line 51 of file kicad_git_common.cpp.

Referenced by activeDialog(), and setActiveDialog().

◆ AddKnownHost()

bool KIGIT::AddKnownHost ( const HOST_KEY_FAILURE & aKey)

Append the refused key to KnownHostsPath(), creating the file and its folder when missing.

Existing entries are never rewritten. Returns false when the line could not be written.

Definition at line 413 of file kigit_known_hosts.cpp.

References FormatKnownHostsLine(), KIGIT::HOST_KEY_FAILURE::host, KIGIT::HOST_KEY_FAILURE::keyType, KnownHostsPath(), path, KIGIT::HOST_KEY_FAILURE::port, and KIGIT::HOST_KEY_FAILURE::rawKey.

Referenced by PromptToTrustHost().

◆ ApplyMergeDriver()

template<typename DRIVER>
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().

◆ BlobToString()

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().

◆ BranchNameError()

APIEXPORT wxString KIGIT::BranchNameError ( const wxString & aName)

Empty when aName is a branch name git would accept, otherwise why it would not, in the words to show the user.

Definition at line 3083 of file kicad_git_common.cpp.

References _.

Referenced by BOOST_AUTO_TEST_CASE(), KIGIT::PROJECT_GIT_UTILS::CreateBranch(), KIGIT_COMMON::CreateBranch(), GIT_COMMIT_PANE::doCommit(), PANEL_GIT_BRANCHES::onNewBranch(), KIGIT_COMMON::StartUnbornBranch(), and PROJECT_TREE_PANE::switchGitBranch().

◆ BuildTextDiff()

KICOMMON_API std::vector< TEXT_DIFF_LINE > KIGIT::BuildTextDiff ( const std::vector< wxString > & aOld,
const std::vector< wxString > & aNew )

Every line of both sides appears once. There are no hunks and nothing is elided.

Definition at line 77 of file text_diff.cpp.

References ADDED, CONTEXT, REMOVED, and result.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and GIT_FILE_DIFF_AREA::ShowFile().

◆ BusyMessage()

APIEXPORT wxString KIGIT::BusyMessage ( )

What every caller says when it finds the session already busy.

One wording, so the same condition does not reach the user in three different sentences.

Definition at line 3125 of file kicad_git_common.cpp.

References _.

Referenced by LIBGIT_BACKEND::PerformFetch(), LIBGIT_BACKEND::PerformPull(), and ShowBusyMessage().

◆ CallIfAlive()

void KIGIT::CallIfAlive ( const std::weak_ptr< bool > & aWatch,
std::function< void()> aFn )

As CallOnUi, for work that touches the window that started the transfer.

aWatch is locked on the UI thread, so a window that has gone is never touched.

Definition at line 41 of file git_transfer.cpp.

References CallOnUi().

Referenced by KIGIT_STATUS_REPORTER::updateUI().

◆ CallOnUi()

void KIGIT::CallOnUi ( std::function< void()> aFn)

Run aFn on the UI thread.

For a transfer that outlives the window that started it. The work is queued on the application rather than on that window, because the window may be part way through its own destructor, and queueing onto a handler being destroyed is a race.

Definition at line 32 of file git_transfer.cpp.

Referenced by CallIfAlive(), KIGIT_TRANSFER::Start(), GIT_ADVANCED_DIALOG::startFetch(), PANEL_GIT_BRANCHES::startForcePush(), GIT_COMMIT_PANE::startPull(), and GIT_COMMIT_PANE::startPush().

◆ canonicalDir()

static wxString KIGIT::canonicalDir ( const wxString & aPath)
static

◆ ClearSyncWarnings() [1/2]

void KIGIT::ClearSyncWarnings ( const KIGIT_COMMON * aCommon)

A transfer that reached the remote answers the background fetch's warnings, so they go from every frame open on the project whose session aCommon is.

Definition at line 209 of file git_credentials_prompt.cpp.

References ClearSyncWarnings(), PROJECT::GetGitCommon(), KIWAY_HOLDER::HasKiway(), and KIWAY_HOLDER::Prj().

◆ ClearSyncWarnings() [2/2]

void KIGIT::ClearSyncWarnings ( wxWindow * aWindow)

◆ CollectDiffDeltas()

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 3063 of file kicad_git_common.cpp.

References delta.

Referenced by LIBGIT_BACKEND::AbandonOperation(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CompareRefs(), KIGIT_COMMON::GetDifferentFiles(), and KIGIT_COMMON::GetStashDetail().

◆ CompareBranchRefs()

APIEXPORT std::vector< wxString > KIGIT::CompareBranchRefs ( git_repository * aRepo)

Refs to offer when comparing branches, base first and head second.

Only refs that resolve are listed. The base is main or master when it is not the current branch, else the current branch's upstream. The head is the current branch, or HEAD when detached.

The caller must hold the git action lock.

Definition at line 3001 of file kicad_git_common.cpp.

References git_repository, main(), and ResolveRefToTree().

Referenced by KICAD_MANAGER_FRAME::OnCompareProjectBranches().

◆ CompareRefs()

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(), git_repository, 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(), BOOST_AUTO_TEST_CASE(), MaterializeCommitFile(), DIALOG_GIT_MR_REVIEW::populateFileList(), and ShowGitCommitDiff().

◆ ComposeCommitMessage()

APIEXPORT wxString KIGIT::ComposeCommitMessage ( const wxString & aSummary,
const wxString & aDescription,
const wxString & aSignOff )

Join a summary line, an optional description and an optional sign-off into one commit message.

aSignOff is the "Name <email>" to put after "Signed-off-by:", or empty for none. A message that already ends with that sign-off does not get it twice.

Definition at line 3131 of file kicad_git_common.cpp.

References message.

Referenced by GIT_COMMIT_PANE::BeginAmend(), BOOST_AUTO_TEST_CASE(), GIT_COMMIT_PANE::finishCommit(), and GIT_COMMIT_PANE::GetCommitMessage().

◆ DecodeRepoText()

APIEXPORT wxString KIGIT::DecodeRepoText ( const char * aText)

Decode text that came out of a repository.

Git stores it as bytes with no encoding, so a repository written on Windows can carry ISO 8859-1, which FromUTF8 alone would blank.

Definition at line 3111 of file kicad_git_common.cpp.

References decoded().

Referenced by KIGIT_COMMON::GetBranchDetail(), KIGIT_COMMON::GetBranches(), KIGIT_COMMON::GetCommitDetail(), KIGIT_COMMON::GetLastCommitMessage(), KIGIT_COMMON::GetRecentCommitMessages(), KIGIT_COMMON::GetRecentCommits(), KIGIT_COMMON::GetStashDetail(), KIGIT_COMMON::GetTagDetail(), and KIGIT_COMMON::GetTags().

◆ DecodeServerText()

wxString KIGIT::DecodeServerText ( const char * aData,
size_t aLength )

Bytes a server sent, as UTF-8 or, when they are not valid UTF-8, one character for each byte.

Definition at line 451 of file kigit_failure.cpp.

References text.

Referenced by push_update_reference_cb(), KIGIT_REPO_MIXIN::ReceiveSideband(), and KIGIT_REPO_MIXIN::ReportTransferFailure().

◆ DefaultSSHKeyCandidates()

std::vector< wxString > KIGIT::DefaultSSHKeyCandidates ( const wxString & aHomeDir,
const wxString & aHost )

Private keys to offer aHost, best first.

The ssh config's IdentityFile entries for the host come first, then id_ed25519, id_ecdsa, id_rsa and id_dsa from aHomeDir/.ssh. Only keys whose private and public files both exist are listed. An empty aHomeDir gives no keys.

Definition at line 198 of file kigit_ssh_keys.cpp.

References candidates(), config, decoded(), IsOfferableSSHKey(), name, ParseSSHConfigIdentityFiles(), path, and text.

Referenced by DIALOG_GIT_REPOSITORY::setDefaultSSHKey(), and KIGIT_COMMON::updatePublicKeys().

◆ DescribeGitFailure()

KIGIT_FAILURE_REPORT KIGIT::DescribeGitFailure ( const KIGIT_ERROR_INFO & aError,
const KIGIT_AUTH_ATTEMPT & aAuth,
const KIGIT_FAILURE_CONTEXT & aContext )

Turn a failed transfer into a message the user can act on.

The libgit2 code decides first, then its error class, then what the credential callback offered, and last the resolver and connection texts libgit2 and libssh2 write themselves. Those are never translated. Text a server sends is shown to the user but never decides the kind, so only its codes are relied on.

Definition at line 424 of file kigit_failure.cpp.

References classifyGitFailure(), KIGIT_FAILURE_REPORT::details, KIGIT_FAILURE_REPORT::kind, and KIGIT_FAILURE_REPORT::summary.

Referenced by DIALOG_GIT_REPOSITORY::OnTestClick(), KIGIT_REPO_MIXIN::ReportTransferFailure(), and LIBGIT_BACKEND::SetupRemote().

◆ DescribeOwnershipRefusal()

KIGIT_OWNERSHIP_REFUSAL KIGIT::DescribeOwnershipRefusal ( const wxString & aStartDir,
const wxString & aGitDir )

The message for a repository git refuses to open because another user owns it.

git checks the working folder, so that is the one named: the nearest folder at or above aStartDir that holds a .git file or folder, spelled as libgit2 resolves it. A bare repository has none and keeps aGitDir, the git directory discovery found.

Definition at line 584 of file kigit_failure.cpp.

References _, config, GIT_BUF_INIT, isRootedLikeLibgit2(), path, quoteForShell(), and resolveLikeLibgit2().

Referenced by LIBGIT_BACKEND::GetRepositoryForFile().

◆ EditGitIdentity()

bool KIGIT::EditGitIdentity ( wxWindow * aParent,
EDA_BASE_FRAME * aFrame,
const std::shared_ptr< KIGIT_COMMON > & aCommon,
const GIT_IDENTITY & aIdentity )

Edit the repository's author and refresh Git views after saving.

UI thread only. Refuse to save if the frame changes project while the dialog is open.

Definition at line 274 of file git_credentials_prompt.cpp.

References _, config, DisplayErrorMessage(), DIALOG_GIT_IDENTITY::GetAuthorName(), DIALOG_GIT_IDENTITY::GetEmail(), Pgm(), ResolveGitIdentity(), DIALOG_SHIM::ShowModal(), and WaitForActionLock().

Referenced by EnsureGitIdentity(), PANEL_GIT_REPOSITORY::onEditAuthor(), and GIT_COMMIT_PANE::setAuthor().

◆ EnsureGitIdentity()

bool KIGIT::EnsureGitIdentity ( wxWindow * aParent,
EDA_BASE_FRAME * aFrame,
const std::shared_ptr< KIGIT_COMMON > & aCommon,
const GIT_IDENTITY & aIdentity )

◆ FileChangeStatusToString()

KICOMMON_API const char * KIGIT::FileChangeStatusToString ( FILE_CHANGE_STATUS aStatus)

◆ FormatKnownHostsLine()

wxString KIGIT::FormatKnownHostsLine ( const wxString & aHost,
int aPort,
const wxString & aKeyType,
const wxString & aBase64Key )

The known_hosts line ssh would write for a key, without a line ending.

Definition at line 324 of file kigit_known_hosts.cpp.

Referenced by AddKnownHost().

◆ HmacSha1()

std::array< uint8_t, 20 > KIGIT::HmacSha1 ( const std::string & aKey,
const std::string & aData )

HMAC-SHA1 (RFC 2104), as OpenSSH hashes host names in known_hosts.

Definition at line 227 of file kigit_known_hosts.cpp.

◆ HomeDir()

wxString KIGIT::HomeDir ( )

The user's home folder, where ssh looks for its config and default keys.

Empty when unknown. Safe to call from any thread.

Definition at line 268 of file kigit_ssh_keys.cpp.

Referenced by DIALOG_GIT_REPOSITORY::setDefaultSSHKey(), and KIGIT_COMMON::updatePublicKeys().

◆ HostKeyFingerprint()

wxString KIGIT::HostKeyFingerprint ( const std::string & aRawKey)

SHA256 of a raw key in unpadded base64, as ssh shows it after "SHA256:".

Definition at line 349 of file kigit_known_hosts.cpp.

Referenced by certificate_check_cb().

◆ HostKeyRefusalMessage()

wxString KIGIT::HostKeyRefusalMessage ( const HOST_KEY_FAILURE & aFailure)

Why a key the user may not trust was refused, and what to do next.

Definition at line 455 of file kigit_known_hosts.cpp.

References _, KIGIT::HOST_KEY_FAILURE::host, MISMATCH, KIGIT::HOST_KEY_FAILURE::port, REVOKED, and KIGIT::HOST_KEY_FAILURE::state.

Referenced by PromptToTrustHost().

◆ HostKeyType()

wxString KIGIT::HostKeyType ( const std::string & aRawKey)

The type a raw SSH key names for itself, such as ssh-ed25519. Empty when the key is malformed.

Definition at line 331 of file kigit_known_hosts.cpp.

Referenced by certificate_check_cb().

◆ IsCredentialFailure()

bool KIGIT::IsCredentialFailure ( KIGIT_FAILURE aKind)

True for the failures another login, key or passphrase can fix, which the credential prompt answers.

Definition at line 444 of file kigit_failure.cpp.

References AUTH_HTTPS_REJECTED, AUTH_NO_SSH_KEY, AUTH_SSH_KEY_REJECTED, and KEY_LOAD_FAILED.

Referenced by KIGIT_REPO_MIXIN::ReportTransferFailure().

◆ IsOfferableSSHKey()

bool KIGIT::IsOfferableSSHKey ( const wxString & aKey)

Whether aKey can be offered to a server.

libgit2 opens both files only once the connection is under way, and a missing one ends the attempt instead of trying the next key.

Definition at line 292 of file kigit_ssh_keys.cpp.

Referenced by DefaultSSHKeyCandidates(), KIGIT_COMMON::GetFirstOfferedSSHKey(), KIGIT_COMMON::GetNextPublicKey(), initialSSHKey(), and KIGIT_COMMON::rebuildPublicKeysUnlocked().

◆ IsPrivateKeyEncrypted()

APIEXPORT bool KIGIT::IsPrivateKeyEncrypted ( const wxString & aKeyText)

Report whether an SSH private key is protected by a passphrase.

aKeyText is the whole contents of the private key file. Anything not recognised as a private key is reported as unencrypted.

Definition at line 2916 of file kicad_git_common.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and DIALOG_GIT_REPOSITORY::OnFileUpdated().

◆ IsSameSSHKey()

bool KIGIT::IsSameSSHKey ( const wxString & aKey,
const wxString & aOther )

Whether two key paths name the same file.

Separators are normalised, and case is ignored where the file system ignores it.

Definition at line 257 of file kigit_ssh_keys.cpp.

Referenced by KIGIT_COMMON::rebuildPublicKeysUnlocked().

◆ KnownHostsPath()

wxString KIGIT::KnownHostsPath ( )

The known_hosts file libgit2 checks host keys against. Empty when it has no home folder.

Definition at line 360 of file kigit_known_hosts.cpp.

References GIT_BUF_INIT, Libgit2LegacyHome(), and path.

Referenced by AddKnownHost(), PromptToTrustHost(), and ReadKnownHosts().

◆ Libgit2LegacyHome()

wxString KIGIT::Libgit2LegacyHome ( int aRevision)

The home folder libgit2 1.5 reads .ssh/known_hosts under, which it has no option to report.

1.5.1 reads HOME at each connection and 1.5.2 takes the folder 1.6 would. 1.5.0 reads no trust store, so KiCad keeps its own where 1.5.2 would look.

Parameters
aRevisionThe patch level of the libgit2 1.5 in use.

Definition at line 483 of file kigit_known_hosts.cpp.

References L, and path.

Referenced by KnownHostsPath().

◆ LoadMergeBlobs()

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(), git_repository, KIGIT::MERGE_BLOBS::ours, and KIGIT::MERGE_BLOBS::theirs.

Referenced by KIGIT_PCB_MERGE::Merge(), and KIGIT_TRIVIAL_MERGE_BASE< DERIVED >::Merge().

◆ LookupKnownHost()

KIGIT::KNOWN_HOST_STATE KIGIT::LookupKnownHost ( const wxString & aKnownHostsText,
const wxString & aHost,
int aPort,
const wxString & aKeyType,
const std::string & aRawKey )

Classify a server's key against the text of a known_hosts file, as OpenSSH reads it.

Entries name the host as [host]:port, or as host on port 22, either plainly, with *, ? and ! patterns, or hashed. A @revoked host entry applies on every port, because libssh2 also accepts a plain host entry for every port. @cert-authority entries are ignored.

Parameters
aKeyTypeThe key's type as known_hosts names it.
aRawKeyThe key as the server sent it.

Definition at line 256 of file kigit_known_hosts.cpp.

References MATCH, MISMATCH, OTHER_KEY_TYPE, REVOKED, and UNKNOWN.

Referenced by certificate_check_cb().

◆ MarkDestructive()

void KIGIT::MarkDestructive ( wxButton * aButton)

◆ MayOfferTrust()

bool KIGIT::MayOfferTrust ( const HOST_KEY_FAILURE & aFailure,
bool aRetriedAfterTrust )

Whether the user may be asked to trust a refused key.

A changed or revoked key never may, and an operation already retried after a trust reports a second refusal instead of asking again.

Definition at line 446 of file kigit_known_hosts.cpp.

References OTHER_KEY_TYPE, KIGIT::HOST_KEY_FAILURE::state, and UNKNOWN.

Referenced by PromptToTrustHost().

◆ ParseSSHConfigIdentityFiles()

std::vector< wxString > KIGIT::ParseSSHConfigIdentityFiles ( const wxString & aConfigText,
const wxString & aHost,
const wxString & aHomeDir )

The IdentityFile entries an ssh config gives aHost, in file order.

Host patterns match aHost case-sensitively, as typed in the remote address, without resolving HostName. Match blocks are skipped. A leading ~ and every d expand to aHomeDir; a value holding any other % token is returned unexpanded.

Definition at line 156 of file kigit_ssh_keys.cpp.

Referenced by DefaultSSHKeyCandidates().

◆ pathIsUnder()

static bool KIGIT::pathIsUnder ( const wxString & aAbsPath,
const wxString & aProjectPath )
static

◆ prefixUnder()

static std::optional< wxString > KIGIT::prefixUnder ( const wxString & aWorkDir,
const wxString & aProjectPath )
static

Definition at line 251 of file project_git_utils.cpp.

Referenced by KIGIT::PROJECT_GIT_UTILS::ProjectPrefix().

◆ PrintableServerText()

wxString KIGIT::PrintableServerText ( const wxString & aText)

Text a server sent, made safe to show: no terminal escapes, control or bidi characters, and no URL userinfo.

Line breaks are kept.

Definition at line 497 of file kigit_failure.cpp.

References StripEmbeddedUserinfo(), and text.

Referenced by push_update_reference_cb(), KIGIT_REPO_MIXIN::ReceiveSideband(), KIGIT_REPO_MIXIN::ReportTransferFailure(), and KIGIT_REPO_MIXIN::SetPushRefusal().

◆ PromptForCredentials()

bool KIGIT::PromptForCredentials ( wxWindow * aParent,
KIGIT_COMMON * aCommon,
PROJECT * aProject = nullptr,
const wxString & aExplanation = wxEmptyString )

Ask the user for the credentials of the session's remote and apply them to the session.

Optionally stores them in the OS keychain. Clears the auth-failure state so the caller can retry the operation.

Parameters
aParentParent window for the dialog.
aCommonSession to update with the entered credentials.
aProjectWhen given, the corrected username and key are also written to the project's stored settings, so a later repository attach does not revert them.
aExplanationWhy the last attempt failed, shown above the fields. Nothing is shown when empty.
Returns
True when the user confirmed and credentials were applied.

Definition at line 81 of file git_credentials_prompt.cpp.

References _, KIGIT_COMMON::ApplyPromptedCredentials(), KIGIT_COMMON::CREDENTIAL_IDENTITY::connType, KIGIT_COMMON::PROMPTED_CREDENTIALS::connType, DisplayInfoMessage(), DIALOG_GIT_CREDENTIALS::GetConnType(), KIGIT_COMMON::GetCredentialIdentity(), PROJECT::GetLocalSettings(), DIALOG_GIT_CREDENTIALS::GetPassword(), DIALOG_GIT_CREDENTIALS::GetSSHKey(), DIALOG_GIT_CREDENTIALS::GetUsername(), KIGIT_COMMON::GIT_CONN_LOCAL, KIGIT_COMMON::GIT_CONN_SSH, initialSSHKey(), PROJECT_LOCAL_SETTINGS::m_GitRepoType, PROJECT_LOCAL_SETTINGS::m_GitRepoUsername, PROJECT_LOCAL_SETTINGS::m_GitSSHKey, KIGIT_COMMON::ParseRemoteURL(), KIGIT_COMMON::PROMPTED_CREDENTIALS::password, KIGIT_COMMON::CREDENTIAL_IDENTITY::remote, resolveMissingRemote(), DIALOG_GIT_CREDENTIALS::SaveCredentials(), DIALOG_SHIM::ShowModal(), KIGIT_COMMON::PROMPTED_CREDENTIALS::sshKey, KIPLATFORM::SECRETS::StoreSecret(), traceGit, KIGIT_COMMON::CREDENTIAL_IDENTITY::username, KIGIT_COMMON::PROMPTED_CREDENTIALS::username, and KIGIT_COMMON::REMOTE_URL::username.

Referenced by GIT_COMMIT_PANE::onPullDone(), GIT_COMMIT_PANE::onPushDone(), and promptForGitCredentials().

◆ PromptToTrustHost()

bool KIGIT::PromptToTrustHost ( wxWindow * aParent,
const HOST_KEY_FAILURE & aFailure,
bool aRetriedAfterTrust )

Ask whether to trust a server seen for the first time, and remember its key when the user agrees.

A changed or revoked key is refused with an explanation and no way to accept it.

Parameters
aRetriedAfterTrustThe operation already ran again after a trust, so it is refused instead.
Returns
True when the key was saved and the operation should be tried again.

Definition at line 146 of file git_credentials_prompt.cpp.

References _, AddKnownHost(), DisplayErrorMessage(), KIGIT::HOST_KEY_FAILURE::fingerprint, KIGIT::HOST_KEY_FAILURE::host, HostKeyRefusalMessage(), KICAD_MESSAGE_DIALOG, KnownHostsPath(), MayOfferTrust(), OTHER_KEY_TYPE, KIGIT::HOST_KEY_FAILURE::port, and KIGIT::HOST_KEY_FAILURE::state.

Referenced by KICAD_MANAGER_CONTROL::NewFromRepository(), PROJECT_TREE_PANE::onGitInitializeProject(), GIT_COMMIT_PANE::onPullDone(), GIT_COMMIT_PANE::onPushDone(), and DIALOG_GIT_REPOSITORY::OnTestClick().

◆ ReadGitIdentity()

◆ ReadKnownHosts()

wxString KIGIT::ReadKnownHosts ( )

The text of KnownHostsPath(). Empty when it is missing or cannot be read.

Definition at line 390 of file kigit_known_hosts.cpp.

References decoded(), KnownHostsPath(), path, and text.

Referenced by certificate_check_cb().

◆ RegisterMergeDriver()

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().

◆ RelativeDate() [1/2]

wxString KIGIT::RelativeDate ( const wxDateTime & aWhen)

◆ RelativeDate() [2/2]

wxString KIGIT::RelativeDate ( const wxDateTime & aWhen,
const wxDateTime & aNow )

Definition at line 99 of file git_ui_utils.cpp.

References _.

◆ ResolveGitIdentity()

GitUserConfig KIGIT::ResolveGitIdentity ( const GIT_IDENTITY & aIdentity,
const COMMON_SETTINGS::GIT & aPreferences,
const wxString & aUserName )

Fill missing values from custom preferences, then use the OS user name if needed.

Definition at line 240 of file git_credentials_prompt.cpp.

References COMMON_SETTINGS::GIT::authorEmail, COMMON_SETTINGS::GIT::authorName, config, KIGIT::GIT_IDENTITY::config, and COMMON_SETTINGS::GIT::useDefaultAuthor.

Referenced by BOOST_AUTO_TEST_CASE(), and EditGitIdentity().

◆ ResolveRefToTree()

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 2972 of file kicad_git_common.cpp.

References KIGIT_COMMON::GetLastGitError(), git_repository, and traceGit.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), CompareBranchRefs(), CompareRefs(), DIALOG_GIT_MR_REVIEW::populateFileList(), KIGIT::PROJECT_GIT_UTILS::WriteBlobToFile(), and KIGIT::PROJECT_GIT_UTILS::WriteTreeToDir().

◆ SelectedText()

wxString KIGIT::SelectedText ( wxListCtrl * aList,
int aColumn )

◆ ShowBusyMessage()

void KIGIT::ShowBusyMessage ( wxWindow * aParent)

◆ SortBranchesForDisplay()

void KIGIT::SortBranchesForDisplay ( std::vector< KIGIT_BRANCH_INFO > & aBranches)

Put the current branch first, then local and remote branches with the newest tips first.

Use the name to break ties. Callers can choose a different order.

Definition at line 71 of file git_ui_utils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), GIT_ADVANCED_DIALOG::populateTopBar(), GIT_COMMIT_PANE::RefreshFileList(), and PROJECT_TREE_PANE::showContextMenu().

◆ SplitCommitMessage()

APIEXPORT void KIGIT::SplitCommitMessage ( const wxString & aMessage,
wxString & aSummary,
wxString & aDescription )

Split a commit message into its first line and the description after the first blank line.

Definition at line 3164 of file kicad_git_common.cpp.

References message.

Referenced by GIT_COMMIT_PANE::BeginAmend(), BOOST_AUTO_TEST_CASE(), GIT_COMMIT_PANE::onRecentMessage(), and GIT_COMMIT_PANE::SetCommitMessage().

◆ SplitTextLines()

KICOMMON_API std::vector< wxString > KIGIT::SplitTextLines ( const std::string & aContent)

Tolerates CRLF endings and content that is not valid UTF-8.

Definition at line 28 of file text_diff.cpp.

References end, and text.

Referenced by BOOST_AUTO_TEST_CASE(), and GIT_FILE_DIFF_AREA::ShowFile().

◆ StartTransfer()

bool KIGIT::StartTransfer ( const std::string & aLabel,
std::function< void()> aWork )

Run aWork on a thread the orphan registry owns.

The registry joins with a bounded timeout at shutdown and detaches whatever has not finished, so a window closing mid transfer never waits for the socket. False when no thread could be started, which only happens once shutdown has begun.

Definition at line 52 of file git_transfer.cpp.

References GetGitBackend(), GIT_BACKEND::OrphanRegistry(), and KIGIT_ORPHAN_REGISTRY::Register().

Referenced by KIGIT_TRANSFER::Start().

◆ StripEmbeddedUserinfo()

wxString KIGIT::StripEmbeddedUserinfo ( const wxString & aText)

Remove the user and password from every URL quoted in a message, since the remote's can carry a password.

Definition at line 463 of file kigit_failure.cpp.

References result.

Referenced by KIGIT_ERRORS::AddError(), credentials_cb(), DIALOG_GIT_CREDENTIALS::DIALOG_GIT_CREDENTIALS(), KIGIT_COMMON::GetLastGitError(), KIGIT_COMMON::GetRemotes(), and PrintableServerText().

◆ TextLooksBinary()

KICOMMON_API bool KIGIT::TextLooksBinary ( const std::string & aContent)

Definition at line 68 of file text_diff.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and GIT_FILE_DIFF_AREA::ShowFile().

◆ TryLockAction()

std::unique_lock< std::mutex > KIGIT::TryLockAction ( KIGIT_COMMON & aCommon,
wxWindow * aParent )
nodiscard

◆ TryTrivialMerge()

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().

◆ UnexplainedFailure()

wxString KIGIT::UnexplainedFailure ( KIGIT_OPERATION aOperation,
const wxString & aUrl )

The summary for an operation that failed without saying why, naming the server it was talking to.

Definition at line 435 of file kigit_failure.cpp.

References KIGIT_FAILURE_CONTEXT::operation, OTHER, and KIGIT_FAILURE_CONTEXT::url.

Referenced by GIT_COMMIT_PANE::onPullDone(), and GIT_COMMIT_PANE::onPushDone().

◆ UnsplitKeepingSash()

void KIGIT::UnsplitKeepingSash ( wxSplitterWindow * aSplitter,
wxWindow * aPane,
int & aSashPos )

◆ ValidateIdentity()

bool KIGIT::ValidateIdentity ( const wxString & aName,
const wxString & aEmail,
wxString & aError )

Check a name and email for recording commits. False leaves the reason in aError.

Definition at line 169 of file git_ui_utils.cpp.

References _, looksLikeAnEmailAddress(), and name.

Referenced by BOOST_AUTO_TEST_CASE(), and DIALOG_GIT_IDENTITY::TransferDataFromWindow().

◆ WaitForActionLock()

std::unique_lock< std::mutex > KIGIT::WaitForActionLock ( KIGIT_COMMON & aCommon,
wxWindow * aParent )
nodiscard

TryLockAction that first waits a moment for a status read or fetch to let go.

For applying what the user has already typed, which the busy message would throw away.

Definition at line 55 of file git_ui_utils.cpp.

References KIGIT_COMMON::ACTION_LOCK_WAIT, ShowBusyMessage(), and KIGIT_COMMON::TryLockActionFor().

Referenced by EditGitIdentity(), PROJECT_TREE_PANE::onGitRemoteSettings(), and PROJECT_TREE_PANE::switchGitBranch().

◆ WriteToGitBuf()

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().

Variable Documentation

◆ MAX_SERVER_TEXT

size_t KIGIT::MAX_SERVER_TEXT = 4096
constexpr

The longest server text a failure keeps. A refusal's explanation comes last, after any transfer progress.

Definition at line 130 of file kigit_failure.h.

Referenced by KIGIT_REPO_MIXIN::addServerLine(), KIGIT_REPO_MIXIN::ReceiveSideband(), and KIGIT_REPO_MIXIN::SetPushRefusal().

◆ SYNC_WARNING_SOURCE

const wxChar* KIGIT::SYNC_WARNING_SOURCE = wxS( "git" )
inlineconstexpr

The status bar source under which background fetch failures are listed.

Definition at line 63 of file git_credentials_prompt.h.

Referenced by ClearSyncWarnings(), and PROJECT_TREE_PANE::reportGitSyncResult().