| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <memory> |
| 4 |
#include <string> |
| 5 |
#include <git2.h> |
| 6 |
|
| 7 |
namespace vcs |
| 8 |
{ |
| 9 |
|
| 10 |
namespace git |
| 11 |
{ |
| 12 |
|
| 13 |
class Tree; |
| 14 |
class Repository; |
| 15 |
|
| 16 |
class Index final |
| 17 |
{ |
| 18 |
private: |
| 19 |
git_index* _index; |
| 20 |
|
| 21 |
public: |
| 22 |
using Ptr = std::shared_ptr<Index>; |
| 23 |
|
| 24 |
Index(git_index* index); |
| 25 |
|
| 26 |
~Index(); |
| 27 |
|
| 28 |
// Corresponds to the operation done by "git add -A" |
| 29 |
void addAll(); |
| 30 |
|
| 31 |
// Update all index entries to match the working directory |
| 32 |
void updateAll(); |
| 33 |
|
| 34 |
// libgit2: Write an existing index object from memory back to disk using an atomic file lock. |
| 35 |
void write(); |
| 36 |
|
| 37 |
// Collects this index and writes this to a tree, such that it can be used for a commit |
| 38 |
std::shared_ptr<Tree> writeTree(Repository& repository); |
| 39 |
|
| 40 |
bool hasConflicts(); |
| 41 |
|
| 42 |
bool fileIsConflicted(const std::string& relativePath); |
| 43 |
|
| 44 |
void resolveByUsingOurs(const std::string& relativePath); |
| 45 |
}; |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
} |