KiCad PCB EDA Suite
Loading...
Searching...
No Matches
libgit_backend.cpp File Reference
#include "libgit_backend.h"
#include "git_clone_handler.h"
#include "git_commit_handler.h"
#include "git_push_handler.h"
#include "git_status_handler.h"
#include "git_config_handler.h"
#include "git_init_handler.h"
#include "git_branch_handler.h"
#include "git_pull_handler.h"
#include "project_git_utils.h"
#include "kicad_git_common.h"
#include "kicad_git_memory.h"
#include "kigit_failure.h"
#include "trace_helpers.h"
#include "kicad_git_compat.h"
#include <wx/file.h>
#include <wx/filename.h>
#include <wx/log.h>
#include <gestfich.h>
#include <algorithm>
#include <fstream>
#include <iterator>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  SELECTED_STATE
 
struct  STAGED_ENTRY
 
struct  SCRATCH_INDEX_GUARD
 
struct  COMMIT_STAGING
 

Enumerations

enum class  REPUBLISH_RESULT { UPDATED , CHANGED_EXTERNALLY , WRITE_FAILED }
 
enum class  TREE_STATE { CLEAN , DIRTY , UNKNOWN }
 
enum class  PUBLISH_RESULT {
  PUBLISHED , CHECKOUT_FAILED_ROLLED_BACK , CHECKOUT_FAILED_PARTIAL , RECORD_FAILED_ROLLED_BACK ,
  RECORD_FAILED_PARTIAL
}
 

Functions

static KIGIT_ERROR_MESSAGE describeSignatureFailure (int aRc)
 
static void reportRemoteLookupFailure (KIGIT_ERRORS *aHandler, int aRc, const wxString &aRemoteName)
 
static int clone_remote_cb (git_remote **aOut, git_repository *aRepo, const char *aName, const char *aUrl, void *aPayload)
 
static std::map< std::string, SELECTED_STATE > readSelectedState (git_index *aIndex, const std::set< std::string > &aSelected)
 
static std::map< std::string, SELECTED_STATE > readWholeState (git_index *aIndex)
 
static git_index * openIndexOnDisk (git_index *aRepoIndex)
 
static bool selectedStateOnDisk (git_index *aRepoIndex, const std::set< std::string > &aSelected, std::map< std::string, SELECTED_STATE > &aOut)
 
static bool wholeStateOnDisk (git_index *aRepoIndex, std::map< std::string, SELECTED_STATE > &aOut)
 
static bool applySelectedPaths (git_repository *aRepo, git_index *aIndex, const std::vector< wxString > &aFiles)
 
static bool branchMovedSince (git_repository *aRepo, const git_oid &aHeadAtStart, bool aHadHead)
 
static bool selectedPathsRestaged (git_index *aIndex, const std::set< std::string > &aSelected, const std::map< std::string, SELECTED_STATE > &aAtStart)
 
static bool indexChangedSince (git_index *aIndex, const std::map< std::string, SELECTED_STATE > &aAtStart)
 
static REPUBLISH_RESULT republishIndex (git_index *aIndex, const std::vector< STAGED_ENTRY > &aCommitted, const std::set< std::string > &aSelected)
 
static bool refuseWhileOperationInProgress (git_repository *aRepo, git_index *aIndex, wxString &aError)
 
static int lookup_branch_reference (git_repository *repo, const wxString &aBranchName, git_reference **aReference)
 
static bool rollbackWorkingTree (git_repository *aRepo, git_commit *aHeadCommit, git_tree *aWrittenTree)
 
static bool restorePathsFromCommit (git_repository *aRepo, git_commit *aCommit, const std::vector< std::string > &aPaths)
 
static void refreshCachedIndex (git_repository *aRepo)
 
static std::vector< std::string > changedPaths (git_repository *aRepo)
 
static TREE_STATE trackedTreeState (git_repository *aRepo)
 
static bool untrackedFilesOverwrittenBy (git_repository *aRepo, git_tree *aIncomingTree, std::vector< wxString > &aCollisions)
 
static wxString describeUntrackedCollisions (const std::vector< wxString > &aPaths)
 
static PullResult adoptRemoteHistory (GIT_PULL_HANDLER *aHandler, const git_oid &aRemoteOid)
 
static PullResult rebaseOnto (GIT_PULL_HANDLER *aHandler, git_repository *aRepo, const git_annotated_commit *aOnto)
 
static bool applyStashOntoCleanTree (git_repository *aRepo, size_t aIndex)
 
static bool treeHolds (git_tree *aTree, const char *aPath, const git_oid &aOnDisk)
 
static bool safeToRestore (git_repository *aRepo, const char *aPath, git_tree *aPreviousTree, git_tree *aWrittenTree)
 
static PUBLISH_RESULT publishPreparedCommit (git_repository *aRepo, git_tree *aTree, const git_oid &aCommitOid, git_reference *aHeadRef, git_commit *aRollbackCommit, const char *aReflogLabel, wxString &aGitError)
 

Enumeration Type Documentation

◆ PUBLISH_RESULT

enum class PUBLISH_RESULT
strong
Enumerator
PUBLISHED 
CHECKOUT_FAILED_ROLLED_BACK 
CHECKOUT_FAILED_PARTIAL 
RECORD_FAILED_ROLLED_BACK 
RECORD_FAILED_PARTIAL 

Definition at line 2954 of file libgit_backend.cpp.

◆ REPUBLISH_RESULT

enum class REPUBLISH_RESULT
strong
Enumerator
UPDATED 
CHANGED_EXTERNALLY 
WRITE_FAILED 

Definition at line 408 of file libgit_backend.cpp.

◆ TREE_STATE

enum class TREE_STATE
strong
Enumerator
CLEAN 
DIRTY 
UNKNOWN 

Definition at line 1536 of file libgit_backend.cpp.

Function Documentation

◆ adoptRemoteHistory()

◆ applySelectedPaths()

static bool applySelectedPaths ( git_repository * aRepo,
git_index * aIndex,
const std::vector< wxString > & aFiles )
static

Definition at line 353 of file libgit_backend.cpp.

References git_repository, and path.

Referenced by COMMIT_STAGING::BuildTree().

◆ applyStashOntoCleanTree()

static bool applyStashOntoCleanTree ( git_repository * aRepo,
size_t aIndex )
static

◆ branchMovedSince()

static bool branchMovedSince ( git_repository * aRepo,
const git_oid & aHeadAtStart,
bool aHadHead )
static

Definition at line 380 of file libgit_backend.cpp.

References git_repository.

Referenced by COMMIT_STAGING::BuildTree().

◆ changedPaths()

static std::vector< std::string > changedPaths ( git_repository * aRepo)
static

Definition at line 1545 of file libgit_backend.cpp.

References git_repository.

Referenced by applyStashOntoCleanTree(), and ShowGitCommitDiff().

◆ clone_remote_cb()

static int clone_remote_cb ( git_remote ** aOut,
git_repository * aRepo,
const char * aName,
const char * aUrl,
void * aPayload )
static

Definition at line 143 of file libgit_backend.cpp.

References git_repository.

Referenced by LIBGIT_BACKEND::Clone().

◆ describeSignatureFailure()

static KIGIT_ERROR_MESSAGE describeSignatureFailure ( int aRc)
static

◆ describeUntrackedCollisions()

static wxString describeUntrackedCollisions ( const std::vector< wxString > & aPaths)
static

Definition at line 1632 of file libgit_backend.cpp.

References _, and path.

Referenced by adoptRemoteHistory(), LIBGIT_BACKEND::handleFastForward(), and LIBGIT_BACKEND::handleMerge().

◆ indexChangedSince()

static bool indexChangedSince ( git_index * aIndex,
const std::map< std::string, SELECTED_STATE > & aAtStart )
static

◆ lookup_branch_reference()

static int lookup_branch_reference ( git_repository * repo,
const wxString & aBranchName,
git_reference ** aReference )
static

Definition at line 1301 of file libgit_backend.cpp.

References git_repository.

Referenced by LIBGIT_BACKEND::SwitchToBranch().

