aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/cgit.c b/cgit.c
index 2ccf864..afafcce 100644
--- a/cgit.c
+++ b/cgit.c
@@ -18,7 +18,7 @@
18 18
19const char *cgit_version = CGIT_VERSION; 19const char *cgit_version = CGIT_VERSION;
20 20
21void add_mimetype(const char *name, const char *value) 21static void add_mimetype(const char *name, const char *value)
22{ 22{
23 struct string_list_item *item; 23 struct string_list_item *item;
24 24
@@ -26,7 +26,7 @@ void add_mimetype(const char *name, const char *value)
26 item->util = xstrdup(value); 26 item->util = xstrdup(value);
27} 27}
28 28
29struct cgit_filter *new_filter(const char *cmd, filter_type filtertype) 29static struct cgit_filter *new_filter(const char *cmd, filter_type filtertype)
30{ 30{
31 struct cgit_filter *f; 31 struct cgit_filter *f;
32 int args_size = 0; 32 int args_size = 0;
@@ -58,7 +58,7 @@ struct cgit_filter *new_filter(const char *cmd, filter_type filtertype)
58 58
59static void process_cached_repolist(const char *path); 59static void process_cached_repolist(const char *path);
60 60
61void repo_config(struct cgit_repo *repo, const char *name, const char *value) 61static void repo_config(struct cgit_repo *repo, const char *name, const char *value)
62{ 62{
63 struct string_list_item *item; 63 struct string_list_item *item;
64 64
@@ -114,7 +114,7 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
114 } 114 }
115} 115}
116 116
117void config_cb(const char *name, const char *value) 117static void config_cb(const char *name, const char *value)
118{ 118{
119 if (!strcmp(name, "section") || !strcmp(name, "repo.group")) 119 if (!strcmp(name, "section") || !strcmp(name, "repo.group"))
120 ctx.cfg.section = xstrdup(value); 120 ctx.cfg.section = xstrdup(value);
@@ -333,7 +333,7 @@ static void querystring_cb(const char *name, const char *value)
333 } 333 }
334} 334}
335 335
336char *xstrdupn(const char *str) 336static char *xstrdupn(const char *str)
337{ 337{
338 return (str ? xstrdup(str) : NULL); 338 return (str ? xstrdup(str) : NULL);
339} 339}
@@ -414,8 +414,8 @@ struct refmatch {
414 int match; 414 int match;
415}; 415};
416 416
417int find_current_ref(const char *refname, const unsigned char *sha1, 417static int find_current_ref(const char *refname, const unsigned char *sha1,
418 int flags, void *cb_data) 418 int flags, void *cb_data)
419{ 419{
420 struct refmatch *info; 420 struct refmatch *info;
421 421
@@ -427,7 +427,13 @@ int find_current_ref(const char *refname, const unsigned char *sha1,
427 return info->match; 427 return info->match;
428} 428}
429 429
430char *find_default_branch(struct cgit_repo *repo) 430static void free_refmatch_inner(struct refmatch *info)
431{
432 if (info->first_ref)
433 free(info->first_ref);
434}
435
436static char *find_default_branch(struct cgit_repo *repo)
431{ 437{
432 struct refmatch info; 438 struct refmatch info;
433 char *ref; 439 char *ref;
@@ -442,6 +448,8 @@ char *find_default_branch(struct cgit_repo *repo)
442 ref = info.first_ref; 448 ref = info.first_ref;
443 if (ref) 449 if (ref)
444 ref = xstrdup(ref); 450 ref = xstrdup(ref);
451 free_refmatch_inner(&info);
452
445 return ref; 453 return ref;
446} 454}
447 455
@@ -569,13 +577,13 @@ static void process_request(void *cbdata)
569 cgit_print_docend(); 577 cgit_print_docend();
570} 578}
571 579
572int cmp_repos(const void *a, const void *b) 580static int cmp_repos(const void *a, const void *b)
573{ 581{
574 const struct cgit_repo *ra = a, *rb = b; 582 const struct cgit_repo *ra = a, *rb = b;
575 return strcmp(ra->url, rb->url); 583 return strcmp(ra->url, rb->url);
576} 584}
577 585
578char *build_snapshot_setting(int bitmap) 586static char *build_snapshot_setting(int bitmap)
579{ 587{
580 const struct cgit_snapshot_format *f; 588 const struct cgit_snapshot_format *f;
581 char *result = xstrdup(""); 589 char *result = xstrdup("");
@@ -595,7 +603,7 @@ char *build_snapshot_setting(int bitmap)
595 return result; 603 return result;
596} 604}
597 605
598char *get_first_line(char *txt) 606static char *get_first_line(char *txt)
599{ 607{
600 char *t = xstrdup(txt); 608 char *t = xstrdup(txt);
601 char *p = strchr(t, '\n'); 609 char *p = strchr(t, '\n');
@@ -604,7 +612,7 @@ char *get_first_line(char *txt)
604 return t; 612 return t;
605} 613}
606 614
607void print_repo(FILE *f, struct cgit_repo *repo) 615static void print_repo(FILE *f, struct cgit_repo *repo)
608{ 616{
609 fprintf(f, "repo.url=%s\n", repo->url); 617 fprintf(f, "repo.url=%s\n", repo->url);
610 fprintf(f, "repo.name=%s\n", repo->name); 618 fprintf(f, "repo.name=%s\n", repo->name);
@@ -649,7 +657,7 @@ void print_repo(FILE *f, struct cgit_repo *repo)
649 fprintf(f, "\n"); 657 fprintf(f, "\n");
650} 658}
651 659
652void print_repolist(FILE *f, struct cgit_repolist *list, int start) 660static void print_repolist(FILE *f, struct cgit_repolist *list, int start)
653{ 661{
654 int i; 662 int i;
655 663