-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgitindex.m
60 lines (50 loc) · 1.36 KB
/
gitindex.m
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
Gitindex : module
{
PATH: con "/dis/git/gitindex.dis";
CACHESIGNATURE: con 16r44495243;
HEADERSZ: con 32;
#This is a entry size up to name field
ENTRYSZ: con 64;
#This constant is used for determining whether hash
#table needs resizing. If entriesnt * CLSBND >= hashcap,
#then hash table needs resizing
CLSBND: con 3;
Header: adt
{
signature: int;
version: int;
entriescnt: int;
sha1: array of byte;
pack: fn(buf: array of byte): ref Header;
unpack: fn(header: self ref Header): array of byte;
new: fn(): ref Header;
};
Entry: adt
{
qid: Sys->Qid;
dtype: int;
dev: int;
mtime: int;
mode: int;
length: big;
sha1: array of byte;
namelen: int;
name: string;
pack: fn(buf: array of byte): ref Entry;
unpack: fn(entry: self ref Entry): array of byte;
compare: fn(e1: self ref Entry, e2: ref Entry): int;
new: fn(): ref Entry;
};
Index: adt
{
header: ref Header;
entries: ref Strhash[ref Entry];
hashcap: int;
addfile: fn(index: self ref Index, path: string): int;
addentry: fn(index: self ref Index, entry: ref Entry);
rmfile: fn(index: self ref Index, path: string);
readindex: fn(index: self ref Index, path: string): int;
writeindex: fn(index: self ref Index, path: string): int;
new: fn(repopath: string): ref Index;
};
};