summaryrefslogtreecommitdiff
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--shared.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/shared.c b/shared.c
index 3d4feea..d815cb1 100644
--- a/shared.c
+++ b/shared.c
@@ -291,6 +291,47 @@ char *trim_end(const char *str, char c)
return s;
}
+void cgit_add_ref(struct reflist *list, struct refinfo *ref)
+{
+ size_t size;
+
+ if (list->count >= list->alloc) {
+ list->alloc += (list->alloc ? list->alloc : 4);
+ size = list->alloc * sizeof(struct refinfo *);
+ list->refs = xrealloc(list->refs, size);
+ }
+ list->refs[list->count++] = ref;
+}
+
+struct refinfo *cgit_mk_refinfo(const char *refname, const unsigned char *sha1)
+{
+ struct refinfo *ref;
+
+ ref = xmalloc(sizeof (struct refinfo));
+ ref->refname = xstrdup(refname);
+ ref->object = parse_object(sha1);
+ switch (ref->object->type) {
+ case OBJ_TAG:
+ ref->tag = cgit_parse_tag((struct tag *)ref->object);
+ break;
+ case OBJ_COMMIT:
+ ref->commit = cgit_parse_commit((struct commit *)ref->object);
+ break;
+ }
+ return ref;
+}
+
+int cgit_refs_cb(const char *refname, const unsigned char *sha1, int flags,
+ void *cb_data)
+{
+ struct reflist *list = (struct reflist *)cb_data;
+ struct refinfo *info = cgit_mk_refinfo(refname, sha1);
+
+ if (info)
+ cgit_add_ref(list, info);
+ return 0;
+}
+
void cgit_diff_tree_cb(struct diff_queue_struct *q,
struct diff_options *options, void *data)
{
tions'>+1 2014-04-24Makefile: osx/bsd does not support -DJason A. Donenfeld2-25/+25 2014-04-24show: error out if password store is empty.Jason A. Donenfeld1-1/+4 2014-04-24find: proper segmenting of terms1.6Jason A. Donenfeld1-3/+3 2014-04-24dmenu: hide outputJason A. Donenfeld1-1/+1 2014-04-24tests: test for spacesJason A. Donenfeld3-8/+20 2014-04-24Move test instructions to INSTALL.Jason A. Donenfeld2-11/+18 2014-04-24tests: we don't use aggregate-resultsJason A. Donenfeld1-57/+0 2014-04-24Don't prompt for questions when stdin is not a tty.Jason A. Donenfeld3-7/+6 2014-04-24Allow overridable bash.Jason A. Donenfeld16-16/+16 2014-04-24dmenu: check for empty instead of ret codeJason A. Donenfeld1-1/+1 2014-04-24tests: sed doesn't like escaped chars on non-gnuJason A. Donenfeld1-1/+1 2014-04-24tests: run from anywhereJason A. Donenfeld13-4/+16 2014-04-24Turns out aliases were a bad idea.Jason A. Donenfeld14-95/+92 2014-04-24Make gpg_opts an array.Jason A. Donenfeld1-12/+12 2014-04-24Shellcheck errors.Jason A. Donenfeld1-6/+6 2014-04-24tests: todo updateJason A. Donenfeld1-25/+0