List for cgit developers and users
 help / color / mirror / Atom feed
From: tobiasdreher at outlook.com (Tobias Dreher)
Subject: [PATCH 1/1] Display repository urls even if repository is empty
Date: Sat, 19 Apr 2014 09:05:48 -0700	[thread overview]
Message-ID: <BLU0-SMTP148BACFFC703AE1CE9E16B4D25C0@phx.gbl> (raw)

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("<table summary='repository info' class='list nowrap'>");
+	cgit_print_repository_urls();
+	html("</table>");
+}
+
  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("</table>");
  }

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);


             reply	other threads:[~2014-04-19 16:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-19 16:05 tobiasdreher [this message]
2014-05-04 19:29 ` tobiasdreher
2014-12-26 22:38 ` Jason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BLU0-SMTP148BACFFC703AE1CE9E16B4D25C0@phx.gbl \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).