KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_git_common.h File Reference
#include <git/git_backend.h>
#include <git/git_compare_handler.h>
#include <git/kicad_git_errors.h>
#include <git/kigit_known_hosts.h>
#include <import_export.h>
#include <git2.h>
#include <atomic>
#include <chrono>
#include <functional>
#include <mutex>
#include <optional>
#include <set>
#include <utility>
#include <vector>
#include <wx/datetime.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  KIGIT_ERROR_INFO
 What libgit2 reported for a failed call, read before anything else can replace it. More...
 
struct  KIGIT_COMMIT_INFO
 
struct  KIGIT_STASH_DETAIL
 
struct  KIGIT_BRANCH_INFO
 
struct  KIGIT_AHEAD_BEHIND
 
struct  KIGIT_BRANCH_DETAIL
 
struct  KIGIT_HISTORY_FILTER
 
struct  KIGIT_COMMIT_FILE
 
struct  KIGIT_COMMIT_DETAIL
 
struct  KIGIT_STASH_INFO
 
struct  KIGIT_TAG_INFO
 
struct  KIGIT_TAG_DETAIL
 
struct  KIGIT_CONFLICT_SIDES
 
class  KIGIT_COMMON
 The project's git session. More...
 
struct  KIGIT_COMMON::REMOTE_URL
 A transport address with any embedded credentials extracted. More...
 
struct  KIGIT_COMMON::CREDENTIAL_IDENTITY
 The remote the credential prompt was opened for. More...
 
struct  KIGIT_COMMON::PROMPTED_CREDENTIALS
 What the credential prompt collected. More...
 
class  KIGIT_COMMON::OPERATION_GUARD
 Publishes a token for as long as its operation runs. More...
 

Namespaces

namespace  KIGIT
 

Enumerations

enum class  GitOperation {
  None , Merge , Rebase , CherryPick ,
  Revert , Other
}
 
enum class  RestoreResult { Restored , AlreadyCurrent , Dirty , Error }
 

Functions

APIEXPORT int progress_cb (const char *str, int len, void *data)
 
APIEXPORT void clone_progress_cb (const char *str, size_t len, size_t total, void *data)
 
APIEXPORT int transfer_progress_cb (const git_transfer_progress *aStats, void *aPayload)
 
APIEXPORT int update_cb (const char *aRefname, const git_oid *aFirst, const git_oid *aSecond, void *aPayload)
 
APIEXPORT int push_transfer_progress_cb (unsigned int aCurrent, unsigned int aTotal, size_t aBytes, void *aPayload)
 
APIEXPORT int push_update_reference_cb (const char *aRefname, const char *aStatus, void *aPayload)
 
APIEXPORT int fetchhead_foreach_cb (const char *, const char *, const git_oid *aOID, unsigned int aIsMerge, void *aPayload)
 
APIEXPORT int credentials_cb (git_cred **aOut, const char *aUrl, const char *aUsername, unsigned int aAllowedTypes, void *aPayload)
 
APIEXPORT int certificate_check_cb (git_cert *aCert, int aValid, const char *aHost, void *aPayload)
 Check an SSH host key against known_hosts, which decides alone.
 
bool KIGIT::IsPrivateKeyEncrypted (const wxString &aKeyText)
 Report whether an SSH private key is protected by a passphrase.
 
APIEXPORT wxWindow *& KIGIT::ActiveAdvancedGitWindow ()
 The advanced git window, or null when none is open.
 
git_tree * KIGIT::ResolveRefToTree (git_repository *aRepo, const wxString &aRef)
 Resolve a string ref (branch name, short OID, full OID, tag) to its tree.
 
std::vector< wxString > KIGIT::CompareBranchRefs (git_repository *aRepo)
 Refs to offer when comparing branches, base first and head second.
 
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.
 
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.
 
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.
 
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.
 
wxString KIGIT::DecodeRepoText (const char *aText)
 Decode text that came out of a repository.
 
