-
Notifications
You must be signed in to change notification settings - Fork 1
/
git.h
65 lines (52 loc) · 1.37 KB
/
git.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2024 by Christopher Antos
// License: http://opensource.org/licenses/MIT
// vim: set et ts=4 sw=4 cino={0s:
#pragma once
#include <windows.h>
#include "str.h"
#include <map>
#include <memory>
enum class GitFileState : BYTE
{
NONE,
NEW,
MODIFIED,
DELETED,
RENAMED,
TYPECHANGE,
IGNORED,
UNMERGED, // Conflicted.
COUNT
};
struct FileStatus
{
GitFileState staged;
GitFileState working;
};
struct RepoStatus
{
~RepoStatus();
bool repo = false;
bool main = true; // Branch is main or master.
bool clean = true;
StrW branch;
StrW root;
std::map<const WCHAR*, FileStatus, SortCase> status;
};
struct GitStatusSymbol
{
WCHAR symbol;
WCHAR color_key[3];
};
bool IsUnderRepo(const WCHAR* dir);
std::shared_ptr<RepoStatus> GitStatus(const WCHAR* dir, bool need_ignored, bool walk_up=false);
const GitStatusSymbol& GitSymbol(GitFileState state);
class RepoMap
{
public:
void Add(std::shared_ptr<const RepoStatus> repo);
void Remove(const WCHAR* dir);
std::shared_ptr<const RepoStatus> Find(const WCHAR* dir) const;
private:
std::map<const WCHAR*, std::shared_ptr<const RepoStatus>, SortCaseless> m_map;
};