KiCad PCB EDA Suite
Loading...
Searching...
No Matches
kigit_lock_retry.cpp File Reference
#include "kigit_lock_retry.h"
#include <git/kicad_git_compat.h>
#include <algorithm>
#include <cerrno>
#include <cstdint>
#include <optional>
#include <system_error>
#include <random>
#include <string>
#include <thread>
#include <utility>
#include <vector>
#include <sys/file.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

Go to the source code of this file.

Namespaces

namespace  KIGIT
 

Functions

int KIGIT::EditIndexLocked (git_repository *aRepo, const std::function< int(git_index *aIndex)> &aEdit)
 Rewrite aRepo's index the way git does, holding index.lock from a fresh read of the file to the rename that publishes it, so staging by another writer is never overwritten.
 
bool KIGIT::IsLockContention (int aGitError)
 True when aGitError says another writer held a lock or moved a ref first.
 
int KIGIT::WithLockRetry (std::chrono::milliseconds aBudget, const std::function< int()> &aOp)
 Run aOp, which returns 0 or a libgit2 error code, again after each lock contention until it succeeds, fails otherwise, or aBudget is spent.
 
std::unique_ptr< REPO_ACTION_LOCK > KIGIT::RepoActionLock (git_repository *aRepo, const char *aName="kicad-action")
 The lock aName in aRepo's common git directory, which every worktree of the repository shares.