]> gitweb.ps.run Git - ps-cgit/commitdiff
Merge branch 'snapshot-fixes'
authorLars Hjemli <hjemli@gmail.com>
Sun, 11 Jan 2009 11:22:46 +0000 (12:22 +0100)
committerLars Hjemli <hjemli@gmail.com>
Sun, 11 Jan 2009 11:22:46 +0000 (12:22 +0100)
Makefile
cgit.c
cgit.css
tests/t0104-tree.sh
tests/t0107-snapshot.sh
ui-log.c
ui-patch.c
ui-refs.c
ui-snapshot.c
ui-tree.c

index 3c7ec07ca3a38f836367d344ea4870010e854958..036fcd7d503fc2c04dd958eac9c5c98921864fbe 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -128,8 +128,8 @@ cgit.o: VERSION
 -include $(OBJECTS:.o=.d)
 
 libgit:
-       $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) libgit.a
-       $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) xdiff/lib.a
+       $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 libgit.a
+       $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 xdiff/lib.a
 
 test: all
        $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all
diff --git a/cgit.c b/cgit.c
index 166fbc649607fcc1872eb61c6c0cd2b7e7c6de31..d1cee580cd6fe064993da8bd04acdf9f3325042b 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -439,28 +439,29 @@ int main(int argc, const char **argv)
        ctx.repo = NULL;
        http_parse_querystring(ctx.qry.raw, querystring_cb);
 
-       /* If virtual-root isn't specified in cgitrc and no url
-        * parameter is specified on the querystring, lets pretend
-        * that virtualroot equals SCRIPT_NAME and use PATH_INFO as
-        * url. This allows cgit to work with virtual urls without
-        * the need for rewriterules in the webserver (as long as
-        * PATH_INFO is included in the cache lookup key).
+       /* If virtual-root isn't specified in cgitrc, lets pretend
+        * that virtual-root equals SCRIPT_NAME.
         */
-       if (!ctx.cfg.virtual_root && !ctx.qry.url) {
+       if (!ctx.cfg.virtual_root)
                ctx.cfg.virtual_root = ctx.cfg.script_name;
-               path = getenv("PATH_INFO");
-               if (path) {
-                       if (path[0] == '/')
-                               path++;
-                       ctx.qry.url = xstrdup(path);
-                       if (ctx.qry.raw) {
-                               qry = ctx.qry.raw;
-                               ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry));
-                               free(qry);
-                       } else
-                               ctx.qry.raw = ctx.qry.url;
-                       cgit_parse_url(ctx.qry.url);
-               }
+
+       /* If no url parameter is specified on the querystring, lets
+        * use PATH_INFO as url. This allows cgit to work with virtual
+        * urls without the need for rewriterules in the webserver (as
+        * long as PATH_INFO is included in the cache lookup key).
+        */
+       path = getenv("PATH_INFO");
+       if (!ctx.qry.url && path) {
+               if (path[0] == '/')
+                       path++;
+               ctx.qry.url = xstrdup(path);
+               if (ctx.qry.raw) {
+                       qry = ctx.qry.raw;
+                       ctx.qry.raw = xstrdup(fmt("%s?%s", path, qry));
+                       free(qry);
+               } else
+                       ctx.qry.raw = ctx.qry.url;
+               cgit_parse_url(ctx.qry.url);
        }
 
        ttl = calc_ttl();
index 7928c2f4f86f0b597a3b992ff7815adca1d4bef0..f19446dfbccfffd727b97793fc84dda1115805f9 100644 (file)
--- a/cgit.css
+++ b/cgit.css
@@ -471,3 +471,27 @@ div.footer {
        font-size: 80%;
        color: #ccc;
 }
+a.branch-deco {
+       margin: 0px 0.5em;
+       padding: 0px 0.25em;
+       background-color: #88ff88;
+       border: solid 1px #007700;
+}
+a.tag-deco {
+       margin: 0px 0.5em;
+       padding: 0px 0.25em;
+       background-color: #ffff88;
+       border: solid 1px #777700;
+}
+a.remote-deco {
+       margin: 0px 0.5em;
+       padding: 0px 0.25em;
+       background-color: #ccccff;
+       border: solid 1px #000077;
+}
+a.deco {
+       margin: 0px 0.5em;
+       padding: 0px 0.25em;
+       background-color: #ff8888;
+       border: solid 1px #770000;
+}
index 0d62cc82c5d5dbbc90e351a73e3c748e427ba7c0..33f4eb00ff2808e9f4335b397e809d695b464301 100755 (executable)
@@ -15,7 +15,7 @@ run_test 'find line 1' '
 '
 
 run_test 'no line 2' '
-       grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
+       grep -e "<a id=.n2. name=.n2. href=.#n2.>2</a>" trash/tmp
 '
 
 run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp'
index 5f1b862ea9c1f4a879ef6767d5b90ae6479546fc..8ab4912a282b667fb19779138c7fe739acdfc321 100755 (executable)
@@ -10,7 +10,7 @@ run_test 'get foo/snapshot/master.tar.gz' '
 
 run_test 'check html headers' '
        head -n 1 trash/tmp |
-            grep -e "Content-Type: application/x-tar" &&
+            grep -e "Content-Type: application/x-gzip" &&
 
        head -n 2 trash/tmp |
             grep -e "Content-Disposition: inline; filename=.master.tar.gz."
