Skip to content

Commit 6eb8ae0

Browse files
iabervonLinus Torvalds
authored and
Linus Torvalds
committed
[PATCH] Header files for object parsing
This adds the structs and function declarations for parsing git objects. Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 6683463 commit 6eb8ae0

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

blob.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef BLOB_H
2+
#define BLOB_H
3+
4+
#include "object.h"
5+
6+
extern const char *blob_type;
7+
8+
struct blob {
9+
struct object object;
10+
};
11+
12+
struct blob *lookup_blob(unsigned char *sha1);
13+
14+
#endif /* BLOB_H */

commit.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef COMMIT_H
2+
#define COMMIT_H
3+
4+
#include "object.h"
5+
#include "tree.h"
6+
7+
struct commit_list {
8+
struct commit *item;
9+
struct commit_list *next;
10+
};
11+
12+
struct commit {
13+
struct object object;
14+
unsigned long date;
15+
struct commit_list *parents;
16+
struct tree *tree;
17+
};
18+
19+
extern const char *commit_type;
20+
21+
struct commit *lookup_commit(unsigned char *sha1);
22+
23+
int parse_commit(struct commit *item);
24+
25+
void free_commit_list(struct commit_list *list);
26+
27+
#endif /* COMMIT_H */

object.h

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef OBJECT_H
2+
#define OBJECT_H
3+
4+
struct object_list {
5+
struct object *item;
6+
struct object_list *next;
7+
};
8+
9+
struct object {
10+
unsigned parsed : 1;
11+
unsigned used : 1;
12+
unsigned int flags;
13+
unsigned char sha1[20];
14+
const char *type;
15+
struct object_list *refs;
16+
};
17+
18+
int nr_objs;
19+
struct object **objs;
20+
21+
struct object *lookup_object(unsigned char *sha1);
22+
23+
void created_object(unsigned char *sha1, struct object *obj);
24+
25+
void add_ref(struct object *refer, struct object *target);
26+
27+
void mark_reachable(struct object *obj, unsigned int mask);
28+
29+
#endif /* OBJECT_H */

tree.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef TREE_H
2+
#define TREE_H
3+
4+
#include "object.h"
5+
6+
extern const char *tree_type;
7+
8+
struct tree {
9+
struct object object;
10+
unsigned has_full_path : 1;
11+
};
12+
13+
struct tree *lookup_tree(unsigned char *sha1);
14+
15+
int parse_tree(struct tree *tree);
16+
17+
#endif /* TREE_H */

0 commit comments

Comments
 (0)