From 4b4f8d1256669bf9838e17f83a070de0ec09a699 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 1 Dec 2008 19:13:44 +0100 Subject: [PATCH 01/16] ui-snapshot: improve extraction of revision from snapshot name The modified get_ref_from_filename() supports the following snapshot formats: * $REV.$EXT * $REPO[-_]*v?$REV.$EXT This implies that the following urls will retrieve the expected revision: * http://hjemli.net/git/cgit/snapshot/v0.8.1.tar.gz * http://hjemli.net/git/cgit/snapshot/0.8.1.tar.gz * http://hjemli.net/git/cgit/snapshot/cgit-0.8.1.tar.gz * http://hjemli.net/git/cgit/snapshot/cgit-140012d7a8.tar.gz Signed-off-by: Lars Hjemli --- ui-snapshot.c | 80 ++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/ui-snapshot.c b/ui-snapshot.c index 76457d6..6f09151 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -114,52 +114,46 @@ static int make_snapshot(const struct cgit_snapshot_format *format, return 0; } -char *dwim_filename = NULL; -const char *dwim_refname = NULL; - -static int ref_cb(const char *refname, const unsigned char *sha1, int flags, - void *cb_data) -{ - const char *r = refname; - while (r && *r) { - fprintf(stderr, " cmp %s with %s:", dwim_filename, r); - if (!strcmp(dwim_filename, r)) { - fprintf(stderr, "MATCH!\n"); - dwim_refname = refname; - return 1; - } - fprintf(stderr, "no match\n"); - if (isdigit(*r)) - break; - r++; - } - return 0; -} - -/* Try to guess the requested revision by combining repo name and tag name - * and comparing this to the requested snapshot name. E.g. the requested - * snapshot is "cgit-0.7.2.tar.gz" while repo name is "cgit" and tag name - * is "v0.7.2". First, the reponame is stripped off, leaving "-0.7.2.tar.gz". - * Next, any '-' and '_' characters are stripped, leaving "0.7.2.tar.gz". - * Finally, the requested format suffix is removed and we end up with "0.7.2". - * Then we test each tag against this dwimmed filename, and for each tag - * we even try to remove any leading characters which are non-digits. I.e. - * we first compare with "v0.7.2", then with "0.7.2" and we've got a match. +/* Try to guess the requested revision from the requested snapshot name. + * First the format extension is stripped, e.g. "cgit-0.7.2.tar.gz" become + * "cgit-0.7.2". If this is a valid commit object name we've got a winner. + * Otherwise, if the snapshot name has a prefix matching the result from + * repo_basename(), we strip the basename and any following '-' and '_' + * characters ("cgit-0.7.2" -> "0.7.2") and check the resulting name once + * more. If this still isn't a valid commit object name, we check if pre- + * pending a 'v' to the remaining snapshot name ("0.7.2" -> "v0.7.2") gives + * us something valid. */ static const char *get_ref_from_filename(const char *url, const char *filename, - const struct cgit_snapshot_format *fmt) + const struct cgit_snapshot_format *format) { - const char *reponame = cgit_repobasename(url); - fprintf(stderr, "reponame=%s, filename=%s\n", reponame, filename); - if (prefixcmp(filename, reponame)) - return NULL; - filename += strlen(reponame); - while (filename && (*filename == '-' || *filename == '_')) - filename++; - dwim_filename = xstrdup(filename); - dwim_filename[strlen(filename) - strlen(fmt->suffix)] = '\0'; - for_each_tag_ref(ref_cb, NULL); - return dwim_refname; + const char *reponame; + unsigned char sha1[20]; + char *snapshot; + + snapshot = xstrdup(filename); + snapshot[strlen(snapshot) - strlen(format->suffix)] = '\0'; + fprintf(stderr, "snapshot=%s\n", snapshot); + + if (get_sha1(snapshot, sha1) == 0) + return snapshot; + + reponame = cgit_repobasename(url); + fprintf(stderr, "reponame=%s\n", reponame); + if (prefixcmp(snapshot, reponame) == 0) { + snapshot += strlen(reponame); + while (snapshot && (*snapshot == '-' || *snapshot == '_')) + snapshot++; + } + + if (get_sha1(snapshot, sha1) == 0) + return snapshot; + + snapshot = fmt("v%s", snapshot); + if (get_sha1(snapshot, sha1) == 0) + return snapshot; + + return NULL; } void cgit_print_snapshot(const char *head, const char *hex, -- 2.50.1 From b9053a4ff04fef90d1b9ab3f813ae3fcee63a8c3 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 1 Dec 2008 21:50:19 +0100 Subject: [PATCH 02/16] ui-shared: exploit snapshot dwimmery in cgit_print_snapshot_links Since we know that ui-snapshot.c is able to extract the revision from the filename, there's no longer necessary to specify the revision with a 'id' querystring argument. Signed-off-by: Lars Hjemli --- ui-shared.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index 224e5f3..c4a506e 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -707,8 +707,7 @@ void cgit_print_snapshot_links(const char *repo, const char *head, continue; filename = fmt("%s-%s%s", cgit_repobasename(repo), hex, f->suffix); - cgit_snapshot_link(filename, NULL, NULL, (char *)head, - (char *)hex, filename); + cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); html("
"); } } -- 2.50.1 From 6596268576a4f5fe2f5c8a3238856b0fb205ff76 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 1 Dec 2008 21:56:07 +0100 Subject: [PATCH 03/16] ui-refs.c: show download links for all tags referring to commit objects The snapshot function has only been linked to from the commit page while users often would want to download a certain release. With this patch, direct download links will now be printed for each tagged release on the repo summary page. Signed-off-by: Lars Hjemli --- ui-refs.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/ui-refs.c b/ui-refs.c index 32e0429..0805fc8 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -78,12 +78,37 @@ static int print_branch(struct refinfo *ref) static void print_tag_header() { html("Tag" - "Reference" + "Download" "Author" "Age\n"); header = 1; } +static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) +{ + const struct cgit_snapshot_format* f; + char *filename; + const char *basename; + + if (!ref || strlen(ref) < 2) + return; + + basename = cgit_repobasename(repo->url); + if (prefixcmp(ref, basename) != 0) { + if ((ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1])) + ref++; + if (isdigit(ref[0])) + ref = xstrdup(fmt("%s-%s", basename, ref)); + } + + for (f = cgit_snapshot_formats; f->suffix; f++) { + if (!(repo->snapshots & f->bit)) + continue; + filename = fmt("%s%s", ref, f->suffix); + cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); + html("  "); + } +} static int print_tag(struct refinfo *ref) { struct tag *tag; @@ -98,7 +123,10 @@ static int print_tag(struct refinfo *ref) html(""); cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); html(""); - cgit_object_link(tag->tagged); + if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) + print_tag_downloads(ctx.repo, name); + else + cgit_object_link(tag->tagged); html(""); if (info->tagger) html(info->tagger); @@ -112,7 +140,10 @@ static int print_tag(struct refinfo *ref) html(""); html_txt(name); html(""); - cgit_object_link(ref->object); + if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) + print_tag_downloads(ctx.repo, name); + else + cgit_object_link(ref->object); html("\n"); } return 0; -- 2.50.1 From c57aceb1d2f1a7d9fd3218fc8c6e9ea01b2952d2 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 1 Dec 2008 21:58:59 +0100 Subject: [PATCH 04/16] ui-shared: shorten the sha1 printed by cgit_object_link Such links was printed as the object type followed by the objects complete sha1. We still use the complete sha1 in the link but we no longer show it in all its glory; only the first 10 hex chars are printed. Signed-off-by: Lars Hjemli --- ui-shared.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index c4a506e..9319881 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -365,11 +365,14 @@ void cgit_patch_link(char *name, char *title, char *class, char *head, void cgit_object_link(struct object *obj) { - char *page, *rev, *name; + char *page, *shortrev, *fullrev, *name; + fullrev = sha1_to_hex(obj->sha1); + shortrev = xstrdup(fullrev); + shortrev[10] = '\0'; if (obj->type == OBJ_COMMIT) { - cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, - ctx.qry.head, sha1_to_hex(obj->sha1)); + cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL, + ctx.qry.head, fullrev); return; } else if (obj->type == OBJ_TREE) page = "tree"; @@ -377,9 +380,8 @@ void cgit_object_link(struct object *obj) page = "tag"; else page = "blob"; - rev = sha1_to_hex(obj->sha1); - name = fmt("%s %s", typename(obj->type), rev); - reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL); + name = fmt("%s %s...", typename(obj->type), shortrev); + reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL); } void cgit_print_date(time_t secs, char *format, int local_time) -- 2.50.1 From a1b01b2513510f8f93f7f8ca39969002cd496a19 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Wed, 3 Dec 2008 17:34:23 +0100 Subject: [PATCH 05/16] ui-log: try to disambiguate ref names The 'h' querystring parameter in cgit is normally used to specify a branch (i.e. a ref below refs/heads/), but if a repository contains a tag with the same name as a branch the output from ui-log would use the tag as start-revision. This patch tries to fix the issue by checking if the specified ref is valid as a branch name; if so, the full refname is used in the call to setup_revisions(). Noticed-by: Takamori Yamaguchi Signed-off-by: Lars Hjemli --- ui-log.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ui-log.c b/ui-log.c index 8dd8b89..d212984 100644 --- a/ui-log.c +++ b/ui-log.c @@ -64,18 +64,31 @@ void print_commit(struct commit *commit) cgit_free_commitinfo(info); } +static const char *disambiguate_ref(const char *ref) +{ + unsigned char sha1[20]; + const char *longref; + + longref = fmt("refs/heads/%s", ref); + if (get_sha1(longref, sha1) == 0) + return longref; + + return ref; +} void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, char *path, int pager) { struct rev_info rev; struct commit *commit; - const char *argv[] = {NULL, tip, NULL, NULL, NULL}; + const char *argv[] = {NULL, NULL, NULL, NULL, NULL}; int argc = 2; int i, columns = 3; if (!tip) - argv[1] = ctx.qry.head; + tip = ctx.qry.head; + + argv[1] = disambiguate_ref(tip); if (grep && pattern && (!strcmp(grep, "grep") || !strcmp(grep, "author") || -- 2.50.1 From 97fdac1608a0b4b07aae26b144c6ee7991e6c5eb Mon Sep 17 00:00:00 2001 From: Ramsay Jones Date: Sat, 15 Nov 2008 18:26:32 +0000 Subject: [PATCH 06/16] Extra cygwin-specific changes Signed-off-by: Ramsay Jones Signed-off-by: Lars Hjemli --- Makefile | 23 +++++++++++++++++++++++ cgit.h | 6 ------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 2107610..dc98072 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,26 @@ GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 # -include cgit.conf +# Define NO_STRCASESTR if you don't have strcasestr. +# +# Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). +# + +#-include config.mak + +# +# Platform specific tweaks +# + +uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') +uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') +uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') + +ifeq ($(uname_O),Cygwin) + NO_STRCASESTR = YesPlease + NEEDS_LIBICONV = YesPlease +endif + # # Define a way to invoke make in subdirs quietly, shamelessly ripped # from git.git @@ -96,6 +116,9 @@ CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' ifdef NO_ICONV CFLAGS += -DNO_ICONV endif +ifdef NO_STRCASESTR + CFLAGS += -DNO_STRCASESTR +endif cgit: $(OBJECTS) libgit $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) diff --git a/cgit.h b/cgit.h index 91db98a..92f0c5a 100644 --- a/cgit.h +++ b/cgit.h @@ -233,11 +233,5 @@ extern const char *cgit_repobasename(const char *reponame); extern int cgit_parse_snapshots_mask(const char *str); -/* libgit.a either links against or compiles its own implementation of - * strcasestr(), and we'd like to reuse it. Simply re-declaring it - * seems to do the trick. - */ -extern char *strcasestr(const char *haystack, const char *needle); - #endif /* CGIT_H */ -- 2.50.1 From a5e899e4c786e2ed7f58874d66956bf196cef8df Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 5 Dec 2008 18:47:16 +0100 Subject: [PATCH 07/16] Makefile: allow cgit.conf to override platform-specific tweaks If the makefile doesn't automatically define the correct build variables it is nice to be able to define them explicitly. Signed-off-by: Lars Hjemli --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index dc98072..2e51c31 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,6 @@ SHA1_HEADER = GIT_VER = 1.6.0.3 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 -# -# Let the user override the above settings. -# --include cgit.conf - # Define NO_STRCASESTR if you don't have strcasestr. # # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). @@ -32,6 +27,11 @@ ifeq ($(uname_O),Cygwin) NEEDS_LIBICONV = YesPlease endif +# +# Let the user override the above settings. +# +-include cgit.conf + # # Define a way to invoke make in subdirs quietly, shamelessly ripped # from git.git -- 2.50.1 From 7115f7d257b5e3fb5d5d7ad6299214506fb35042 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 5 Dec 2008 19:04:17 +0100 Subject: [PATCH 08/16] ui-repolist: avoid build warning for strcasestr(3) The non-standard function strcasestr is only defined if _GNU_SOURCE has also been defined. Signed-off-by: Lars Hjemli --- ui-repolist.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui-repolist.c b/ui-repolist.c index c23232c..2324273 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -6,6 +6,10 @@ * (see COPYING for full license text) */ +/* This is needed for strcasestr to be defined by */ +#define _GNU_SOURCE 1 +#include + #include #include "cgit.h" -- 2.50.1 From 14b4e108a73b09ce9b6df2c7f2e417305ad68cf4 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 5 Dec 2008 19:10:28 +0100 Subject: [PATCH 09/16] parsing.c: enable builds with NO_ICONV defined Signed-off-by: Lars Hjemli --- parsing.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parsing.c b/parsing.c index c8f3048..f3f3b15 100644 --- a/parsing.c +++ b/parsing.c @@ -96,6 +96,9 @@ char *parse_user(char *t, char **name, char **email, unsigned long *date) return p; } +#ifdef NO_ICONV +#define reencode(a, b, c) +#else const char *reencode(char **txt, const char *src_enc, const char *dst_enc) { char *tmp; @@ -110,6 +113,7 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc) } return *txt; } +#endif struct commitinfo *cgit_parse_commit(struct commit *commit) { -- 2.50.1 From 2755af6e29801ea10b5d7be6a0a5635ba3bc9660 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 6 Dec 2008 11:53:59 +0100 Subject: [PATCH 10/16] tests/t0010-validate-html.sh: skip tests if 'tidy' is not available Noticed-by: Ramsay Jones Signed-off-by: Lars Hjemli --- tests/t0010-validate-html.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/t0010-validate-html.sh b/tests/t0010-validate-html.sh index 94aa52b..3fe4800 100755 --- a/tests/t0010-validate-html.sh +++ b/tests/t0010-validate-html.sh @@ -9,7 +9,7 @@ test_url() test -z "$NO_TIDY_WARNINGS" || tidy_opt+=" --show-warnings no" cgit_url "$1" >trash/tidy-$test_count || return sed -ie "1,4d" trash/tidy-$test_count || return - tidy $tidy_opt trash/tidy-$test_count + "$tidy" $tidy_opt trash/tidy-$test_count rc=$? # tidy returns with exitcode 1 on warnings, 2 on error @@ -23,6 +23,13 @@ test_url() prepare_tests 'Validate html with tidy' +tidy=`which tidy` +test -n "$tidy" || { + echo "Skipping tests: tidy not found" + tests_done + exit +} + run_test 'index page' 'test_url ""' run_test 'foo' 'test_url "foo"' run_test 'foo/log' 'test_url "foo/log"' -- 2.50.1 From b6faa78091a1340b73e291f1f87604f246d3f391 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Sat, 6 Dec 2008 12:03:54 +0100 Subject: [PATCH 11/16] tests/setup.sh: allow testsuite to fail properly with POSIX standard shells The "((expr))" construct is not implemented by e.g. dash, so this commit replaces the construct with a more portable one. Signed-off-by: Lars Hjemli --- tests/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/setup.sh b/tests/setup.sh index 95acb54..30f90d5 100755 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -113,7 +113,7 @@ run_test() then printf " %2d) %-60s [ok]\n" $test_count "$desc" else - ((test_failed++)) + test_failed=$(expr $test_failed + 1) printf " %2d) %-60s [failed]\n" $test_count "$desc" fi } -- 2.50.1 From 0edf76078e6a36ba502e6ffb97021166ea459a7f Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 26 Dec 2008 11:02:02 +0100 Subject: [PATCH 12/16] shared.c: future-proof usage of git diff-structures Signed-off-by: Lars Hjemli --- shared.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/shared.c b/shared.c index 89d1bab..a764c4d 100644 --- a/shared.c +++ b/shared.c @@ -267,10 +267,12 @@ int cgit_diff_files(const unsigned char *old_sha1, if (!load_mmfile(&file1, old_sha1) || !load_mmfile(&file2, new_sha1)) return 1; + memset(&diff_params, 0, sizeof(diff_params)); + memset(&emit_params, 0, sizeof(emit_params)); + memset(&emit_cb, 0, sizeof(emit_cb)); diff_params.flags = XDF_NEED_MINIMAL; emit_params.ctxlen = 3; emit_params.flags = XDL_EMIT_FUNCNAMES; - emit_params.find_func = NULL; emit_cb.outf = filediff_cb; emit_cb.priv = fn; xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); -- 2.50.1 From 06de14d0fdb141feab10383ba18c0e81d56f483b Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Fri, 26 Dec 2008 11:03:01 +0100 Subject: [PATCH 13/16] Use GIT-1.6.1 Signed-off-by: Lars Hjemli --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2e51c31..3c7ec07 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_CONFIG = /etc/cgitrc CACHE_ROOT = /var/cache/cgit SHA1_HEADER = -GIT_VER = 1.6.0.3 +GIT_VER = 1.6.1 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 # Define NO_STRCASESTR if you don't have strcasestr. diff --git a/git b/git index 031e6c8..8104ebf 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 031e6c898f61db1ae0c0be641eac6532c1000d56 +Subproject commit 8104ebfe8276657ee803cca7eb8665a78cf3ef83 -- 2.50.1 From 03afc5fe1fe70b6e44b60708c89708060e6d5a90 Mon Sep 17 00:00:00 2001 From: Tomas Carnecky Date: Tue, 30 Dec 2008 11:14:52 +0100 Subject: [PATCH 14/16] ui-patch: whitespace changes in the patch generation code Add a space between the committer name and email, and remove superfluous spaces in the date header. This makes cgit-generated patches match the output from git-format-patch almost exactly, at least as far as the email headers go. Signed-off-by: Tomas Carnecky Signed-off-by: Lars Hjemli --- ui-patch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-patch.c b/ui-patch.c index e60877d..1d77336 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -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); -- 2.50.1 From f3c99cf1cee25ae95ffea6188b40734e877bce20 Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Tue, 6 Jan 2009 21:37:23 +0100 Subject: [PATCH 15/16] ui-tree.c: do not add blank line when displaying blobs Also, fix a related bug in the test-suite. Noticed-by: Jim Meyering Signed-off-by: Lars Hjemli --- tests/t0104-tree.sh | 2 +- ui-tree.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 0d62cc8..33f4eb0 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -15,7 +15,7 @@ run_test 'find line 1' ' ' run_test 'no line 2' ' - grep -e "2" trash/tmp + ! grep -e "2" trash/tmp ' run_test 'generate foo+bar/tree' 'cgit_url "foo%2bbar/tree" >trash/tmp' diff --git a/ui-tree.c b/ui-tree.c index 79332fc..4bf372a 100644 --- 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("\n"); html("\n"); } -- 2.50.1 From 5164be32778e2bca146e13904e5b9e79d0d6cca8 Mon Sep 17 00:00:00 2001 From: Robin Redeker Date: Sat, 10 Jan 2009 12:44:08 +0100 Subject: [PATCH 16/16] ui-refs: avoid SEGFAULT on lightweight tags Signed-off-by: Robin Redeker Signed-off-by: Lars Hjemli --- ui-refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-refs.c b/ui-refs.c index d61ee7c..c35e694 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -141,7 +141,7 @@ static int print_tag(struct refinfo *ref) html(""); html_txt(name); html(""); - 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); -- 2.50.1