KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kicad_git_common.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef _GIT_COMMON_H_
21#define _GIT_COMMON_H_
22
23#include <git/git_backend.h>
28#include <import_export.h>
29
30#include <git2.h>
31#include <atomic>
32#include <chrono>
33#include <functional>
34#include <memory>
35#include <mutex>
36#include <optional>
37#include <set>
38#include <utility>
39#include <vector>
40
41#include <wx/datetime.h>
42#include <wx/string.h>
43
44class LIBGIT_BACKEND;
46
47
50{
51 int klass = 0;
52 int code = 0;
53 wxString message;
54};
55
56
57// One entry in the commit history, as shown by the advanced git window's History page.
59{
60 wxString hash;
61 wxString summary;
62 wxString author;
63 wxString email;
64 wxDateTime when;
65 std::vector<wxString> refs;
66};
67
68
69// What the Stashes page's detail pane shows about one stash.
71{
72 bool found = false;
73 wxString message;
74 wxString branch;
75 wxString baseHash;
76 wxDateTime when;
77 std::vector<wxString> files;
78};
79
80
81// A local or remote branch and its tip commit.
83{
84 wxString name;
85 bool isRemote = false;
86 bool isCurrent = false;
87 wxString tipHash;
88 wxString message;
89 wxDateTime when;
90};
91
92
93// Commit counts between two references.
95{
96 size_t ahead = 0;
97 size_t behind = 0;
98};
99
100
103{
104 bool hasUpstream = false;
106
108 bool HasLocalCommits() const { return !hasUpstream || divergence.ahead > 0; }
109};
110
111
112// What the Branches page's detail pane shows about one branch.
114{
115 bool found = false;
116 wxString name;
117 wxString tipHash;
118 wxDateTime when;
119 wxString author;
120 wxString email;
121 wxString message;
122 wxString upstream;
123
125 std::optional<KIGIT_AHEAD_BEHIND> divergence;
126};
127
128
129// Which commits the History page walks.
131{
132 wxString branch;
133 wxString search;
134 wxString path;
135};
136
137
138// One file a commit changed, with its line counts against the parent.
148
149
150// Everything the History page's detail pane shows about one commit.
152{
153 bool found = false;
154 wxString hash;
155 wxString shortHash;
156 wxString message;
157 wxString author;
158 wxString email;
159 wxDateTime when;
160 std::vector<wxString> parents;
161 std::vector<wxString> refs;
162 std::vector<KIGIT_COMMIT_FILE> files;
163 int added = 0;
164 int removed = 0;
165};
166
167
168// One entry in the stash list, as shown by the advanced git window's Stashes page.
170{
171 size_t index = 0;
172 wxString id;
173 wxString message;
174 wxDateTime when;
175};
176
177
178// One entry in the tag list, as shown by the advanced git window's Tags page.
180{
181 wxString name;
182 wxString hash;
183 wxString summary;
184 wxDateTime when;
185};
186
187
188// What the Tags page's detail pane shows about one tag.
190{
191 bool found = false;
192 wxString name;
193 wxString hash;
194 wxDateTime when;
195 wxString author;
196 wxString email;
197 wxString message;
198};
199
200
201// The kind of operation a repository can be left in the middle of.
211
212
213// Outcome of restoring an old version as a new commit.
221
222
223// Each side of a conflicted file, extracted to a temp file. A side that does not exist is empty.
225{
226 wxString path;
227 wxString ancestorFile;
228 wxString oursFile;
229 wxString theirsFile;
230 bool hasAncestor = false;
231 bool hasOurs = false;
232 bool hasTheirs = false;
233};
234
235
243{
244
245public:
248 KIGIT_COMMON( git_repository* aRepo, const wxString& aProjectPath = wxEmptyString );
249 KIGIT_COMMON( const KIGIT_COMMON& aOther );
251
252 git_repository* GetRepo() const;
253
254 void SetRepo( git_repository* aRepo )
255 {
256 m_repo = aRepo;
257 }
258
259 wxString GetCurrentBranchName() const;
260
263 wxString GetHeadCommitId() const;
264
267 std::vector<KIGIT_BRANCH_INFO> GetBranches() const;
268
269 // One branch's tip commit and how it stands to the branch it tracks. Not found leaves the
270 // result's found flag clear.
271 KIGIT_BRANCH_DETAIL GetBranchDetail( const wxString& aBranch ) const;
272
279 std::vector<wxString> GetProjectDirs();
280
286 std::pair<std::set<wxString>,std::set<wxString>> GetDifferentFiles() const;
287
288 enum class GIT_STATUS
289 {
292 GIT_STATUS_MODIFIED, // File changed but not committed to local repository
295 GIT_STATUS_BEHIND, // File changed in remote repository but not in local
296 GIT_STATUS_AHEAD, // File changed in local repository but not in remote
300 };
301
309
312 {
313 wxString url;
314 wxString username;
315 wxString password;
316 wxString hostname;
317 int port = 0;
319 };
320
321 static REMOTE_URL ParseRemoteURL( const wxString& aURL );
322
323 wxString GetUsername() const
324 {
325 std::lock_guard<std::mutex> lock( m_credentialsMutex );
326 return m_username;
327 }
328
330 wxString GetPassword();
331
338 static bool DeferForSecret( const std::shared_ptr<KIGIT_COMMON>& aCommon, const std::weak_ptr<bool>& aOwner,
339 std::function<void()> aRetry );
340
342 bool SecretRead() const
343 {
344 std::lock_guard<std::mutex> lock( m_credentialsMutex );
345 return secretReadLocked();
346 }
347
348 GIT_CONN_TYPE GetConnType() const;
349
351 void SetConnType( GIT_CONN_TYPE aConnType );
352
353 void SetUsername( const wxString& aUsername )
354 {
355 std::lock_guard<std::mutex> lock( m_credentialsMutex );
356 m_username = aUsername;
357 m_secretFetched = false;
358 }
359
360 void SetPassword( const wxString& aPassword )
361 {
362 std::lock_guard<std::mutex> lock( m_credentialsMutex );
363 m_password = aPassword;
364 m_secretFetched = true;
365 }
366 void SetSSHKey( const wxString& aSSHKey );
367
370 wxString GetSSHKey() const;
371
374 wxString GetFirstOfferedSSHKey() const;
375
378 wxString GetAcceptedSSHKey() const;
379 void SetAcceptedSSHKey( const wxString& aKey );
380
389
393 {
395 std::optional<wxString> username;
396 wxString password;
397 wxString sshKey;
398 };
399
401
408 bool ApplyPromptedCredentials( const CREDENTIAL_IDENTITY& aFor, const PROMPTED_CREDENTIALS& aEntered );
409
412 bool HasLocalCommits() const;
413
416 std::optional<KIGIT_UPSTREAM_STATUS> UpstreamStatus() const;
417
419 bool IsPullRebaseConfigured() const;
420
422 bool IsHeadDetached() const;
423
425 std::optional<size_t> GetUnmergedCommitCount( const wxString& aBranch ) const;
426
427 // True when tracked files hold uncommitted changes, staged or not. Untracked files do not
428 // count: a merge leaves them alone. aReadOk distinguishes a clean tree from a failed read.
429 bool HasUncommittedTrackedChanges( bool* aReadOk = nullptr ) const;
430
431 // The full messages of the newest commits from HEAD, newest first, with repeats dropped.
432 std::vector<wxString> GetRecentCommitMessages( size_t aMax ) const;
433
434 // The most recent commits aFilter selects, newest first, up to aMax of them.
435 std::vector<KIGIT_COMMIT_INFO> GetRecentCommits( size_t aMax = 50, const KIGIT_HISTORY_FILTER& aFilter = {} ) const;
436
437 // One commit in full, with the files it changed against its first parent. A root commit's
438 // files all count as added. Not found leaves the result's found flag clear.
439 KIGIT_COMMIT_DETAIL GetCommitDetail( const wxString& aHash ) const;
440
441 // The full message of the commit HEAD points at, body and trailers included. The amend
442 // prefill uses this, so accepting the suggestion does not truncate the message to its
443 // first line.
444 wxString GetLastCommitMessage() const;
445
446 // The stashes in the repository, in the order git reports them (newest first).
447 std::vector<KIGIT_STASH_INFO> GetStashes() const;
448
449 // One stash in full, by its commit id. Not found leaves the result's found flag clear.
450 KIGIT_STASH_DETAIL GetStashDetail( const wxString& aId ) const;
451
452 // The tags in the repository, each resolved to the commit it points at.
453 std::vector<KIGIT_TAG_INFO> GetTags() const;
454
455 // One tag in full. Not found leaves the result's found flag clear.
456 KIGIT_TAG_DETAIL GetTagDetail( const wxString& aName ) const;
457
459 bool IsHeadUnborn() const;
460
461 // The caller holds the action lock, as with the query methods above.
462 // Create aName at the tip of aFrom, a local or remote branch, or at HEAD when aFrom is empty.
463 bool CreateBranch( const wxString& aName, const wxString& aFrom = wxEmptyString );
464
471 bool StartUnbornBranch( const wxString& aName );
472 bool DeleteBranch( const wxString& aName );
473
475 bool StashSave( const wxString& aMessage );
476 bool StashApply( size_t aIndex );
477 bool StashPop( size_t aIndex );
478 bool StashDrop( size_t aIndex );
479
480 // Tag HEAD. With a message the tag is annotated and carries it, otherwise it is lightweight.
481 bool CreateTag( const wxString& aName, const wxString& aMessage = wxEmptyString );
482 bool DeleteTag( const wxString& aName );
483 bool CheckoutTag( const wxString& aName );
484
485 bool AddRemote( const wxString& aName, const wxString& aUrl );
486 bool SetRemoteUrl( const wxString& aName, const wxString& aUrl );
487 bool RemoveRemote( const wxString& aName );
488
489 bool SetUserConfig( const wxString& aName, const wxString& aEmail );
490
495 bool GetMergeConflicts( const wxString& aStageDir, wxString& aHeadOid, wxString& aTheirsOid,
496 std::vector<KIGIT_CONFLICT_SIDES>& aConflicts, wxString& aError );
497
503 RestoreResult RestoreVersion( const wxString& aCommitHash, KIGIT_ERROR_MESSAGE& aError );
504
509 bool DiscardChanges( const std::vector<wxString>& aPaths, wxString& aError );
510
512 bool IsPathInHead( const wxString& aPath );
513
515 bool IsPathConflicted( const wxString& aPath ) const;
516
518 bool IsOperationInProgress() const;
519
521 GitOperation OperationInProgress() const;
522
524 bool AbandonOperation( wxString& aError );
525
534 MergeCommitResult CreateMergedCommit( const wxString& aExpectedHeadOid, const wxString& aTheirsOid,
535 const std::vector<std::pair<wxString, wxString>>& aResolvedFiles,
536 KIGIT_ERROR_MESSAGE& aError );
537
538 // Returns true if the repository has a remote that can be pushed to pulled from
539 bool HasPushAndPullRemote() const;
540
541 // Updates the password and remote information for the repository given the current branch
542 void UpdateCurrentBranchInfo();
543
549 void SyncRemoteUrl( const wxString& aRawUrl );
550
555 void FollowRewrittenUrl( const wxString& aRawUrl );
556
557 wxString GetGitRootDirectory() const;
558
559 wxString GetRemotename() const;
560
562 std::vector<std::pair<wxString, wxString>> GetRemotes() const;
563
564 // When the repository last fetched, from any remote. Invalid when it never has.
565 wxDateTime GetLastFetchTime() const;
566
567 // Lines added and removed in the working tree against HEAD, new files included. Only for
568 // aPaths, relative to the repository root, so the count matches the list beside it.
569 std::pair<int, int> GetWorkingTreeLineStats( const std::set<wxString>& aPaths ) const;
570
573 wxString GetRemoteNameOrDefault() const;
574
576 wxString GetPushUrl( const wxString& aRemoteName ) const;
577
581 void SetProjectDir( const wxString& aProjectDir ) { m_projectDir = aProjectDir; }
582
586 wxString GetProjectDir() const;
587
590 std::optional<wxString> GetProjectPrefix() const;
591
593 void SetAttachError( const wxString& aError, const wxString& aTrustCommand = wxEmptyString )
594 {
595 m_attachError = aError;
596 m_attachTrustCommand = aTrustCommand;
597 }
598
599 const wxString& GetAttachError() const { return m_attachError; }
600
602 const wxString& GetAttachTrustCommand() const { return m_attachTrustCommand; }
603
606 void ResetNextKey();
607
609 void RememberWorkingSSHKey( const KIGIT_AUTH_ATTEMPT& aAttempt );
610
612 wxString GetNextPublicKey();
613
614 void SetRemote( const wxString& aRemote )
615 {
616 {
617 std::lock_guard<std::mutex> lock( m_credentialsMutex );
618 m_remote = aRemote;
619 m_password.clear();
620 m_secretFetched = false;
621 m_acceptedSSHKey.clear();
623 }
624
625 // Gathers the keys now, or the first transfer's sync would drop a key chosen after this
626 SyncRemoteUrl( aRemote );
627 }
628
629 wxString GetRemote() const
630 {
631 std::lock_guard<std::mutex> lock( m_credentialsMutex );
632 return m_remote;
633 }
634
636 static wxString GetLastGitError();
637
640 static KIGIT_ERROR_INFO GetLastGitErrorInfo( int aCode );
641
644 using CANCEL_TOKEN = std::shared_ptr<std::atomic<bool>>;
645
646 static CANCEL_TOKEN NewCancelToken() { return std::make_shared<std::atomic<bool>>( false ); }
647
651 {
652 public:
653 OPERATION_GUARD( KIGIT_COMMON* aCommon, const CANCEL_TOKEN& aToken ) :
654 m_common( aCommon ),
655 m_token( aToken )
656 {
657 std::lock_guard<std::mutex> lock( m_common->m_operationMutex );
658 m_common->m_activeCancel = m_token;
659
660 // A shutdown asked for before this operation reached the lock still applies to it.
661 if( m_token && m_common->m_shutdown )
662 m_token->store( true );
663 }
664
668 {
669 std::lock_guard<std::mutex> lock( m_common->m_operationMutex );
670
671 if( m_common->m_activeCancel == m_token )
672 m_common->m_activeCancel.reset();
673 }
674
677
678 private:
681 };
682
684 bool IsShuttingDown() const
685 {
686 std::lock_guard<std::mutex> lock( m_operationMutex );
687 return m_shutdown;
688 }
689
691 void SetShuttingDown( bool aCancel )
692 {
693 std::lock_guard<std::mutex> lock( m_operationMutex );
694 m_shutdown = aCancel;
695
696 if( aCancel && m_activeCancel )
697 m_activeCancel->store( true );
698 }
699
702 int SSHPortFor( const wxString& aHost ) const;
703
704 std::unique_lock<std::mutex> TryLockAction()
705 {
706 return std::unique_lock<std::mutex>( m_gitActionMutex, std::try_to_lock );
707 }
708
710 static constexpr std::chrono::milliseconds ACTION_LOCK_WAIT{ 2000 };
711
714 std::unique_lock<std::mutex> TryLockActionFor( std::chrono::milliseconds aWait );
715
716 std::unique_lock<std::mutex> LockAction() { return std::unique_lock<std::mutex>( m_gitActionMutex ); }
717
718 // Views showing working-tree state register here, so a commit, push or pull in one of them
719 // refreshes the others. UI thread only, so the list needs no lock.
720 void AddRefreshListener( void* aOwner, std::function<void()> aCallback );
721 void RemoveRefreshListener( void* aOwner );
722 void NotifyRefreshListeners();
723
726
727protected:
729
730 wxString m_projectDir; // Repository working directory preserving symlinks
731 wxString m_projectPath; // Project directory captured when the session was created
734
736 wxString m_remote; // This is the full connection string
737 wxString m_urlUsername; // The username m_remote was parsed with, which HTTPS strips from it
738 wxString m_hostname; // This is just the hostname without the protocol, username, or password
739 int m_port = 0; // The port m_remote names, 0 when it names none and -1 when it is not valid
740 wxString m_username;
741 wxString m_password;
742
744
748 mutable std::mutex m_credentialsMutex;
749
750 std::vector<std::pair<void*, std::function<void()>>> m_refreshListeners;
751
753
754 // Make git handlers friends so they can access the mutex
755 friend class GIT_PUSH_HANDLER;
756 friend class GIT_PULL_HANDLER;
757 friend class GIT_CLONE_HANDLER;
758 friend class LIBGIT_BACKEND;
759
760private:
762 std::optional<KIGIT_AHEAD_BEHIND> compareRefs( const git_reference* aBranch, const git_reference* aBase ) const;
763
765 {
766 std::lock_guard<std::mutex> lock( m_operationMutex );
767 return m_activeCancel;
768 }
769
771 bool secretReadLocked() const
772 {
774 }
775
777 wxString remoteNameWithoutUpstream() const;
778
779 void updatePublicKeys();
780
784 void rebuildPublicKeysUnlocked();
785 void updateConnectionType();
786
788 void updateConnectionTypeUnlocked();
789
790 std::vector<wxString> m_discoveredKeys; // Gathered for m_publicKeysHost, without the project key
791 std::vector<wxString> m_publicKeys;
792 wxString m_publicKeysHost; // The host m_publicKeys was gathered for
793 wxString m_projectSSHKey; // Kept when its file is missing, so the setting is not lost
794 wxString m_acceptedSSHKey; // An encrypted key the server took for m_remote, still to be unlocked
797
800 mutable std::mutex m_operationMutex;
802 bool m_shutdown = false;
803};
804
805extern "C" APIEXPORT int fetchhead_foreach_cb( const char*, const char*,
806 const git_oid* aOID, unsigned int aIsMerge, void* aPayload );
807
808
809class wxWindow;
810
811
812namespace KIGIT
813{
814
821APIEXPORT bool IsPrivateKeyEncrypted( const wxString& aKeyText );
822
824APIEXPORT bool IsPrivateKeyFileEncrypted( const wxString& aKey );
825
828
829
837
838
851APIEXPORT git_tree* ResolveRefToTree( git_repository* aRepo, const wxString& aRef );
852
853
861APIEXPORT std::vector<wxString> CompareBranchRefs( git_repository* aRepo );
862
863
874APIEXPORT void CollectDiffDeltas( git_diff* aDiff,
875 const std::function<void( const git_diff_delta& )>& aCallback );
876
882APIEXPORT wxString ComposeCommitMessage( const wxString& aSummary, const wxString& aDescription,
883 const wxString& aSignOff );
884
886APIEXPORT void SplitCommitMessage( const wxString& aMessage, wxString& aSummary, wxString& aDescription );
887
890APIEXPORT wxString BranchNameError( const wxString& aName );
891
894APIEXPORT wxString DecodeRepoText( const char* aText );
895
898APIEXPORT wxString BusyMessage();
899
900} // namespace KIGIT
901
902
903#endif // _GIT_COMMON_H_
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
git_repository * m_repo
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.
wxString m_projectPath
wxString m_urlUsername
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
wxString m_projectDir
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....
GIT_CONN_TYPE m_connType
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.
wxString m_attachError
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)
wxString m_projectSSHKey
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.
MergeCommitResult
Definition git_backend.h:83
#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)
GitOperation
RestoreResult
@ 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 klass
git_error_t
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 name
Tag name.
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.