]> gitweb.ps.run Git - ps-cgit/blobdiff - git.h
Add support for snapshots
[ps-cgit] / git.h
diff --git a/git.h b/git.h
index 922a16754a7e70ff5e07a76bfdaca0335a18010f..a1d1c4bea4a5d7f27cc33eca026729e6bdedb9e6 100644 (file)
--- a/git.h
+++ b/git.h
@@ -31,7 +31,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <time.h>
-
+#include <regex.h>
 
 /* On most systems <limits.h> would have given us this, but
  * not on some systems (e.g. GNU/Hurd).
@@ -124,6 +124,19 @@ static inline ssize_t xwrite(int fd, const void *buf, size_t len)
  */
 
 
+enum object_type {
+       OBJ_NONE = 0,
+       OBJ_COMMIT = 1,
+       OBJ_TREE = 2,
+       OBJ_BLOB = 3,
+       OBJ_TAG = 4,
+       /* 5 for future expansion */
+       OBJ_OFS_DELTA = 6,
+       OBJ_REF_DELTA = 7,
+       OBJ_BAD,
+};
+
+
 /* Convert to/from hex/sha1 representation */
 #define MINIMUM_ABBREV 4
 #define DEFAULT_ABBREV 7
@@ -156,12 +169,80 @@ static inline void hashclr(unsigned char *hash)
 }
 
 
+/*
+ * from git:grep.h
+ */
+
+enum grep_pat_token {
+        GREP_PATTERN,
+        GREP_PATTERN_HEAD,
+        GREP_PATTERN_BODY,
+        GREP_AND,
+        GREP_OPEN_PAREN,
+        GREP_CLOSE_PAREN,
+        GREP_NOT,
+        GREP_OR,
+};
+
+enum grep_context {
+        GREP_CONTEXT_HEAD,
+        GREP_CONTEXT_BODY,
+};
+
+struct grep_pat {
+        struct grep_pat *next;
+        const char *origin;
+        int no;
+        enum grep_pat_token token;
+        const char *pattern;
+        regex_t regexp;
+};
+
+enum grep_expr_node {
+        GREP_NODE_ATOM,
+        GREP_NODE_NOT,
+        GREP_NODE_AND,
+        GREP_NODE_OR,
+};
+
+struct grep_opt {
+        struct grep_pat *pattern_list;
+        struct grep_pat **pattern_tail;
+        struct grep_expr *pattern_expression;
+        int prefix_length;
+        regex_t regexp;
+        unsigned linenum:1;
+        unsigned invert:1;
+        unsigned status_only:1;
+        unsigned name_only:1;
+        unsigned unmatch_name_only:1;
+        unsigned count:1;
+        unsigned word_regexp:1;
+        unsigned fixed:1;
+        unsigned all_match:1;
+#define GREP_BINARY_DEFAULT     0
+#define GREP_BINARY_NOMATCH     1
+#define GREP_BINARY_TEXT        2
+        unsigned binary:2;
+        unsigned extended:1;
+        unsigned relative:1;
+        unsigned pathname:1;
+        int regflags;
+        unsigned pre_context;
+        unsigned post_context;
+};
+
+
+extern void compile_grep_patterns(struct grep_opt *opt);
+extern void free_grep_patterns(struct grep_opt *opt);
 
 
 /*
  * from git:object.h 
  */
 
+extern const char *type_names[9];
+
 struct object_list {
        struct object *item;
        struct object_list *next;
@@ -197,6 +278,10 @@ struct object {
 };
 
 
+/** Returns the object, having parsed it to find out what it is. **/
+struct object *parse_object(const unsigned char *sha1);
+
+
 /*
  * from git:tree.h
  */
@@ -277,6 +362,25 @@ typedef void* (*topo_sort_get_fn_t)(struct commit*);
 
 
 
+/*
+ * from git:tag.h
+ */
+
+extern const char *tag_type;
+
+struct tag {
+       struct object object;
+       struct object *tagged;
+       char *tag;
+       char *signature; /* not actually implemented */
+};
+
+extern struct tag *lookup_tag(const unsigned char *sha1);
+extern int parse_tag_buffer(struct tag *item, void *data, unsigned long size);
+extern int parse_tag(struct tag *item);
+extern struct object *deref_tag(struct object *, const char *, int);
+
+
 /*
  * from git:diffcore.h
  */
@@ -565,4 +669,31 @@ int log_tree_commit(struct rev_info *, struct commit *);
 
 
 
+/* from git:archive.h */
+
+struct archiver_args {
+       const char *base;
+       struct tree *tree;
+       const unsigned char *commit_sha1;
+       time_t time;
+       const char **pathspec;
+       unsigned int verbose : 1;
+       void *extra;
+};
+
+typedef int (*write_archive_fn_t)(struct archiver_args *);
+
+typedef void *(*parse_extra_args_fn_t)(int argc, const char **argv);
+
+struct archiver {
+       const char *name;
+       struct archiver_args args;
+       write_archive_fn_t write_archive;
+       parse_extra_args_fn_t parse_extra;
+};
+
+extern int write_tar_archive(struct archiver_args *);
+extern int write_zip_archive(struct archiver_args *);
+extern void *parse_extra_zip_args(int argc, const char **argv);
+
 #endif /* GIT_H */