-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
131 lines (125 loc) · 2.47 KB
/
Copy pathmain.cpp
File metadata and controls
131 lines (125 loc) · 2.47 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include <iostream>
using namespace std;
#include "core/Repository.h"
int main(int argc,char* argv[])
{
Repository repo;
if(argc<2)
{
cout<<"Usage: gitlite <command>\n";
return 0;
}
string cmd=argv[1];
if(cmd=="init")
{
repo.init();
}
else if(cmd=="add")
{
if(argc<3)
{
cout<<"Usage: gitlite add <file>\n";
return 0;
}
repo.add(argv[2]);
}
else if(cmd=="status")
{
repo.status();
}
else if(cmd=="commit")
{
if(argc<3)
{
cout<<"Usage: gitlite commit \"message\"\n";
return 0;
}
repo.commit(argv[2]);
}
else if(cmd=="log")
{
repo.log();
}
else if(cmd=="diff")
{
if(argc<4)
{
cout<<"Usage: gitlite diff <file1> <file2>\n";
return 0;
}
repo.diff(argv[2], argv[3]);
}
else if(cmd=="branch")
{
string bname = argv[2];
string cid = (argc > 3) ? argv[3] : "";
repo.branch(bname, cid);
}
else if(cmd=="checkout")
{
if(argc<3)
{
cout<<"Usage: gitlite checkout <branch>\n";
return 0;
}
repo.checkout(argv[2]);
}
else if(cmd=="search")
{
if(argc<3)
{
cout<<"Usage: gitlite search <keyword>\n";
return 0;
}
repo.search(argv[2]);
}
else if(cmd=="stats")
{
if(argc<4)
{
cout<<"Usage: gitlite stats <file1> <file2>\n";
return 0;
}
repo.stats(argv[2],argv[3]);
}
else if(cmd=="gc")
{
repo.gc();
}
else if(cmd=="graph")
{
repo.graph();
}
else if(cmd=="restore")
{
if(argc<4)
{
cout<<"Usage: gitlite restore <commitID> <filename>\n";
return 0;
}
repo.restoreFile(argv[2], argv[3]);
}
else if(cmd=="diff-commit")
{
if(argc<4)
{
cout<<"Usage: gitlite diff-commit <commitID> <filename>\n";
return 0;
}
repo.diffWithCommit(argv[2], argv[3]);
}
else if(cmd=="cat-file")
{
if(argc<4)
{
cout<<"Usage: gitlite cat-file <commitID> <filename>\n";
return 0;
}
repo.catFile(argv[2], argv[3]);
}
else
{
cout<<"Unknown command\n";
}
return 0;
}