wxString KIGIT::BusyMessage ()
 What every caller says when it finds the session already busy.
 

Enumeration Type Documentation

◆ GitOperation

enum class GitOperation
strong
Enumerator
None 
Merge 
Rebase 
CherryPick 
Revert 
Other 

Definition at line 189 of file kicad_git_common.h.

◆ RestoreResult

enum class RestoreResult
strong
Enumerator
Restored 

A new commit carrying the old version's content was created.

AlreadyCurrent 

The chosen version's content matches the current head.

Dirty 

Uncommitted changes exist, and restoring would overwrite them.

Error 

The restore failed. See the error string.

Definition at line 201 of file kicad_git_common.h.

Function Documentation

◆ certificate_check_cb()

APIEXPORT int certificate_check_cb ( git_cert * aCert,
int aValid,
const char * aHost,
void * aPayload )

Check an SSH host key against known_hosts, which decides alone.

A listed key returns 0, and any other state fails with GIT_ECERTIFICATE and is recorded with KIGIT_REPO_MIXIN::SetHostKeyFailure. A key KiCad cannot read, or a host or port that does not match the synced remote, fails without a record. Other certificates, such as HTTPS ones, are left to libgit2. Never returns a positive value, which libgit2 1.9 takes as accepting an unverified SSH host.

Definition at line 2846 of file kicad_git_common.cpp.

References _, KIGIT::HOST_KEY_FAILURE::fingerprint, KIGIT_REPO_MIXIN::GetCommon(), KIGIT::HOST_KEY_FAILURE::host, KIGIT::HostKeyFingerprint(), KIGIT::HostKeyType(), KIGIT::HOST_KEY_FAILURE::keyType, KIGIT::LookupKnownHost(), KIGIT::MATCH, KIGIT::HOST_KEY_FAILURE::port, KIGIT::HOST_KEY_FAILURE::rawKey, KIGIT::ReadKnownHosts(), KIGIT_REPO_MIXIN::SetHostKeyFailure(), KIGIT_REPO_MIXIN::SetHostKeyRefusal(), KIGIT_COMMON::SSHPortFor(), KIGIT::HOST_KEY_FAILURE::state, and traceGit.

Referenced by LIBGIT_BACKEND::Clone(), DIALOG_GIT_REPOSITORY::OnTestClick(), LIBGIT_BACKEND::PerformFetch(), and LIBGIT_BACKEND::Push().

◆ clone_progress_cb()

APIEXPORT void clone_progress_cb ( const char * str,
size_t len,
size_t total,
void * data )

Definition at line 2622 of file kicad_git_common.cpp.

References KIGIT_REPO_MIXIN::UpdateProgress().

Referenced by LIBGIT_BACKEND::Clone().

◆ credentials_cb()

◆ fetchhead_foreach_cb()

APIEXPORT int fetchhead_foreach_cb ( const char * ,
const char * ,
const git_oid * aOID,
unsigned int aIsMerge,
void * aPayload )

Definition at line 2612 of file kicad_git_common.cpp.

Referenced by LIBGIT_BACKEND::PerformPull().

◆ progress_cb()

APIEXPORT int progress_cb ( const char * str,
int len,
void * data )

◆ push_transfer_progress_cb()

APIEXPORT int push_transfer_progress_cb ( unsigned int aCurrent,
unsigned int aTotal,
size_t aBytes,
void * aPayload )

◆ push_update_reference_cb()

APIEXPORT int push_update_reference_cb ( const char * aRefname,
const char * aStatus,
void * aPayload )

◆ transfer_progress_cb()

APIEXPORT int transfer_progress_cb ( const git_transfer_progress * aStats,
void * aPayload )

◆ update_cb()

APIEXPORT int update_cb ( const char * aRefname,
const git_oid * aFirst,
const git_oid * aSecond,
void * aPayload )

Definition at line 2665 of file kicad_git_common.cpp.

References _, and KIGIT_REPO_MIXIN::UpdateProgress().

Referenced by LIBGIT_BACKEND::Push().