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
353
357 {
359 std::optional<wxString> username;
360 wxString password;
361 wxString sshKey;
362 };
363
365
372 bool ApplyPromptedCredentials( const CREDENTIAL_IDENTITY& aFor, const PROMPTED_CREDENTIALS& aEntered );
373
374 // Holds a temporary variable that can be used by the authentication callback
375 // to remember which types of authentication have been tested so that we
376 // don't loop forever.
377 std::atomic<unsigned>& TestedTypes() { return m_testedTypes; }
378
381 bool HasLocalCommits() const;
382
384 bool HasUpstreamCommits() const;
385
387 bool IsPullRebaseConfigured() const;
388
390 bool IsHeadDetached() const;
391
393 std::optional<size_t> GetUnmergedCommitCount( const wxString& aBranch ) const;
394
395 // True when tracked files hold uncommitted changes, staged or not. Untracked files do not
396 // count: a merge leaves them alone. aReadOk distinguishes a clean tree from a failed read.
397 bool HasUncommittedTrackedChanges( bool* aReadOk = nullptr ) const;
398
399 // The full messages of the newest commits from HEAD, newest first, with repeats dropped.
400 std::vector<wxString> GetRecentCommitMessages( size_t aMax ) const;
401
402 // The most recent commits aFilter selects, newest first, up to aMax of them.
403 std::vector<KIGIT_COMMIT_INFO> GetRecentCommits( size_t aMax = 50, const KIGIT_HISTORY_FILTER& aFilter = {} ) const;
404
405 // One commit in full, with the files it changed against its first parent. A root commit's
406 // files all count as added. Not found leaves the result's found flag clear.
407 KIGIT_COMMIT_DETAIL GetCommitDetail( const wxString& aHash ) const;
408
409 // The full message of the commit HEAD points at, body and trailers included. The amend
410 // prefill uses this, so accepting the suggestion does not truncate the message to its
411 // first line.
412 wxString GetLastCommitMessage() const;
413
414 // The stashes in the repository, in the order git reports them (newest first).
415 std::vector<KIGIT_STASH_INFO> GetStashes() const;
416
417 // One stash in full, by its commit id. Not found leaves the result's found flag clear.
418 KIGIT_STASH_DETAIL GetStashDetail( const wxString& aId ) const;
419
420 // The tags in the repository, each resolved to the commit it points at.
421 std::vector<KIGIT_TAG_INFO> GetTags() const;
422
423 // One tag in full. Not found leaves the result's found flag clear.
424 KIGIT_TAG_DETAIL GetTagDetail( const wxString& aName ) const;
425
427 bool IsHeadUnborn() const;
428
429 // The caller holds the action lock, as with the query methods above.
430 // Create aName at the tip of aFrom, a local or remote branch, or at HEAD when aFrom is empty.
431 bool CreateBranch( const wxString& aName, const wxString& aFrom = wxEmptyString );
432
439 bool StartUnbornBranch( const wxString& aName );
440 bool DeleteBranch( const wxString& aName );
441
443 bool StashSave( const wxString& aMessage );
444 bool StashApply( size_t aIndex );
445 bool StashPop( size_t aIndex );
446 bool StashDrop( size_t aIndex );
447
448 // Tag HEAD. With a message the tag is annotated and carries it, otherwise it is lightweight.
449 bool CreateTag( const wxString& aName, const wxString& aMessage = wxEmptyString );
450 bool DeleteTag( const wxString& aName );
451 bool CheckoutTag( const wxString& aName );
452
453 bool AddRemote( const wxString& aName, const wxString& aUrl );
454 bool SetRemoteUrl( const wxString& aName, const wxString& aUrl );
455 bool RemoveRemote( const wxString& aName );
456
457 bool SetUserConfig( const wxString& aName, const wxString& aEmail );
458
463 bool GetMergeConflicts( const wxString& aStageDir, wxString& aHeadOid, wxString& aTheirsOid,
464 std::vector<KIGIT_CONFLICT_SIDES>& aConflicts, wxString& aError );
465
471 RestoreResult RestoreVersion( const wxString& aCommitHash, KIGIT_ERROR_MESSAGE& aError );
472
477 bool DiscardChanges( const std::vector<wxString>& aPaths, wxString& aError );
478
480 bool IsPathInHead( const wxString& aPath );
481
483 bool IsPathConflicted( const wxString& aPath ) const;
484
486 bool IsOperationInProgress() const;
487
489 GitOperation OperationInProgress() const;
490
492 bool AbandonOperation( wxString& aError );
493
502 MergeCommitResult CreateMergedCommit( const wxString& aExpectedHeadOid, const wxString& aTheirsOid,
503 const std::vector<std::pair<wxString, wxString>>& aResolvedFiles,
504 KIGIT_ERROR_MESSAGE& aError );
505
506 // Returns true if the repository has a remote that can be pushed to pulled from
507 bool HasPushAndPullRemote() const;
508
509 // Updates the password and remote information for the repository given the current branch
510 void UpdateCurrentBranchInfo();
511
517 void SyncRemoteUrl( const wxString& aRawUrl );
518
523 void FollowRewrittenUrl( const wxString& aRawUrl );
524
525 wxString GetGitRootDirectory() const;
526
527 wxString GetRemotename() const;
528
530 std::vector<std::pair<wxString, wxString>> GetRemotes() const;
531
532 // When the repository last fetched, from any remote. Invalid when it never has.
533 wxDateTime GetLastFetchTime() const;
534
535 // Lines added and removed in the working tree against HEAD, new files included. Only for
536 // aPaths, relative to the repository root, so the count matches the list beside it.
537 std::pair<int, int> GetWorkingTreeLineStats( const std::set<wxString>& aPaths ) const;
538
541 wxString GetRemoteNameOrDefault() const;
542
546 void SetProjectDir( const wxString& aProjectDir ) { m_projectDir = aProjectDir; }
547
551 wxString GetProjectDir() const;
552
555 std::optional<wxString> GetProjectPrefix() const;
556
558 void SetAttachError( const wxString& aError, const wxString& aTrustCommand = wxEmptyString )
559 {
560 m_attachError = aError;
561 m_attachTrustCommand = aTrustCommand;
562 }
563
564 const wxString& GetAttachError() const { return m_attachError; }
565
567 const wxString& GetAttachTrustCommand() const { return m_attachTrustCommand; }
568
570 {
571 std::lock_guard<std::mutex> lock( m_credentialsMutex );
572 m_nextPublicKey = 0;
573 }
574
576 wxString GetNextPublicKey();
577
578 void SetRemote( const wxString& aRemote )
579 {
580 {
581 std::lock_guard<std::mutex> lock( m_credentialsMutex );
582 m_remote = aRemote;
583 m_password.clear();
584 m_secretFetched = false;
586 }
587
588 // Gathers the keys now, or the first transfer's sync would drop a key chosen after this
589 SyncRemoteUrl( aRemote );
590 }
591
592 wxString GetRemote() const
593 {
594 std::lock_guard<std::mutex> lock( m_credentialsMutex );
595 return m_remote;
596 }
597
599 int HandleSSHKeyAuthentication( git_cred** aOut, const wxString& aUsername, KIGIT_AUTH_ATTEMPT& aAttempt );
600
601 int HandlePlaintextAuthentication( git_cred** aOut, const wxString& aUsername );
602
603 int HandleSSHAgentAuthentication( git_cred** aOut, const wxString& aUsername );
604
606 static wxString GetLastGitError();
607
610 static KIGIT_ERROR_INFO GetLastGitErrorInfo( int aCode );
611
614 using CANCEL_TOKEN = std::shared_ptr<std::atomic<bool>>;
615
616 static CANCEL_TOKEN NewCancelToken() { return std::make_shared<std::atomic<bool>>( false ); }
617
621 {
622 public:
623 OPERATION_GUARD( KIGIT_COMMON* aCommon, const CANCEL_TOKEN& aToken ) :
624 m_common( aCommon ),
625 m_token( aToken )
626 {
627 std::lock_guard<std::mutex> lock( m_common->m_operationMutex );
628 m_common->m_activeCancel = m_token;
629
630 // A shutdown asked for before this operation reached the lock still applies to it.
631 if( m_token && m_common->m_shutdown )
632 m_token->store( true );
633 }
634
638 {
639 std::lock_guard<std::mutex> lock( m_common->m_operationMutex );
640
641 if( m_common->m_activeCancel == m_token )
642 m_common->m_activeCancel.reset();
643 }
644
647
648 private:
651 };
652
654 bool IsShuttingDown() const
655 {
656 std::lock_guard<std::mutex> lock( m_operationMutex );
657 return m_shutdown;
658 }
659
661 void SetShuttingDown( bool aCancel )
662 {
663 std::lock_guard<std::mutex> lock( m_operationMutex );
664 m_shutdown = aCancel;
665
666 if( aCancel && m_activeCancel )
667 m_activeCancel->store( true );
668 }
669
672 int SSHPortFor( const wxString& aHost ) const;
673
674 std::unique_lock<std::mutex> TryLockAction()
675 {
676 return std::unique_lock<std::mutex>( m_gitActionMutex, std::try_to_lock );
677 }
678
680 static constexpr std::chrono::milliseconds ACTION_LOCK_WAIT{ 2000 };
681
684 std::unique_lock<std::mutex> TryLockActionFor( std::chrono::milliseconds aWait );
685
686 std::unique_lock<std::mutex> LockAction() { return std::unique_lock<std::mutex>( m_gitActionMutex ); }
687
688 // Views showing working-tree state register here, so a commit, push or pull in one of them
689 // refreshes the others. UI thread only, so the list needs no lock.
690 void AddRefreshListener( void* aOwner, std::function<void()> aCallback );
691 void RemoveRefreshListener( void* aOwner );
692 void NotifyRefreshListeners();
693
694protected:
696
697 wxString m_projectDir; // Repository working directory preserving symlinks
698 wxString m_projectPath; // Project directory captured when the session was created
701
703 wxString m_remote; // This is the full connection string
704 wxString m_urlUsername; // The username m_remote was parsed with, which HTTPS strips from it
705 wxString m_hostname; // This is just the hostname without the protocol, username, or password
706 int m_port = 0; // The port m_remote names, 0 when it names none and -1 when it is not valid
707 wxString m_username;
708 wxString m_password;
709
710 std::atomic<unsigned> m_testedTypes;
711
713
717 mutable std::mutex m_credentialsMutex;
718
719 std::vector<std::pair<void*, std::function<void()>>> m_refreshListeners;
720
721 // Make git handlers friends so they can access the mutex
722 friend class GIT_PUSH_HANDLER;
723 friend class GIT_PULL_HANDLER;
724 friend class GIT_CLONE_HANDLER;
725 friend class LIBGIT_BACKEND;
726
727private:
729 std::optional<KIGIT_AHEAD_BEHIND> compareRefs( const git_reference* aBranch, const git_reference* aBase ) const;
730
732 {
733 std::lock_guard<std::mutex> lock( m_operationMutex );
734 return m_activeCancel;
735 }
736
738 wxString remoteNameWithoutUpstream() const;
739
740 void updatePublicKeys();
741
744 void rebuildPublicKeysUnlocked();
745 void updateConnectionType();
746
748 void updateConnectionTypeUnlocked();
749
750 std::vector<wxString> m_discoveredKeys; // Gathered for m_publicKeysHost, without the project key
751 std::vector<wxString> m_publicKeys;
752 wxString m_publicKeysHost; // The host m_publicKeys was gathered for
753 wxString m_projectSSHKey; // Kept when its file is missing, so the setting is not lost
756
759 mutable std::mutex m_operationMutex;
761 bool m_shutdown = false;
762
763 // Create a dummy flag to tell if we have tested ssh agent credentials separately
764 // from the ssh key credentials. Our own bit, so it must clear every git_credential_t
765 // value. The highest is GIT_CREDENTIAL_SSH_MEMORY at 1 << 6.
766 static const unsigned KIGIT_CREDENTIAL_SSH_AGENT = 1u << ( sizeof( unsigned ) * 8 - 1 );
767};
768
769extern "C" APIEXPORT int progress_cb( const char* str, int len, void* data );
770extern "C" APIEXPORT void clone_progress_cb( const char* str, size_t len, size_t total, void* data );
771extern "C" APIEXPORT int transfer_progress_cb( const git_transfer_progress* aStats, void* aPayload );
772extern "C" APIEXPORT int update_cb( const char* aRefname, const git_oid* aFirst, const git_oid* aSecond,
773 void* aPayload );
774extern "C" APIEXPORT int push_transfer_progress_cb( unsigned int aCurrent, unsigned int aTotal,
775 size_t aBytes, void* aPayload );
776extern "C" APIEXPORT int push_update_reference_cb( const char* aRefname, const char* aStatus,
777 void* aPayload );
778
779extern "C" APIEXPORT int fetchhead_foreach_cb( const char*, const char*,
780 const git_oid* aOID, unsigned int aIsMerge, void* aPayload );
781extern "C" APIEXPORT int credentials_cb( git_cred** aOut, const char* aUrl, const char* aUsername,
782 unsigned int aAllowedTypes, void* aPayload );
783
791extern "C" APIEXPORT int certificate_check_cb( git_cert* aCert, int aValid, const char* aHost, void* aPayload );
792
793
794class wxWindow;
795
796
797namespace KIGIT
798{
799
806APIEXPORT bool IsPrivateKeyEncrypted( const wxString& aKeyText );
807
808
816
817
830APIEXPORT git_tree* ResolveRefToTree( git_repository* aRepo, const wxString& aRef );
831
832
840APIEXPORT std::vector<wxString> CompareBranchRefs( git_repository* aRepo );
841
842
853APIEXPORT void CollectDiffDeltas( git_diff* aDiff,
854 const std::function<void( const git_diff_delta& )>& aCallback );
855
861APIEXPORT wxString ComposeCommitMessage( const wxString& aSummary, const wxString& aDescription,
862 const wxString& aSignOff );
863
865APIEXPORT void SplitCommitMessage( const wxString& aMessage, wxString& aSummary, wxString& aDescription );
866
869APIEXPORT wxString BranchNameError( const wxString& aName );
870
873APIEXPORT wxString DecodeRepoText( const char* aText );
874
877APIEXPORT wxString BusyMessage();
878
879} // namespace KIGIT
880
881
882#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
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:67
#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 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 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.