From mboxrd@z Thu Jan 1 00:00:00 1970 From: tobiasdreher at outlook.com (Tobias Dreher) Date: Sat, 19 Apr 2014 09:05:48 -0700 Subject: [PATCH 1/1] Display repository urls even if repository is empty Message-ID: Hello everyone, Currently cgit only outputs the line "Repository seems to be empty" if a repository is empty. However, this is often the case when you just created a bare new repository, and want to make your first commit, and for that you want to know the URL of your repository! This patch adds that output. cgit.c | 5 +++-- ui-summary.c | 20 ++++++++++++++++---- ui-summary.h | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cgit.c b/cgit.c index f488ebf..93a77a1 100644 --- a/cgit.c +++ b/cgit.c @@ -574,12 +574,15 @@ static int prepare_repo_cmd(void) ctx.qry.nohead = 1; ctx.qry.head = find_default_branch(ctx.repo); } + sort_string_list(&ctx.repo->submodules); + cgit_prepare_repo_env(ctx.repo); if (!ctx.qry.head) { cgit_print_http_headers(); cgit_print_docstart(); cgit_print_pageheader(); cgit_print_error("Repository seems to be empty"); + cgit_print_repository_urls_as_table(); cgit_print_docend(); return 1; } @@ -597,8 +600,6 @@ static int prepare_repo_cmd(void) free(tmp); return 1; } - sort_string_list(&ctx.repo->submodules); - cgit_prepare_repo_env(ctx.repo); choose_readme(ctx.repo); return 0; } diff --git a/ui-summary.c b/ui-summary.c index df99ce1..c55ad62 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -70,6 +70,21 @@ static void print_urls(char *txt, char *suffix) } } +void cgit_print_repository_urls() +{ + if (ctx.repo->clone_url) + print_urls(expand_macros(ctx.repo->clone_url), NULL); + else if (ctx.cfg.clone_prefix) + print_urls(ctx.cfg.clone_prefix, ctx.repo->url); +} + +void cgit_print_repository_urls_as_table() +{ + html(""); + cgit_print_repository_urls(); + html("
"); +} + void cgit_print_summary() { int columns = 3; @@ -88,10 +103,7 @@ void cgit_print_summary() cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, NULL, NULL, 0, 0, 0); } - if (ctx.repo->clone_url) - print_urls(expand_macros(ctx.repo->clone_url), NULL); - else if (ctx.cfg.clone_prefix) - print_urls(ctx.cfg.clone_prefix, ctx.repo->url); + cgit_print_repository_urls(); html(""); } diff --git a/ui-summary.h b/ui-summary.h index c01f560..1dd7e9e 100644 --- a/ui-summary.h +++ b/ui-summary.h @@ -1,6 +1,7 @@ #ifndef UI_SUMMARY_H #define UI_SUMMARY_H +extern void cgit_print_repository_urls_as_table(); extern void cgit_print_summary(); extern void cgit_print_repo_readme(char *path);