[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgit
Subject:    Re: [PATCH 1/1] Display repository urls even if repository is empty
From:       "Jason A. Donenfeld" <Jason () zx2c4 ! com>
Date:       2014-12-26 22:38:16
Message-ID: CAHmME9pGQqg7DUGem_BZkfO_PAcnK5gDKFrqp=FwmiVky2O+9w () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hey Tobias,

Sorry for the delay on this. Would you mind rebasing it on master, and
resubmitting? I'll merge it ASAP.

Thanks,
Jason

On Sat, Apr 19, 2014 at 6:05 PM, Tobias Dreher <tobiasdreher@outlook.com>
wrote:

> 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);
> _______________________________________________
> CGit mailing list
> CGit@lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/cgit
>

[Attachment #5 (text/html)]

<div dir="ltr">Hey Tobias,<div><br></div><div>Sorry for the delay on this. Would you \
mind rebasing it on master, and resubmitting? I&#39;ll merge it \
ASAP.</div><div><br></div><div>Thanks,</div><div>Jason<br><div \
class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 19, 2014 at 6:05 PM, \
Tobias Dreher <span dir="ltr">&lt;<a href="mailto:tobiasdreher@outlook.com" \
target="_blank">tobiasdreher@outlook.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hello everyone,<br> <br>
Currently cgit only outputs the line &quot;Repository seems to be empty&quot; 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.<br> <br>
<br>
<br>
  cgit.c           |   5 +++--<br>
  ui-summary.c | 20 ++++++++++++++++----<br>
  ui-summary.h |   1 +<br>
  3 files changed, 20 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/cgit.c b/cgit.c<br>
index f488ebf..93a77a1 100644<br>
--- a/cgit.c<br>
+++ b/cgit.c<br>
@@ -574,12 +574,15 @@ static int prepare_repo_cmd(void)<br>
                        ctx.qry.nohead = 1;<br>
                        ctx.qry.head = find_default_branch(ctx.repo);<br>
            }<br>
+           sort_string_list(&amp;ctx.repo-&gt;<u></u>submodules);<br>
+           cgit_prepare_repo_env(ctx.<u></u>repo);<br>
<br>
            if (!ctx.qry.head) {<br>
                        cgit_print_http_headers();<br>
                        cgit_print_docstart();<br>
                        cgit_print_pageheader();<br>
                        cgit_print_error(&quot;Repository seems to be \
empty&quot;);<br> +                       \
cgit_print_repository_urls_as_<u></u>table();<br>  cgit_print_docend();<br>
                        return 1;<br>
            }<br>
@@ -597,8 +600,6 @@ static int prepare_repo_cmd(void)<br>
                        free(tmp);<br>
                        return 1;<br>
            }<br>
-           sort_string_list(&amp;ctx.repo-&gt;<u></u>submodules);<br>
-           cgit_prepare_repo_env(ctx.<u></u>repo);<br>
            choose_readme(ctx.repo);<br>
            return 0;<br>
  }<br>
diff --git a/ui-summary.c b/ui-summary.c<br>
index df99ce1..c55ad62 100644<br>
--- a/ui-summary.c<br>
+++ b/ui-summary.c<br>
@@ -70,6 +70,21 @@ static void print_urls(char *txt, char *suffix)<br>
            }<br>
  }<br>
<br>
+void cgit_print_repository_urls()<br>
+{<br>
+           if (ctx.repo-&gt;clone_url)<br>
+                       print_urls(expand_macros(ctx.<u></u>repo-&gt;clone_url), \
NULL);<br> +           else if (ctx.cfg.clone_prefix)<br>
+                       print_urls(ctx.cfg.clone_<u></u>prefix, \
ctx.repo-&gt;url);<br> +}<br>
+<br>
+void cgit_print_repository_urls_as_<u></u>table()<br>
+{<br>
+           html(&quot;&lt;table summary=&#39;repository info&#39; class=&#39;list \
nowrap&#39;&gt;&quot;);<br> +           cgit_print_repository_urls();<br>
+           html(&quot;&lt;/table&gt;&quot;);<br>
+}<br>
+<br>
  void cgit_print_summary()<br>
  {<br>
            int columns = 3;<br>
@@ -88,10 +103,7 @@ void cgit_print_summary()<br>
                        cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, \
NULL,<br>  NULL, NULL, 0, 0, 0);<br>
            }<br>
-           if (ctx.repo-&gt;clone_url)<br>
-                       print_urls(expand_macros(ctx.<u></u>repo-&gt;clone_url), \
                NULL);<br>
-           else if (ctx.cfg.clone_prefix)<br>
-                       print_urls(ctx.cfg.clone_<u></u>prefix, \
ctx.repo-&gt;url);<br> +           cgit_print_repository_urls();<br>
            html(&quot;&lt;/table&gt;&quot;);<br>
  }<br>
<br>
diff --git a/ui-summary.h b/ui-summary.h<br>
index c01f560..1dd7e9e 100644<br>
--- a/ui-summary.h<br>
+++ b/ui-summary.h<br>
@@ -1,6 +1,7 @@<br>
  #ifndef UI_SUMMARY_H<br>
  #define UI_SUMMARY_H<br>
<br>
+extern void cgit_print_repository_urls_as_<u></u>table();<br>
  extern void cgit_print_summary();<br>
  extern void cgit_print_repo_readme(char *path);<br>
______________________________<u></u>_________________<br>
CGit mailing list<br>
<a href="mailto:CGit@lists.zx2c4.com" target="_blank">CGit@lists.zx2c4.com</a><br>
<a href="http://lists.zx2c4.com/mailman/listinfo/cgit" \
target="_blank">http://lists.zx2c4.com/<u></u>mailman/listinfo/cgit</a><br> \
</blockquote></div><br><br clear="all"><div><br></div><br> </div></div></div>



_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
http://lists.zx2c4.com/mailman/listinfo/cgit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic