39#include <wx/datetime.h>
63 std::vector<wxString>
refs;
149 std::vector<KIGIT_COMMIT_FILE>
files;
246 wxString GetCurrentBranchName()
const;
250 wxString GetHeadCommitId()
const;
254 std::vector<KIGIT_BRANCH_INFO> GetBranches()
const;
266 std::vector<wxString> GetProjectDirs();
273 std::pair<std::set<wxString>,std::set<wxString>> GetDifferentFiles()
const;
316 wxString GetPassword();
317 GIT_CONN_TYPE GetConnType()
const;
320 void SetConnType( GIT_CONN_TYPE aConnType );
335 void SetSSHKey(
const wxString& aSSHKey );
339 wxString GetSSHKey()
const;
343 wxString GetFirstOfferedSSHKey()
const;
381 bool HasLocalCommits()
const;
384 bool HasUpstreamCommits()
const;
387 bool IsPullRebaseConfigured()
const;
390 bool IsHeadDetached()
const;
393 std::optional<size_t> GetUnmergedCommitCount(
const wxString& aBranch )
const;
397 bool HasUncommittedTrackedChanges(
bool* aReadOk =
nullptr )
const;
400 std::vector<wxString> GetRecentCommitMessages(
size_t aMax )
const;
403 std::vector<KIGIT_COMMIT_INFO> GetRecentCommits(
size_t aMax = 50,
const KIGIT_HISTORY_FILTER& aFilter = {} )
const;
407 KIGIT_COMMIT_DETAIL GetCommitDetail(
const wxString& aHash )
const;
412 wxString GetLastCommitMessage()
const;
415 std::vector<KIGIT_STASH_INFO> GetStashes()
const;
418 KIGIT_STASH_DETAIL GetStashDetail(
const wxString& aId )
const;
421 std::vector<KIGIT_TAG_INFO> GetTags()
const;
424 KIGIT_TAG_DETAIL GetTagDetail(
const wxString& aName )
const;
427 bool IsHeadUnborn()
const;
431 bool CreateBranch(
const wxString& aName,
const wxString& aFrom = wxEmptyString );
439 bool StartUnbornBranch(
const wxString& aName );
440 bool DeleteBranch(
const wxString& aName );
443 bool StashSave(
const wxString& aMessage );
444 bool StashApply(
size_t aIndex );
445 bool StashPop(
size_t aIndex );
446 bool StashDrop(
size_t aIndex );
449 bool CreateTag(
const wxString& aName,
const wxString& aMessage = wxEmptyString );
450 bool DeleteTag(
const wxString& aName );
451 bool CheckoutTag(
const wxString& aName );
453 bool AddRemote(
const wxString& aName,
const wxString& aUrl );
454 bool SetRemoteUrl(
const wxString& aName,
const wxString& aUrl );
455 bool RemoveRemote(
const wxString& aName );
457 bool SetUserConfig(
const wxString& aName,
const wxString& aEmail );
463 bool GetMergeConflicts(
const wxString& aStageDir, wxString& aHeadOid, wxString& aTheirsOid,
464 std::vector<KIGIT_CONFLICT_SIDES>& aConflicts, wxString& aError );
471 RestoreResult RestoreVersion(
const wxString& aCommitHash, KIGIT_ERROR_MESSAGE& aError );
477 bool DiscardChanges(
const std::vector<wxString>& aPaths, wxString& aError );
480 bool IsPathInHead(
const wxString& aPath );
483 bool IsPathConflicted(
const wxString& aPath )
const;
486 bool IsOperationInProgress()
const;
492 bool AbandonOperation( wxString& aError );
502 MergeCommitResult CreateMergedCommit(
const wxString& aExpectedHeadOid,
const wxString& aTheirsOid,
503 const std::vector<std::pair<wxString, wxString>>& aResolvedFiles,
504 KIGIT_ERROR_MESSAGE& aError );
507 bool HasPushAndPullRemote()
const;
510 void UpdateCurrentBranchInfo();
517 void SyncRemoteUrl(
const wxString& aRawUrl );
523 void FollowRewrittenUrl(
const wxString& aRawUrl );
525 wxString GetGitRootDirectory()
const;
527 wxString GetRemotename()
const;
530 std::vector<std::pair<wxString, wxString>> GetRemotes()
const;
533 wxDateTime GetLastFetchTime()
const;
537 std::pair<int, int> GetWorkingTreeLineStats(
const std::set<wxString>& aPaths )
const;
541 wxString GetRemoteNameOrDefault()
const;
551 wxString GetProjectDir()
const;
555 std::optional<wxString> GetProjectPrefix()
const;
558 void SetAttachError(
const wxString& aError,
const wxString& aTrustCommand = wxEmptyString )
576 wxString GetNextPublicKey();
599 int HandleSSHKeyAuthentication( git_cred** aOut,
const wxString& aUsername,
KIGIT_AUTH_ATTEMPT& aAttempt );
601 int HandlePlaintextAuthentication( git_cred** aOut,
const wxString& aUsername );
603 int HandleSSHAgentAuthentication( git_cred** aOut,
const wxString& aUsername );
606 static wxString GetLastGitError();
627 std::lock_guard<std::mutex> lock(
m_common->m_operationMutex );
639 std::lock_guard<std::mutex> lock(
m_common->m_operationMutex );
672 int SSHPortFor(
const wxString& aHost )
const;
684 std::unique_lock<std::mutex> TryLockActionFor( std::chrono::milliseconds aWait );
690 void AddRefreshListener(
void* aOwner, std::function<
void()> aCallback );
691 void RemoveRefreshListener(
void* aOwner );
692 void NotifyRefreshListeners();
729 std::optional<KIGIT_AHEAD_BEHIND>
compareRefs(
const git_reference* aBranch,
const git_reference* aBase )
const;
738 wxString remoteNameWithoutUpstream()
const;
740 void updatePublicKeys();
744 void rebuildPublicKeysUnlocked();
745 void updateConnectionType();
748 void updateConnectionTypeUnlocked();
772extern "C" APIEXPORT int update_cb(
const char* aRefname,
const git_oid* aFirst,
const git_oid* aSecond,
775 size_t aBytes,
void* aPayload );
780 const git_oid* aOID,
unsigned int aIsMerge,
void* aPayload );
782 unsigned int aAllowedTypes,
void* aPayload );
854 const std::function<
void(
const git_diff_delta& )>& aCallback );
862 const wxString& aSignOff );
OPERATION_GUARD & operator=(const OPERATION_GUARD &)=delete
OPERATION_GUARD(const OPERATION_GUARD &)=delete
~OPERATION_GUARD()
Only while it is still the published one, or a slow operation finishing would drop a newer one's toke...
OPERATION_GUARD(KIGIT_COMMON *aCommon, const CANCEL_TOKEN &aToken)
std::mutex m_gitActionMutex
std::shared_ptr< std::atomic< bool > > CANCEL_TOKEN
One token per operation.
wxString m_attachTrustCommand
void SyncRemoteUrl(const wxString &aRawUrl)
Bind the session to the URL a transfer is about to connect to.
CANCEL_TOKEN ActiveCancelToken() const
wxString GetRemote() const
std::mutex m_credentialsMutex
Serializes the credential fields between the UI thread and the authentication callback's worker threa...
std::unique_lock< std::mutex > LockAction()
static const unsigned KIGIT_CREDENTIAL_SSH_AGENT
void SetUsername(const wxString &aUsername)
wxString m_publicKeysHost
const wxString & GetAttachError() const
CANCEL_TOKEN m_activeCancel
git_repository * GetRepo() const
KIGIT_COMMON(git_repository *aRepo, const wxString &aProjectPath=wxEmptyString)
aProjectPath is the absolute project directory.
CREDENTIAL_IDENTITY GetCredentialIdentity() const
friend class GIT_CLONE_HANDLER
const wxString & GetAttachTrustCommand() const
The command that trusts a repository another user owns, when that is why attaching failed.
static CANCEL_TOKEN NewCancelToken()
void SetProjectDir(const wxString &aProjectDir)
Keep symlinks in the repository path so Git status paths match the project tree.
std::atomic< unsigned > m_testedTypes
bool ApplyPromptedCredentials(const CREDENTIAL_IDENTITY &aFor, const PROMPTED_CREDENTIALS &aEntered)
Apply what the prompt collected, unless the session has moved to another remote since aFor was taken.
std::vector< std::pair< void *, std::function< void()> > > m_refreshListeners
static constexpr std::chrono::milliseconds ACTION_LOCK_WAIT
Long enough for a status read to finish, short enough that a window does not look hung.
std::vector< wxString > m_publicKeys
bool IsShuttingDown() const
Background timers ask this before starting work of their own.
std::unique_lock< std::mutex > TryLockAction()
wxString GetUsername() const
void SetShuttingDown(bool aCancel)
Stop the operation running now and keep later ones from starting.
std::mutex m_operationMutex
Guarded together, so a shutdown cannot miss an operation registering itself at the same moment.
friend class GIT_PUSH_HANDLER
void updateConnectionTypeUnlocked()
Body of updateConnectionType, for callers that already hold m_credentialsMutex.
std::atomic< unsigned > & TestedTypes()
friend class GIT_PULL_HANDLER
std::vector< wxString > m_discoveredKeys
friend class LIBGIT_BACKEND
static REMOTE_URL ParseRemoteURL(const wxString &aURL)
void SetAttachError(const wxString &aError, const wxString &aTrustCommand=wxEmptyString)
Why binding a repository last failed, for the panels to show. Empty on success.
std::optional< KIGIT_AHEAD_BEHIND > compareRefs(const git_reference *aBranch, const git_reference *aBase) const
Count commits unique to aBranch and aBase. No value if the history cannot be read.
void SetPassword(const wxString &aPassword)
void SetRemote(const wxString &aRemote)
void SetRepo(git_repository *aRepo)
#define APIEXPORT
Macros which export functions from a DLL/DSO.
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.
APIEXPORT int transfer_progress_cb(const git_transfer_progress *aStats, 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 push_transfer_progress_cb(unsigned int aCurrent, unsigned int aTotal, size_t aBytes, void *aPayload)
APIEXPORT int update_cb(const char *aRefname, const git_oid *aFirst, const git_oid *aSecond, void *aPayload)
APIEXPORT int progress_cb(const char *str, int len, void *data)
@ AlreadyCurrent
The chosen version's content matches the current head.
@ Restored
A new commit carrying the old version's content was created.
@ Dirty
Uncommitted changes exist, and restoring would overwrite them.
APIEXPORT void clone_progress_cb(const char *str, size_t len, size_t total, void *data)
bool IsPrivateKeyEncrypted(const wxString &aKeyText)
Report whether an SSH private key is protected by a passphrase.
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.
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 ...
git_tree * ResolveRefToTree(git_repository *aRepo, const wxString &aRef)
Resolve a string ref (branch name, short OID, full OID, tag) to its tree.
wxString BusyMessage()
What every caller says when it finds the session already busy.
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 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.
APIEXPORT wxWindow *& ActiveAdvancedGitWindow()
The advanced git window, or null when none is open.
wxString DecodeRepoText(const char *aText)
Decode text that came out of a repository.
std::vector< wxString > CompareBranchRefs(git_repository *aRepo)
Refs to offer when comparing branches, base first and head second.
size_t behind
Commits only in the second reference.
size_t ahead
Commits only in the first reference.
What the credential callback handed out during one operation, kept to explain a rejection.
std::optional< KIGIT_AHEAD_BEHIND > divergence
Comparison with upstream, if it could be read.
wxString upstream
The branch this one tracks, or empty.
wxDateTime when
That commit's time.
wxString message
Full message of the tip commit.
wxString tipHash
Short hash of the commit the branch points at.
wxString hash
Full commit hash.
std::vector< wxString > parents
Short hashes.
std::vector< KIGIT_COMMIT_FILE > files
std::vector< wxString > refs
As in KIGIT_COMMIT_INFO.
wxString message
Full message, body included.
wxString oldPath
For a rename or copy, where the file came from.
KIGIT::FILE_CHANGE_STATUS status
wxString author
Author name.
wxString email
Author email, used to look up a web avatar.
wxString summary
First line of the commit message.
std::vector< wxString > refs
HEAD, branches and tags at this commit, in that order.
wxString hash
Short commit hash.
wxDateTime when
Commit time.
The remote the credential prompt was opened for.
What the credential prompt collected.
std::optional< wxString > username
A transport address with any embedded credentials extracted.
int port
0 when the address names none.
wxString url
Keeps the SSH username, scheme and port, but never a password.
wxString theirsFile
Extracted remote version, an empty file when absent.
wxString ancestorFile
Extracted common-ancestor version, an empty file when absent.
wxString oursFile
Extracted local version, an empty file when absent.
bool hasOurs
False when the local side deleted the file.
wxString path
Repository-relative path of the conflicted file.
bool hasTheirs
False when the remote side deleted the file.
bool hasAncestor
False when the file did not exist in the common ancestor.
What libgit2 reported for a failed call, read before anything else can replace it.
int code
The failed call's return value.
wxString search
Keep only commits whose summary, author or hash contains this.
wxString path
Keep only commits that changed this file or folder, relative to the root.
wxString branch
One branch, local or remote, or empty for every branch and HEAD.
wxString branch
The branch the stash was taken on, as its message records it.
std::vector< wxString > files
Paths the stash changes, new files included.
wxString message
What was stashed, without the "WIP on branch:" prefix.
wxString baseHash
Short hash of the commit the stash was taken on.
wxString message
The line git writes, such as "WIP on main: 7f8e9d1 subject".
wxString id
Full hash of the stash commit, which does not.
size_t index
Position in the stash list, which shifts as stashes come and go.
wxDateTime when
Time the stash was created.
wxString message
The tag's own message, or the commit's for a lightweight tag.
wxString email
Their email.
wxString name
The tag name.
wxString hash
Short hash of the tagged commit.
wxDateTime when
When the tag was made, or the commit for a lightweight tag.
wxString author
Who made the tag, or the commit for a lightweight tag.
bool found
False when no tag of that name points at a commit.
wxString summary
First line of the tagged commit message.
wxDateTime when
When the tag was made, or the commit for a lightweight tag.
wxString hash
Short hash of the tagged commit.