41#include <wx/datetime.h>
65 std::vector<wxString>
refs;
162 std::vector<KIGIT_COMMIT_FILE>
files;
259 wxString GetCurrentBranchName()
const;
263 wxString GetHeadCommitId()
const;
267 std::vector<KIGIT_BRANCH_INFO> GetBranches()
const;
279 std::vector<wxString> GetProjectDirs();
286 std::pair<std::set<wxString>,std::set<wxString>> GetDifferentFiles()
const;
330 wxString GetPassword();
338 static bool DeferForSecret(
const std::shared_ptr<KIGIT_COMMON>& aCommon,
const std::weak_ptr<bool>& aOwner,
339 std::function<
void()> aRetry );
348 GIT_CONN_TYPE GetConnType()
const;
351 void SetConnType( GIT_CONN_TYPE aConnType );
366 void SetSSHKey(
const wxString& aSSHKey );
370 wxString GetSSHKey()
const;
374 wxString GetFirstOfferedSSHKey()
const;
378 wxString GetAcceptedSSHKey()
const;
379 void SetAcceptedSSHKey(
const wxString& aKey );
444 wxString GetLastCommitMessage()
const;
447 std::vector<KIGIT_STASH_INFO> GetStashes()
const;
453 std::vector<KIGIT_TAG_INFO> GetTags()
const;
459 bool IsHeadUnborn()
const;
463 bool CreateBranch(
const wxString& aName,
const wxString& aFrom = wxEmptyString );
471 bool StartUnbornBranch(
const wxString& aName );
472 bool DeleteBranch(
const wxString& aName );
475 bool StashSave(
const wxString& aMessage );
476 bool StashApply(
size_t aIndex );
477 bool StashPop(
size_t aIndex );
478 bool StashDrop(
size_t aIndex );
481 bool CreateTag(
const wxString& aName,
const wxString& aMessage = wxEmptyString );
482 bool DeleteTag(
const wxString& aName );
483 bool CheckoutTag(
const wxString& aName );
485 bool AddRemote(
const wxString& aName,
const wxString& aUrl );
486 bool SetRemoteUrl(
const wxString& aName,
const wxString& aUrl );
487 bool RemoveRemote(
const wxString& aName );
489 bool SetUserConfig(
const wxString& aName,
const wxString& aEmail );
495 bool GetMergeConflicts(
const wxString& aStageDir, wxString& aHeadOid, wxString& aTheirsOid,
496 std::vector<KIGIT_CONFLICT_SIDES>& aConflicts, wxString& aError );
509 bool DiscardChanges(
const std::vector<wxString>& aPaths, wxString& aError );
512 bool IsPathInHead(
const wxString& aPath );
515 bool IsPathConflicted(
const wxString& aPath )
const;
518 bool IsOperationInProgress()
const;
524 bool AbandonOperation( wxString& aError );
534 MergeCommitResult CreateMergedCommit(
const wxString& aExpectedHeadOid,
const wxString& aTheirsOid,
535 const std::vector<std::pair<wxString, wxString>>& aResolvedFiles,
539 bool HasPushAndPullRemote()
const;
542 void UpdateCurrentBranchInfo();
549 void SyncRemoteUrl(
const wxString& aRawUrl );
555 void FollowRewrittenUrl(
const wxString& aRawUrl );
557 wxString GetGitRootDirectory()
const;
559 wxString GetRemotename()
const;
562 std::vector<std::pair<wxString, wxString>> GetRemotes()
const;
565 wxDateTime GetLastFetchTime()
const;
569 std::pair<int, int> GetWorkingTreeLineStats(
const std::set<wxString>& aPaths )
const;
573 wxString GetRemoteNameOrDefault()
const;
576 wxString GetPushUrl(
const wxString& aRemoteName )
const;
586 wxString GetProjectDir()
const;
590 std::optional<wxString> GetProjectPrefix()
const;
593 void SetAttachError(
const wxString& aError,
const wxString& aTrustCommand = wxEmptyString )
612 wxString GetNextPublicKey();
636 static wxString GetLastGitError();
657 std::lock_guard<std::mutex> lock(
m_common->m_operationMutex );
669 std::lock_guard<std::mutex> lock(
m_common->m_operationMutex );
702 int SSHPortFor(
const wxString& aHost )
const;
714 std::unique_lock<std::mutex> TryLockActionFor( std::chrono::milliseconds aWait );
720 void AddRefreshListener(
void* aOwner, std::function<
void()> aCallback );
721 void RemoveRefreshListener(
void* aOwner );
722 void NotifyRefreshListeners();
762 std::optional<KIGIT_AHEAD_BEHIND>
compareRefs(
const git_reference* aBranch,
const git_reference* aBase )
const;
777 wxString remoteNameWithoutUpstream()
const;
779 void updatePublicKeys();
784 void rebuildPublicKeysUnlocked();
785 void updateConnectionType();
788 void updateConnectionTypeUnlocked();
806 const git_oid* aOID,
unsigned int aIsMerge,
void* aPayload );
875 const std::function<
void(
const git_diff_delta& )>& aCallback );
883 const wxString& aSignOff );
The transfers running on one repository, so every window can show and cancel the others'.
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
std::vector< KIGIT_COMMIT_INFO > GetRecentCommits(size_t aMax=50, const KIGIT_HISTORY_FILTER &aFilter={}) const
bool HasUncommittedTrackedChanges(bool *aReadOk=nullptr) const
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()
bool IsPullRebaseConfigured() const
True when the repository is set to rebase rather than merge when getting changes.
void SetUsername(const wxString &aUsername)
wxString m_publicKeysHost
const wxString & GetAttachError() const
CANCEL_TOKEN m_activeCancel
wxString m_acceptedSSHKey
git_repository * GetRepo() const
KIGIT_COMMON(git_repository *aRepo, const wxString &aProjectPath=wxEmptyString)
aProjectPath is the absolute project directory.
CREDENTIAL_IDENTITY GetCredentialIdentity() const
std::vector< wxString > GetRecentCommitMessages(size_t aMax) const
friend class GIT_CLONE_HANDLER
std::optional< size_t > GetUnmergedCommitCount(const wxString &aBranch) const
Commits in aBranch that HEAD does not contain. No value when either cannot be read.
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.
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.
bool secretReadLocked() const
SecretRead() for a caller already holding m_credentialsMutex.
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.
GIT_TRANSFER_BUSY & Transfers()
The transfers running on this repository, which every window shows and may cancel....
friend class GIT_PUSH_HANDLER
void updateConnectionTypeUnlocked()
Body of updateConnectionType, for callers that already hold m_credentialsMutex.
GIT_TRANSFER_BUSY m_transfers
std::optional< KIGIT_UPSTREAM_STATUS > UpstreamStatus() const
The current branch against its upstream.
friend class GIT_PULL_HANDLER
bool HasLocalCommits() const
True when HEAD has commits its upstream does not, or has no upstream yet.
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)
bool IsHeadDetached() const
True when HEAD points at a commit rather than a branch, as after checking out a tag.
void SetRemote(const wxString &aRemote)
void SetRepo(git_repository *aRepo)
bool SecretRead() const
False while the keyring has not been read for the current remote.
#define APIEXPORT
Macros which export functions from a DLL/DSO.
APIEXPORT int fetchhead_foreach_cb(const char *, const char *, const git_oid *aOID, unsigned int aIsMerge, void *aPayload)
@ 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.
bool IsPrivateKeyFileEncrypted(const wxString &aKey)
IsPrivateKeyEncrypted for the key file aKey. A file that cannot be read is reported as unencrypted.
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 ConfiguredSSHCommand(git_repository *aRepo)
git's core.sshCommand for aRepo, or from the user's git config when aRepo is null....
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.
A summary the user can act on, with the raw text that explains it kept apart for the details.
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.
Where the current branch stands against its upstream.
bool HasLocalCommits() const
True when HEAD has commits its upstream does not, or has no upstream yet.
KIGIT_AHEAD_BEHIND divergence
HEAD against its upstream, zero without one.