◆ openIndexOnDisk()

static git_index * openIndexOnDisk ( git_index * aRepoIndex)
static

Definition at line 277 of file libgit_backend.cpp.

Referenced by selectedStateOnDisk(), and wholeStateOnDisk().

◆ publishPreparedCommit()

static PUBLISH_RESULT publishPreparedCommit ( git_repository * aRepo,
git_tree * aTree,
const git_oid & aCommitOid,
git_reference * aHeadRef,
git_commit * aRollbackCommit,
const char * aReflogLabel,
wxString & aGitError )
static

◆ readSelectedState()

static std::map< std::string, SELECTED_STATE > readSelectedState ( git_index * aIndex,
const std::set< std::string > & aSelected )
static

◆ readWholeState()

static std::map< std::string, SELECTED_STATE > readWholeState ( git_index * aIndex)
static

◆ rebaseOnto()

◆ refreshCachedIndex()

static void refreshCachedIndex ( git_repository * aRepo)
static

◆ refuseWhileOperationInProgress()

static bool refuseWhileOperationInProgress ( git_repository * aRepo,
git_index * aIndex,
wxString & aError )
static

Definition at line 458 of file libgit_backend.cpp.

References _, and git_repository.

Referenced by COMMIT_STAGING::Begin().

◆ reportRemoteLookupFailure()

static void reportRemoteLookupFailure ( KIGIT_ERRORS * aHandler,
int aRc,
const wxString & aRemoteName )
static

◆ republishIndex()

static REPUBLISH_RESULT republishIndex ( git_index * aIndex,
const std::vector< STAGED_ENTRY > & aCommitted,
const std::set< std::string > & aSelected )
static

◆ restorePathsFromCommit()

static bool restorePathsFromCommit ( git_repository * aRepo,
git_commit * aCommit,
const std::vector< std::string > & aPaths )
static

Definition at line 2840 of file libgit_backend.cpp.

References git_repository, and path.

Referenced by applyStashOntoCleanTree(), and rollbackWorkingTree().

◆ rollbackWorkingTree()

static bool rollbackWorkingTree ( git_repository * aRepo,
git_commit * aHeadCommit,
git_tree * aWrittenTree )
static

◆ safeToRestore()

static bool safeToRestore ( git_repository * aRepo,
const char * aPath,
git_tree * aPreviousTree,
git_tree * aWrittenTree )
static

Definition at line 2882 of file libgit_backend.cpp.

References git_repository, and treeHolds().

Referenced by rollbackWorkingTree().

◆ selectedPathsRestaged()

static bool selectedPathsRestaged ( git_index * aIndex,
const std::set< std::string > & aSelected,
const std::map< std::string, SELECTED_STATE > & aAtStart )
static

◆ selectedStateOnDisk()

static bool selectedStateOnDisk ( git_index * aRepoIndex,
const std::set< std::string > & aSelected,
std::map< std::string, SELECTED_STATE > & aOut )
static

Definition at line 302 of file libgit_backend.cpp.

References openIndexOnDisk(), and readSelectedState().

Referenced by selectedPathsRestaged().

◆ trackedTreeState()

static TREE_STATE trackedTreeState ( git_repository * aRepo)
static

Definition at line 1576 of file libgit_backend.cpp.

References CLEAN, DIRTY, git_repository, and UNKNOWN.

Referenced by applyStashOntoCleanTree(), and LIBGIT_BACKEND::handleFastForward().

◆ treeHolds()

static bool treeHolds ( git_tree * aTree,
const char * aPath,
const git_oid & aOnDisk )
static

Definition at line 2868 of file libgit_backend.cpp.

Referenced by safeToRestore().

◆ untrackedFilesOverwrittenBy()

static bool untrackedFilesOverwrittenBy ( git_repository * aRepo,
git_tree * aIncomingTree,
std::vector< wxString > & aCollisions )
static

◆ wholeStateOnDisk()

static bool wholeStateOnDisk ( git_index * aRepoIndex,
std::map< std::string, SELECTED_STATE > & aOut )
static