index 2f90778c70b22d80a6282eea60190f2cdf78c521..c3757dd0131d75c2764dc0a0931a57085b7fc8b5 100644 (file)
--- a/ui-log.c
+++ b/ui-log.c
@@ -31,6 +31,38 @@ void inspect_files(struct diff_filepair *pair)
                cgit_diff_files(pair->one->sha1, pair->two->sha1, count_lines);
 }
 
+void show_commit_decorations(struct commit *commit)
+{
+       struct name_decoration *deco;
+       static char buf[1024];
+
+       buf[sizeof(buf) - 1] = 0;
+       deco = lookup_decoration(&name_decoration, &commit->object);
+       while (deco) {
+               if (!prefixcmp(deco->name, "refs/heads/")) {
+                       strncpy(buf, deco->name + 11, sizeof(buf) - 1);
+                       cgit_log_link(buf, NULL, "branch-deco", buf, NULL, NULL,
+                               0, NULL, NULL, ctx.qry.showmsg);
+               }
+               else if (!prefixcmp(deco->name, "tag: refs/tags/")) {
+                       strncpy(buf, deco->name + 15, sizeof(buf) - 1);
+                       cgit_tag_link(buf, NULL, "tag-deco", ctx.qry.head, buf);
+               }
+               else if (!prefixcmp(deco->name, "refs/remotes/")) {
+                       strncpy(buf, deco->name + 13, sizeof(buf) - 1);
+                       cgit_log_link(buf, NULL, "remote-deco", NULL,
+                               sha1_to_hex(commit->object.sha1), NULL,
+                               0, NULL, NULL, ctx.qry.showmsg);
+               }
+               else {
+                       strncpy(buf, deco->name, sizeof(buf) - 1);
+                       cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
+                               sha1_to_hex(commit->object.sha1));
+               }
+               deco = deco->next;
+       }
+}
+
 void print_commit(struct commit *commit)
 {
        struct commitinfo *info;
@@ -49,6 +81,7 @@ void print_commit(struct commit *commit)
                ctx.qry.showmsg ? " class='logsubject'" : "");
        cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
                         sha1_to_hex(commit->object.sha1));
+       show_commit_decorations(commit);
        html("</td><td>");
        html_txt(info->author);
        if (ctx.repo->enable_log_filecount) {
@@ -119,6 +152,8 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern
        rev.verbose_header = 1;
        rev.show_root_diff = 0;
        setup_revisions(argc, argv, &rev, NULL);
+       load_ref_decorations();
+       rev.show_decorations = 1;
        rev.grep_filter.regflags |= REG_ICASE;
        compile_grep_patterns(&rev.grep_filter);
        prepare_revision_walk(&rev);
index e60877d8ed2fcf2a6a76dab90d08b5eadcc9ea6f..1d7733645d68efb41e682fa8e24c80dc9f8958df 100644 (file)
@@ -101,9 +101,9 @@ void cgit_print_patch(char *hex)
        ctx.page.filename = patchname;
        cgit_print_http_headers(&ctx);
        htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
-       htmlf("From: %s%s\n", info->author, info->author_email);
+       htmlf("From: %s %s\n", info->author, info->author_email);
        html("Date: ");
-       cgit_print_date(info->author_date, "%a, %d  %b  %Y  %H:%M:%S  %z%n", ctx.cfg.local_time);
+       cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
        htmlf("Subject: %s\n\n", info->subject);
        if (info->msg && *info->msg) {
                htmlf("%s", info->msg);
index d61ee7c8d150d1adf5da535148bf9a1114f1440a..c35e694e8e6517811ad808849dc5d88474901f59 100644 (file)
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -141,7 +141,7 @@ static int print_tag(struct refinfo *ref)
                html("<tr><td>");
                html_txt(name);
                html("</td><td>");
-               if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT))
+               if (ctx.repo->snapshots && (ref->object->type == OBJ_COMMIT))
                        print_tag_downloads(ctx.repo, name);
                else
                        cgit_object_link(ref->object);
index f98f5d74bf46ead3077bd79a975703d9bb016c83..f25613e9d6c98530e48c1814305000d22ebbb44f 100644 (file)
@@ -58,8 +58,8 @@ static int write_tar_bzip2_archive(struct archiver_args *args)
 
 const struct cgit_snapshot_format cgit_snapshot_formats[] = {
        { ".zip", "application/x-zip", write_zip_archive, 0x1 },
-       { ".tar.gz", "application/x-tar", write_tar_gzip_archive, 0x2 },
-       { ".tar.bz2", "application/x-tar", write_tar_bzip2_archive, 0x4 },
+       { ".tar.gz", "application/x-gzip", write_tar_gzip_archive, 0x2 },
+       { ".tar.bz2", "application/x-bzip2", write_tar_bzip2_archive, 0x4 },
        { ".tar", "application/x-tar", write_tar_archive, 0x8 },
        {}
 };
index 051db7cb28cbf2321ca67582aac866596743a465..9876c9972e9558f82632d03280997cc8db234fac 100644 (file)
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -54,8 +54,10 @@ static void print_object(const unsigned char *sha1, char *path)
                }
                idx++;
        }
-       htmlf(linefmt, ++lineno);
-       html_txt(buf + start);
+       if (start < idx) {
+               htmlf(linefmt, ++lineno);
+               html_txt(buf + start);
+       }
        html("</td></tr>\n");
        html("</table>\n");
 }