KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_git_common.cpp File Reference
#include "kicad_git_common.h"
#include "kicad_git_memory.h"
#include "git_repo_mixin.h"
#include "git_backend.h"
#include "kigit_ssh_keys.h"
#include "project_git_utils.h"
#include <git/git_progress.h>
#include <git/kicad_git_compat.h>
#include <kiplatform/secrets.h>
#include <trace_helpers.h>
#include <git2.h>
#include <wx/arrstr.h>
#include <wx/base64.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/utils.h>
#include <algorithm>
#include <cctype>
#include <cerrno>
#include <chrono>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <string>
#include <thread>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  KIGIT
 

Functions

static size_t findUserinfoAt (const wxString &aUrl)
 
static wxString decodePercent (const wxString &aText)
 
static int parsePort (const wxString &aPort)
 
static bool isScpIpv6 (const wxString &aText, size_t aBracket)
 
static bool scpHasUser (const wxString &aText, size_t aStart)
 
static bool parseScpAddress (const wxString &aURL, wxString &aUser, wxString &aHost, wxString &aPort)
 
int fetchhead_foreach_cb (const char *, const char *, const git_oid *aOID, unsigned int aIsMerge, void *aPayload)
 
void clone_progress_cb (const char *aStr, size_t aLen, size_t aTotal, void *aPayload)
 
int progress_cb (const char *str, int len, void *aPayload)
 
int transfer_progress_cb (const git_transfer_progress *aStats, void *aPayload)
 
int update_cb (const char *aRefname, const git_oid *aFirst, const git_oid *aSecond, void *aPayload)
 
int push_transfer_progress_cb (unsigned int aCurrent, unsigned int aTotal, size_t aBytes, void *aPayload)
 
int push_update_reference_cb (const char *aRefname, const char *aStatus, void *aPayload)
 
int credentials_cb (git_cred **aOut, const char *aUrl, const char *aUsername, unsigned int aAllowedTypes, void *aPayload)
 
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.
 
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::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.
 
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.
 

Function Documentation

◆ certificate_check_cb()

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

void clone_progress_cb ( const char * aStr,
size_t aLen,
size_t aTotal,
void * aPayload )

Definition at line 2622 of file kicad_git_common.cpp.

References KIGIT_REPO_MIXIN::UpdateProgress().

Referenced by LIBGIT_BACKEND::Clone().

◆ credentials_cb()

◆ decodePercent()

static wxString decodePercent ( const wxString & aText)
static

Definition at line 2188 of file kicad_git_common.cpp.

References decoded(), result, and text.

Referenced by KIGIT_COMMON::ParseRemoteURL().

◆ fetchhead_foreach_cb()

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

◆ findUserinfoAt()

static size_t findUserinfoAt ( const wxString & aUrl)
static

Definition at line 2139 of file kicad_git_common.cpp.

Referenced by KIGIT_COMMON::ParseRemoteURL().

◆ isScpIpv6()

static bool isScpIpv6 ( const wxString & aText,
size_t aBracket )
static

Definition at line 2229 of file kicad_git_common.cpp.

Referenced by parseScpAddress().

◆ parsePort()

static int parsePort ( const wxString & aPort)
static

Definition at line 2215 of file kicad_git_common.cpp.

Referenced by KIGIT_COMMON::ParseRemoteURL().

◆ parseScpAddress()

static bool parseScpAddress ( const wxString & aURL,
wxString & aUser,
wxString & aHost,
wxString & aPort )
static

Definition at line 2267 of file kicad_git_common.cpp.

References isScpIpv6(), NONE, PORT, scpHasUser(), and USER.

Referenced by KIGIT_COMMON::ParseRemoteURL().

◆ progress_cb()

int progress_cb ( const char * str,
int len,
void * aPayload )

◆ push_transfer_progress_cb()

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

◆ push_update_reference_cb()

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

◆ scpHasUser()

static bool scpHasUser ( const wxString & aText,
size_t aStart )
static

Definition at line 2251 of file kicad_git_common.cpp.

Referenced by parseScpAddress().

◆ transfer_progress_cb()

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

◆ update_cb()

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