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>
27#include <import_export.h>
28
29#include <git2.h>
30#include <atomic>
31#include <chrono>
32#include <functional>
33#include <mutex>
34#include <optional>
35#include <set>
36#include <utility>
37#include <vector>
38
39#include <wx/datetime.h>
40#include <wx/string.h>
41
42class LIBGIT_BACKEND;
44
45
48{
49 int klass = 0;
50 int code = 0;
51 wxString message;
52};
53
54
55// One entry in the commit history, as shown by the advanced git window's History page.
57{
58 wxString hash;
59 wxString summary;
60 wxString author;
61 wxString email;
62 wxDateTime when;
63 std::vector<wxString> refs;
64};
65
66
67// What the Stashes page's detail pane shows about one stash.
69{
70 bool found = false;
71 wxString message;
72 wxString branch;
73 wxString baseHash;
74 wxDateTime when;
75 std::vector<wxString> files;
76};
77
78
79// A local or remote branch and its tip commit.
81{
82 wxString name;
83 bool isRemote = false;
84 bool isCurrent = false;
85 wxString tipHash;
86 wxString message;
87 wxDateTime when;
88};
89
90
91// Commit counts between two references.
93{
94 size_t ahead = 0;
95 size_t behind = 0;
96};
97
98
99// What the Branches page's detail pane shows about one branch.
101{
102 bool found = false;
103 wxString name;
104 wxString tipHash;
105 wxDateTime when;
106 wxString author;
107 wxString email;
108 wxString message;
109 wxString upstream;
110
112 std::optional<KIGIT_AHEAD_BEHIND> divergence;
113};
114
115
116// Which commits the History page walks.
118{
119 wxString branch;
120 wxString search;
121 wxString path;
122};
123
124
125// One file a commit changed, with its line counts against the parent.
135
136
137// Everything the History page's detail pane shows about one commit.
139{
140 bool found = false;
141 wxString hash;
142 wxString shortHash;
143 wxString message;
144 wxString author;
145 wxString email;
146 wxDateTime when;
147 std::vector<wxString> parents;
148 std::vector<wxString> refs;
149 std::vector<KIGIT_COMMIT_FILE> files;
150 int added = 0;
151 int removed = 0;
152};
153
154
155// One entry in the stash list, as shown by the advanced git window's Stashes page.
157{
158 size_t index = 0;
159 wxString id;
160 wxString message;
161 wxDateTime when;
162};
163
164
165// One entry in the tag list, as shown by the advanced git window's Tags page.
167{
168 wxString name;
169 wxString hash;
170 wxString summary;
171 wxDateTime when;
172};
173
174
175// What the Tags page's detail pane shows about one tag.
177{
178 bool found = false;
179 wxString name;
180 wxString hash;
181 wxDateTime when;
182 wxString author;
183 wxString email;
184 wxString message;
185};
186
187
188// The kind of operation a repository can be left in the middle of.
198
199
200// Outcome of restoring an old version as a new commit.
208
209
210// Each side of a conflicted file, extracted to a temp file. A side that does not exist is empty.
212{
213 wxString path;
214 wxString ancestorFile;
215 wxString oursFile;
216 wxString theirsFile;
217 bool hasAncestor = false;
218 bool hasOurs = false;
219 bool hasTheirs = false;
220};
221
222
230{
231
232public:
235 KIGIT_COMMON( git_repository* aRepo, const wxString& aProjectPath = wxEmptyString );
236 KIGIT_COMMON( const KIGIT_COMMON& aOther );
238
239 git_repository* GetRepo() const;
240
241 void SetRepo( git_repository* aRepo )
242 {
243 m_repo = aRepo;
244 }
245
246 wxString GetCurrentBranchName() const;
247
250 wxString GetHeadCommitId() const;
251
254 std::vector<KIGIT_BRANCH_INFO> GetBranches() const;
255
256 // One branch's tip commit and how it stands to the branch it tracks. Not found leaves the
257 // result's found flag clear.
258 KIGIT_BRANCH_DETAIL GetBranchDetail( const wxString& aBranch ) const;
259
266 std::vector<wxString> GetProjectDirs();
267
273 std::pair<std::set<wxString>,std::set<wxString>> GetDifferentFiles() const;
274
275 enum class GIT_STATUS
276 {
279 GIT_STATUS_MODIFIED, // File changed but not committed to local repository
282 GIT_STATUS_BEHIND, // File changed in remote repository but not in local
283 GIT_STATUS_AHEAD, // File changed in local repository but not in remote
287 };
288
296
299 {
300 wxString url;
301 wxString username;
302 wxString password;
303 wxString hostname;
304 int port = 0;
306 };
307
308 static REMOTE_URL ParseRemoteURL( const wxString& aURL );
309
310 wxString GetUsername() const
311 {
312 std::lock_guard<std::mutex> lock( m_credentialsMutex );
313 return m_username;
314 }
315
316 wxString GetPassword();
317 GIT_CONN_TYPE GetConnType() const;
318
320 void SetConnType( GIT_CONN_TYPE aConnType );
321
322 void SetUsername( const wxString& aUsername )
323 {
324 std::lock_guard<std::mutex> lock( m_credentialsMutex );
325 m_username = aUsername;
326 m_secretFetched = false;
327 }
328
329 void SetPassword( const wxString& aPassword )
330 {
331 std::lock_guard<std::mutex> lock( m_credentialsMutex );
332 m_password = aPassword;
333 m_secretFetched = true;
334 }
335 void SetSSHKey( const wxString& aSSHKey );
336
339 wxString GetSSHKey() const;
340
343 wxString GetFirstOfferedSSHKey() const;
344
347 wxString GetAcceptedSSHKey() const;
348 void SetAcceptedSSHKey( const wxString& aKey );
349
358
362 {
364 std::optional<wxString> username;
365 wxString password;
366 wxString sshKey;
367 };
368
370
377 bool ApplyPromptedCredentials( const CREDENTIAL_IDENTITY& aFor, const PROMPTED_CREDENTIALS& aEntered );
378
379 // Holds a temporary variable that can be used by the authentication callback
380 // to remember which types of authentication have been tested so that we
381 // don't loop forever.
382 std::atomic<unsigned>& TestedTypes() { return m_testedTypes; }
383
386 bool HasLocalCommits() const;
387
389 bool HasUpstreamCommits() const;
390
392 bool IsPullRebaseConfigured() const;
393
395 bool IsHeadDetached() const;
396
398 std::optional<size_t> GetUnmergedCommitCount( const wxString& aBranch ) const;
399
400 // True when tracked files hold uncommitted changes, staged or not. Untracked files do not
401 // count: a merge leaves them alone. aReadOk distinguishes a clean tree from a failed read.
402 bool HasUncommittedTrackedChanges( bool* aReadOk = nullptr ) const;
403
404 // The full messages of the newest commits from HEAD, newest first, with repeats dropped.
405 std::vector<wxString> GetRecentCommitMessages( size_t aMax ) const;
406
407 // The most recent commits aFilter selects, newest first, up to aMax of them.
408 std::vector<KIGIT_COMMIT_INFO> GetRecentCommits( size_t aMax = 50, const KIGIT_HISTORY_FILTER& aFilter = {} ) const;
409
410 // One commit in full, with the files it changed against its first parent. A root commit's
411 // files all count as added. Not found leaves the result's found flag clear.
412 KIGIT_COMMIT_DETAIL GetCommitDetail( const wxString& aHash ) const;
413
414 // The full message of the commit HEAD points at, body and trailers included. The amend
415 // prefill uses this, so accepting the suggestion does not truncate the message to its
416 // first line.
417 wxString GetLastCommitMessage() const;
418
419 // The stashes in the repository, in the order git reports them (newest first).
420 std::vector<KIGIT_STASH_INFO> GetStashes() const;
421
422 // One stash in full, by its commit id. Not found leaves the result's found flag clear.
423 KIGIT_STASH_DETAIL GetStashDetail( const wxString& aId ) const;
424
425 // The tags in the repository, each resolved to the commit it points at.
426 std::vector<KIGIT_TAG_INFO> GetTags() const;
427
428 // One tag in full. Not found leaves the result's found flag clear.
429 KIGIT_TAG_DETAIL GetTagDetail( const wxString& aName ) const;
430
432 bool IsHeadUnborn() const;
433
434 // The caller holds the action lock, as with the query methods above.
435 // Create aName at the tip of aFrom, a local or remote branch, or at HEAD when aFrom is empty.
436 bool CreateBranch( const wxString& aName, const wxString& aFrom = wxEmptyString );
437
444 bool StartUnbornBranch( const wxString& aName );
445 bool DeleteBranch( const wxString& aName );
446
448 bool StashSave( const wxString& aMessage );
449 bool StashApply( size_t aIndex );
450 bool StashPop( size_t aIndex );
451 bool StashDrop( size_t aIndex );
452
453 // Tag HEAD. With a message the tag is annotated and carries it, otherwise it is lightweight.
454 bool CreateTag( const wxString& aName, const wxString& aMessage = wxEmptyString );
455 bool DeleteTag( const wxString& aName );
456 bool CheckoutTag( const wxString& aName );
457
458 bool AddRemote( const wxString& aName, const wxString& aUrl );
459 bool SetRemoteUrl( const wxString& aName, const wxString& aUrl );
460 bool RemoveRemote( const wxString& aName );
461
462 bool SetUserConfig( const wxString& aName, const wxString& aEmail );
463
468 bool GetMergeConflicts( const wxString& aStageDir, wxString& aHeadOid, wxString& aTheirsOid,
469 std::vector<KIGIT_CONFLICT_SIDES>& aConflicts, wxString& aError );
470
476 RestoreResult RestoreVersion( const wxString& aCommitHash, KIGIT_ERROR_MESSAGE& aError );
477
482 bool DiscardChanges( const std::vector<wxString>& aPaths, wxString& aError );
483
485 bool IsPathInHead( const wxString& aPath );
486
488 bool IsPathConflicted( const wxString& aPath ) const;
489
491 bool IsOperationInProgress() const;
492
494 GitOperation OperationInProgress() const;
495
497 bool AbandonOperation( wxString& aError );
498
507 MergeCommitResult CreateMergedCommit( const wxString& aExpectedHeadOid, const wxString& aTheirsOid,
508 const std::vector<std::pair<wxString, wxString>>& aResolvedFiles,
509 KIGIT_ERROR_MESSAGE& aError );
510
511 // Returns true if the repository has a remote that can be pushed to pulled from
512 bool HasPushAndPullRemote() const;
513
514 // Updates the password and remote information for the repository given the current branch
515 void UpdateCurrentBranchInfo();
516
522 void SyncRemoteUrl( const wxString& aRawUrl );
523
528 void FollowRewrittenUrl( const wxString& aRawUrl );
529
530 wxString GetGitRootDirectory() const;
531
532 wxString GetRemotename() const;
533
535 std::vector<std::pair<wxString, wxString>> GetRemotes() const;
536
537 // When the repository last fetched, from any remote. Invalid when it never has.
538 wxDateTime GetLastFetchTime() const;
539
540 // Lines added and removed in the working tree against HEAD, new files included. Only for
541 // aPaths, relative to the repository root, so the count matches the list beside it.
542 std::pair<int, int> GetWorkingTreeLineStats( const std::set<wxString>& aPaths ) const;
543
546 wxString GetRemoteNameOrDefault() const;
547
551 void SetProjectDir( const wxString& aProjectDir ) { m_projectDir = aProjectDir; }
552
556 wxString GetProjectDir() const;
557
560 std::optional<wxString> GetProjectPrefix() const;
561
563 void SetAttachError( const wxString& aError, const wxString& aTrustCommand = wxEmptyString )
564 {
565 m_attachError = aError;
566 m_attachTrustCommand = aTrustCommand;
567 }
568
569 const wxString& GetAttachError() const { return m_attachError; }
570
572 const wxString& GetAttachTrustCommand() const { return m_attachTrustCommand; }
573
576 void ResetNextKey();
577
579 void RememberWorkingSSHKey( const KIGIT_AUTH_ATTEMPT& aAttempt );
580
582 wxString GetNextPublicKey();
583
584 void SetRemote( const wxString& aRemote )
585 {
586 {
587 std::lock_guard<std::mutex> lock( m_credentialsMutex );
588 m_remote = aRemote;
589 m_password.clear();
590 m_secretFetched = false;
591 m_acceptedSSHKey.clear();
593 }
594
595 // Gathers the keys now, or the first transfer's sync would drop a key chosen after this
596 SyncRemoteUrl( aRemote );
597 }
598
599 wxString GetRemote() const
600 {
601 std::lock_guard<std::mutex> lock( m_credentialsMutex );
602 return m_remote;
603 }
604
606 int HandleSSHKeyAuthentication( git_cred** aOut, const wxString& aUsername, KIGIT_AUTH_ATTEMPT& aAttempt );
607
608 int HandlePlaintextAuthentication( git_cred** aOut, const wxString& aUsername );
609
610 int HandleSSHAgentAuthentication( git_cred** aOut, const wxString& aUsername );
611
613 static wxString GetLastGitError();
614
617 static KIGIT_ERROR_INFO GetLastGitErrorInfo( int aCode );
618
621 using CANCEL_TOKEN = std::shared_ptr<std::atomic<bool>>;
622
623 static CANCEL_TOKEN NewCancelToken() { return std::make_shared<std::atomic<bool>>( false ); }
624
628 {
629 public:
630 OPERATION_GUARD( KIGIT_COMMON* aCommon, const CANCEL_TOKEN& aToken ) :
631 m_common( aCommon ),
632 m_token( aToken )
633 {
634 std::lock_guard<std::mutex> lock( m_common->m_operationMutex );
635 m_common->m_activeCancel = m_token;
636
637 // A shutdown asked for before this operation reached the lock still applies to it.
638 if( m_token && m_common->m_shutdown )
639 m_token->store( true );
640 }
641
645 {
646 std::lock_guard<std::mutex> lock( m_common->m_operationMutex );
647
648 if( m_common->m_activeCancel == m_token )
649 m_common->m_activeCancel.reset();
650 }
651
654
655 private:
658 };
659
661 bool IsShuttingDown() const
662 {
663 std::lock_guard<std::mutex> lock( m_operationMutex );
664 return m_shutdown;
665 }
666
668 void SetShuttingDown( bool aCancel )
669 {
670 std::lock_guard<std::mutex> lock( m_operationMutex );
671 m_shutdown = aCancel;
672
673 if( aCancel && m_activeCancel )
674 m_activeCancel->store( true );
675 }
676
679 int SSHPortFor( const wxString& aHost ) const;
680
681 std::unique_lock<std::mutex> TryLockAction()
682 {
683 return std::unique_lock<std::mutex>( m_gitActionMutex, std::try_to_lock );
684 }
685
687 static constexpr std::chrono::milliseconds ACTION_LOCK_WAIT{ 2000 };
688
691 std::unique_lock<std::mutex> TryLockActionFor( std::chrono::milliseconds aWait );
692
693 std::unique_lock<std::mutex> LockAction() { return std::unique_lock<std::mutex>( m_gitActionMutex ); }
694
695 // Views showing working-tree state register here, so a commit, push or pull in one of them
696 // refreshes the others. UI thread only, so the list needs no lock.
697 void AddRefreshListener( void* aOwner, std::function<void()> aCallback );
698 void RemoveRefreshListener( void* aOwner );
699 void NotifyRefreshListeners();
700
701protected:
703
704 wxString m_projectDir; // Repository working directory preserving symlinks
705 wxString m_projectPath; // Project directory captured when the session was created
708
710 wxString m_remote; // This is the full connection string
711 wxString m_urlUsername; // The username m_remote was parsed with, which HTTPS strips from it
712 wxString m_hostname; // This is just the hostname without the protocol, username, or password
713 int m_port = 0; // The port m_remote names, 0 when it names none and -1 when it is not valid
714 wxString m_username;
715 wxString m_password;
716
717 std::atomic<unsigned> m_testedTypes;
718
720
724 mutable std::mutex m_credentialsMutex;
725
726 std::vector<std::pair<void*, std::function<void()>>> m_refreshListeners;
727
728 // Make git handlers friends so they can access the mutex
729 friend class GIT_PUSH_HANDLER;
730 friend class GIT_PULL_HANDLER;
731 friend class GIT_CLONE_HANDLER;
732 friend class LIBGIT_BACKEND;
733
734private:
736 std::optional<KIGIT_AHEAD_BEHIND> compareRefs( const git_reference* aBranch, const git_reference* aBase ) const;
737
739 {
740 std::lock_guard<std::mutex> lock( m_operationMutex );
741 return m_activeCancel;
742 }
743
745 wxString remoteNameWithoutUpstream() const;
746
747 void updatePublicKeys();
748
752 void rebuildPublicKeysUnlocked();
753 void updateConnectionType();
754
756 void updateConnectionTypeUnlocked();
757
758 std::vector<wxString> m_discoveredKeys; // Gathered for m_publicKeysHost, without the project key
759 std::vector<wxString> m_publicKeys;
760 wxString m_publicKeysHost; // The host m_publicKeys was gathered for
761 wxString m_projectSSHKey; // Kept when its file is missing, so the setting is not lost
762 wxString m_acceptedSSHKey; // An encrypted key the server took for m_remote, still to be unlocked
765
768 mutable std::mutex m_operationMutex;
770 bool m_shutdown = false;
771
772 // Create a dummy flag to tell if we have tested ssh agent credentials separately
773 // from the ssh key credentials. Our own bit, so it must clear every git_credential_t
774 // value. The highest is GIT_CREDENTIAL_SSH_MEMORY at 1 << 6.
775 static const unsigned KIGIT_CREDENTIAL_SSH_AGENT = 1u << ( sizeof( unsigned ) * 8 - 1 );
776};
777
778extern "C" APIEXPORT int progress_cb( const char* str, int len, void* data );
779extern "C" APIEXPORT void clone_progress_cb( const char* str, size_t len, size_t total, void* data );
780extern "C" APIEXPORT int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload );
781extern "C" APIEXPORT int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond,
782 void* aPayload );
783extern "C" APIEXPORT int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal,
784 size_t aBytes, void* aPayload );
785extern "C" APIEXPORT int push_update_reference_cb( const char* aRefname, const char* aStatus,
786 void* aPayload );
787
788extern "C" APIEXPORT int fetchhead_foreach_cb( const char*, const char*,
789 const git_oid* aOID, unsigned int aIsMerge, void* aPayload );
790extern "C" APIEXPORT int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername,
791 unsigned int aAllowedTypes, void* aPayload );
792
800extern "C" APIEXPORT int certificate_check_cb( git_cert* aCert, int aValid, const char* aHost, void* aPayload );
801
802
803class wxWindow;
804
805
806namespace KIGIT
807{
808
815APIEXPORT bool IsPrivateKeyEncrypted( const wxString& aKeyText );
816
818APIEXPORT bool IsPrivateKeyFileEncrypted( const wxString& aKey );
819
822
823
831
832
845APIEXPORT git_tree* ResolveRefToTree( git_repository* aRepo, const wxString& aRef );
846
847
855APIEXPORT std::vector<wxString> CompareBranchRefs( git_repository* aRepo );
856
857
868APIEXPORT void CollectDiffDeltas( git_diff* aDiff,
869 const std::function<void( const git_diff_delta& )>& aCallback );
870
876APIEXPORT wxString ComposeCommitMessage( const wxString& aSummary, const wxString& aDescription,
877 const wxString& aSignOff );
878
880APIEXPORT void SplitCommitMessage( const wxString& aMessage, wxString& aSummary, wxString& aDescription );
881
884APIEXPORT wxString BranchNameError( const wxString& aName );
885
888APIEXPORT wxString DecodeRepoText( const char* aText );
889
892APIEXPORT wxString BusyMessage();
893
894} // namespace KIGIT
895
896
897#endif // _GIT_COMMON_H_
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
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()
wxString m_projectPath
wxString m_urlUsername
static const unsigned KIGIT_CREDENTIAL_SSH_AGENT
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
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
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_CONN_TYPE m_connType
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.
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
void SetRemote(const wxString &aRemote)
void SetRepo(git_repository *aRepo)
MergeCommitResult
Definition git_backend.h:83
#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)
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.
APIEXPORT void clone_progress_cb(const char *str, size_t len, size_t total, void *data)
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.
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.