From mailings at hupie.com Wed Jun 1 13:35:24 2011 From: mailings at hupie.com (Ferry Huberts) Date: Wed, 01 Jun 2011 13:35:24 +0200 Subject: web server errors on access to snapshot file Message-ID: <4DE623FC.9090504@hupie.com> Hi, I've noticed errors in my web server log. This happens upon first access to a snapshot file. > [Tue May 24 17:41:21 2011] [error] [client 192.168.180.1] snapshot=server_installs-1.2.0, referer: http://gittest.local/cgit/server_installs/tag/?id=v1.2.0 > [Tue May 24 17:41:21 2011] [error] [client 192.168.180.1] reponame=server_installs, referer: http://gittest.local/cgit/server_installs/tag/?id=v1.2.0 Any idea why this happens? grtz -- Ferry Huberts From hjemli at gmail.com Wed Jun 1 14:12:40 2011 From: hjemli at gmail.com (Lars Hjemli) Date: Wed, 1 Jun 2011 14:12:40 +0200 Subject: web server errors on access to snapshot file In-Reply-To: <4DE623FC.9090504@hupie.com> References: <4DE623FC.9090504@hupie.com> Message-ID: On Wed, Jun 1, 2011 at 13:35, Ferry Huberts wrote: > I've noticed errors in my web server log. > This happens upon first access to a snapshot file. > >> [Tue May 24 17:41:21 2011] [error] [client 192.168.180.1] snapshot=server_installs-1.2.0, referer: http://gittest.local/cgit/server_installs/tag/?id=v1.2.0 It's not an error, it's just leftover debug cruft (I'll remove it). See http://hjemli.net/git/cgit/tree/ui-snapshot.c#n122 -- larsh From mailings at hupie.com Wed Jun 1 14:25:07 2011 From: mailings at hupie.com (Ferry Huberts) Date: Wed, 01 Jun 2011 14:25:07 +0200 Subject: web server errors on access to snapshot file In-Reply-To: References: <4DE623FC.9090504@hupie.com> Message-ID: <4DE62FA3.1050607@hupie.com> On 06/01/2011 02:12 PM, Lars Hjemli wrote: > On Wed, Jun 1, 2011 at 13:35, Ferry Huberts wrote: >> I've noticed errors in my web server log. >> This happens upon first access to a snapshot file. >> >>> [Tue May 24 17:41:21 2011] [error] [client 192.168.180.1] snapshot=server_installs-1.2.0, referer: http://gittest.local/cgit/server_installs/tag/?id=v1.2.0 > > It's not an error, it's just leftover debug cruft (I'll remove it). > See http://hjemli.net/git/cgit/tree/ui-snapshot.c#n122 > > -- > larsh cool, thanks. please also remove line 128 then :-) -- Ferry Huberts From thomas.moschny at gmx.de Wed Jun 1 16:34:11 2011 From: thomas.moschny at gmx.de (Thomas Moschny) Date: Wed, 1 Jun 2011 16:34:11 +0200 Subject: git gc and idle times In-Reply-To: <4DE4A557.7040604@hupie.com> References: <20110511160628.7d00fb2a@andromeda.ipd.uni-karlsruhe.de> <4DE4A557.7040604@hupie.com> Message-ID: <20110601163411.1aa713cf@andromeda.ipd.uni-karlsruhe.de> Ferry Huberts : > On 05/11/2011 04:06 PM, Thomas Moschny wrote: > > One question however: After running git-gc on some of the > > repositories, the overview page of cgit misses idle times for > > those. The idle time is back after pushing a commit. Is there > > something that needs to be adjusted/fixed manually after running > > git-gc? Or is it a bug of cgit? > > patch is in master: 21e0e0bfac660072a4518f91f59d5c4bf6e764b5 Thanks! Meanwhile, I added this code to each post-update hook git for-each-ref --format='%(committerdate)' \ --sort=-committerdate --count=1 \ > $GIT_DIR/info/web/last-modified Works fine. -- Thomas Moschny From dpmcgee at gmail.com Thu Jun 2 21:01:12 2011 From: dpmcgee at gmail.com (Dan McGee) Date: Thu, 2 Jun 2011 14:01:12 -0500 Subject: [PATCH 1/2] Update to use pathspec in read_tree_recursive calls Message-ID: <1307041273-16994-1-git-send-email-dpmcgee@gmail.com> This is needed after commit f0096c06 in the git.git repo (a post 1.7.4 change). Signed-off-by: Dan McGee --- These aren't needed right away, but thought I'd save anyone the trouble going forward moving to a newer version of git. These have been working for me for a week or so. shared.c | 10 +++++----- ui-blob.c | 16 +++++++++++----- ui-tree.c | 10 ++++++++-- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/shared.c b/shared.c index be2ae59..8316bfd 100644 --- a/shared.c +++ b/shared.c @@ -305,7 +305,6 @@ void cgit_diff_tree(const unsigned char *old_sha1, filepair_fn fn, const char *prefix, int ignorews) { struct diff_options opt; - int prefixlen; diff_setup(&opt); opt.output_format = DIFF_FORMAT_CALLBACK; @@ -317,10 +316,10 @@ void cgit_diff_tree(const unsigned char *old_sha1, opt.format_callback = cgit_diff_tree_cb; opt.format_callback_data = fn; if (prefix) { - opt.nr_paths = 1; - opt.paths = &prefix; - prefixlen = strlen(prefix); - opt.pathlens = &prefixlen; + const char *paths[] = {prefix, NULL}; + init_pathspec(&opt.pathspec, paths); + } else { + init_pathspec(&opt.pathspec, NULL); } diff_setup_done(&opt); @@ -330,6 +329,7 @@ void cgit_diff_tree(const unsigned char *old_sha1, diff_root_tree_sha1(new_sha1, "", &opt); diffcore_std(&opt); diff_flush(&opt); + free_pathspec(&opt.pathspec); } void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix) diff --git a/ui-blob.c b/ui-blob.c index ec435e1..f3b0d0d 100644 --- a/ui-blob.c +++ b/ui-blob.c @@ -32,16 +32,19 @@ int cgit_print_file(char *path, const char *head) char *buf; unsigned long size; struct commit *commit; - const char *paths[] = {path, NULL}; if (get_sha1(head, sha1)) return -1; type = sha1_object_info(sha1, &size); if(type == OBJ_COMMIT && path) { + struct pathspec pathspec; + const char *paths[] = {path, NULL}; commit = lookup_commit_reference(sha1); match_path = path; matched_sha1 = sha1; found_path = 0; - read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL); + init_pathspec(&pathspec, paths); + read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL); + free_pathspec(&pathspec); if (!found_path) return -1; type = sha1_object_info(sha1, &size); @@ -63,7 +66,6 @@ void cgit_print_blob(const char *hex, char *path, const char *head) char *buf; unsigned long size; struct commit *commit; - const char *paths[] = {path, NULL}; if (hex) { if (get_sha1_hex(hex, sha1)){ @@ -80,11 +82,15 @@ void cgit_print_blob(const char *hex, char *path, const char *head) type = sha1_object_info(sha1, &size); if((!hex) && type == OBJ_COMMIT && path) { + struct pathspec pathspec; + const char *paths[] = {path, NULL}; commit = lookup_commit_reference(sha1); match_path = path; matched_sha1 = sha1; - read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL); - type = sha1_object_info(sha1,&size); + init_pathspec(&pathspec, paths); + read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL); + free_pathspec(&pathspec); + type = sha1_object_info(sha1, &size); } if (type == OBJ_BAD) { diff --git a/ui-tree.c b/ui-tree.c index 2d8d2f3..1f18c21 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -207,6 +207,7 @@ static void ls_tail() static void ls_tree(const unsigned char *sha1, char *path) { struct tree *tree; + struct pathspec pathspec; tree = parse_tree_indirect(sha1); if (!tree) { @@ -216,7 +217,9 @@ static void ls_tree(const unsigned char *sha1, char *path) } ls_head(); - read_tree_recursive(tree, "", 0, 1, NULL, ls_item, NULL); + init_pathspec(&pathspec, NULL); + read_tree_recursive(tree, "", 0, 1, &pathspec, ls_item, NULL); + free_pathspec(&pathspec); ls_tail(); } @@ -257,6 +260,7 @@ void cgit_print_tree(const char *rev, char *path) { unsigned char sha1[20]; struct commit *commit; + struct pathspec pathspec; const char *paths[] = {path, NULL}; if (!rev) @@ -279,6 +283,8 @@ void cgit_print_tree(const char *rev, char *path) } match_path = path; - read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL); + init_pathspec(&pathspec, paths); + read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL); + free_pathspec(&pathspec); ls_tail(); } -- 1.7.5.2 From dpmcgee at gmail.com Thu Jun 2 21:01:13 2011 From: dpmcgee at gmail.com (Dan McGee) Date: Thu, 2 Jun 2011 14:01:13 -0500 Subject: [PATCH 2/2] Use max_parents to support newer git upstream code In-Reply-To: <1307041273-16994-1-git-send-email-dpmcgee@gmail.com> References: <1307041273-16994-1-git-send-email-dpmcgee@gmail.com> Message-ID: <1307041273-16994-2-git-send-email-dpmcgee@gmail.com> This is necessary after commit ad5aeeded upstream. Signed-off-by: Dan McGee --- ui-stats.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/ui-stats.c b/ui-stats.c index 59f4c1e..51dd6a2 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -239,7 +239,7 @@ struct string_list collect_stats(struct cgit_context *ctx, init_revisions(&rev, NULL); rev.abbrev = DEFAULT_ABBREV; rev.commit_format = CMIT_FMT_DEFAULT; - rev.no_merges = 1; + rev.max_parents = 1; rev.verbose_header = 1; rev.show_root_diff = 0; setup_revisions(argc, argv, &rev, NULL); -- 1.7.5.2 From jamie.couture at gmail.com Fri Jun 3 01:40:53 2011 From: jamie.couture at gmail.com (jamie.couture at gmail.com) Date: Thu, 2 Jun 2011 19:40:53 -0400 Subject: [PATCH 1/2] avoid memory leak In-Reply-To: References: Message-ID: <1307058054-2552-1-git-send-email-jamie.couture@gmail.com> free rel when we're done --- scan-tree.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) From jamie.couture at gmail.com Fri Jun 3 01:40:54 2011 From: jamie.couture at gmail.com (jamie.couture at gmail.com) Date: Thu, 2 Jun 2011 19:40:54 -0400 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <1307058054-2552-1-git-send-email-jamie.couture@gmail.com> References: <1307058054-2552-1-git-send-email-jamie.couture@gmail.com> Message-ID: <1307058054-2552-2-git-send-email-jamie.couture@gmail.com> --- cgit.c | 2 ++ cgit.h | 1 + cgitrc.5.txt | 8 ++++++++ scan-tree.c | 10 ++++++++++ 4 files changed, 21 insertions(+), 0 deletions(-) From mailings at hupie.com Fri Jun 3 09:19:30 2011 From: mailings at hupie.com (Ferry Huberts) Date: Fri, 03 Jun 2011 09:19:30 +0200 Subject: [PATCH 1/2] avoid memory leak In-Reply-To: <1307058054-2552-1-git-send-email-jamie.couture@gmail.com> References: <1307058054-2552-1-git-send-email-jamie.couture@gmail.com> Message-ID: <4DE88B02.1060004@hupie.com> On 06/03/2011 01:40 AM, jamie.couture at gmail.com wrote: > > free rel when we're done > --- > scan-tree.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > > > > _______________________________________________ > cgit mailing list > cgit at hjemli.net > http://hjemli.net/mailman/listinfo/cgit i see no patches... -- Ferry Huberts From jamie.couture at gmail.com Fri Jun 3 15:54:37 2011 From: jamie.couture at gmail.com (Jamie Couture) Date: Fri, 3 Jun 2011 09:54:37 -0400 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <1307109277-8936-1-git-send-email-jamie.couture@gmail.com> References: <1307109277-8936-1-git-send-email-jamie.couture@gmail.com> Message-ID: <1307109277-8936-2-git-send-email-jamie.couture@gmail.com> --- cgit.c | 2 ++ cgit.h | 1 + cgitrc.5.txt | 8 ++++++++ scan-tree.c | 10 ++++++++++ 4 files changed, 21 insertions(+), 0 deletions(-) From jamie.couture at gmail.com Fri Jun 3 15:54:36 2011 From: jamie.couture at gmail.com (Jamie Couture) Date: Fri, 3 Jun 2011 09:54:36 -0400 Subject: [PATCH 1/2] avoid memory leak Message-ID: <1307109277-8936-1-git-send-email-jamie.couture@gmail.com> free rel when we're done --- scan-tree.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) From jamie.couture at gmail.com Sat Jun 4 01:21:00 2011 From: jamie.couture at gmail.com (Jamie Couture) Date: Fri, 3 Jun 2011 19:21:00 -0400 Subject: [PATCH 0/2] Set section via git config Message-ID: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> From: Jamie Couture Sorry for the noise. I can see my attachments, but some people can not. Trying again. Third time's a charm? Jamie Couture (2): avoid memory leak Add feature: obtain repo section from git config cgit.c | 2 ++ cgit.h | 1 + cgitrc.5.txt | 8 ++++++++ scan-tree.c | 12 ++++++++++++ 4 files changed, 23 insertions(+), 0 deletions(-) -- 1.7.5.4 From jamie.couture at gmail.com Sat Jun 4 01:21:01 2011 From: jamie.couture at gmail.com (Jamie Couture) Date: Fri, 3 Jun 2011 19:21:01 -0400 Subject: [PATCH 1/2] avoid memory leak In-Reply-To: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> Message-ID: <1307143262-11018-2-git-send-email-jamie.couture@gmail.com> From: Jamie Couture free rel when we're done --- scan-tree.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/scan-tree.c b/scan-tree.c index 627af1b..3f579ec 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -155,6 +155,8 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) config_fn = fn; parse_configfile(xstrdup(p), &repo_config); } + + free(rel); } static void scan_path(const char *base, const char *path, repo_config_fn fn) -- 1.7.5.4 From jamie.couture at gmail.com Sat Jun 4 01:21:02 2011 From: jamie.couture at gmail.com (Jamie Couture) Date: Fri, 3 Jun 2011 19:21:02 -0400 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> Message-ID: <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> From: Jamie Couture --- cgit.c | 2 ++ cgit.h | 1 + cgitrc.5.txt | 8 ++++++++ scan-tree.c | 10 ++++++++++ 4 files changed, 21 insertions(+), 0 deletions(-) diff --git a/cgit.c b/cgit.c index f4dd6ef..6a51bec 100644 --- a/cgit.c +++ b/cgit.c @@ -207,6 +207,8 @@ void config_cb(const char *name, const char *value) ctx.cfg.scan_hidden_path = atoi(value); else if (!strcmp(name, "section-from-path")) ctx.cfg.section_from_path = atoi(value); + else if (!strcmp(name, "section-from-repo-config")) + ctx.cfg.section_from_repo_config = atoi(value); else if (!strcmp(name, "source-filter")) ctx.cfg.source_filter = new_filter(value, 1); else if (!strcmp(name, "summary-log")) diff --git a/cgit.h b/cgit.h index b5f00fc..14e8243 100644 --- a/cgit.h +++ b/cgit.h @@ -214,6 +214,7 @@ struct cgit_config { int remove_suffix; int scan_hidden_path; int section_from_path; + int section_from_repo_config; int snapshots; int summary_branches; int summary_log; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index c3698a6..a78d226 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -301,6 +301,14 @@ section-from-path:: If negative, cgit will discard the specified number of path elements above the repo directory. Default value: 0. +section-from-repo-config:: + If set to "1" obtain the section name from git config. The expected config + section.key that is used is "cgit.section". + Ex: $ git config cgit.section mysection + An alternative to section-from-path, and will not check git config if + section-from-path is set. See also: scan-path. This must be defined prior + to scan-path. + side-by-side-diffs:: If set to "1" shows side-by-side diffs instead of unidiffs per default. Default value: "0". diff --git a/scan-tree.c b/scan-tree.c index 3f579ec..3bbc4bc 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -61,6 +61,13 @@ static int git_owner_config(const char *key, const char *value, void *cb) return 0; } +static int git_section_config(const char *key, const char *value, void *cb) +{ + if (!strcmp(key, "cgit.section")) + repo->section = xstrdup(value); + return 0; +} + static char *xstrrchr(char *s, char *from, int c) { while (from >= s && *from != c) @@ -149,6 +156,9 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) } } } + else if (ctx.cfg.section_from_repo_config) { + git_config_from_file(git_section_config, fmt("%s/config", path), NULL); + } p = fmt("%s/cgitrc", path); if (!stat(p, &st)) { -- 1.7.5.4 From mailings at hupie.com Sat Jun 4 11:21:00 2011 From: mailings at hupie.com (Ferry Huberts) Date: Sat, 4 Jun 2011 11:21:00 +0200 Subject: [PATCH 1/1] commit-links.sh: improve regular expressions Message-ID: <1307179260-4984-1-git-send-email-mailings@hupie.com> From: Ferry Huberts Signed-off-by: Ferry Huberts --- filters/commit-links.sh | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/filters/commit-links.sh b/filters/commit-links.sh index d2cd2b3..44b9555 100755 --- a/filters/commit-links.sh +++ b/filters/commit-links.sh @@ -15,11 +15,14 @@ # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) # +regex='' + # This expression generates links to commits referenced by their SHA1. regex=$regex' -s|\b([0-9a-fA-F]{8,40})\b|\1|g' +s@(^|\s+)([0-9a-fA-F]{7,40})([^0-9a-fA-F]|$)@\1\2\3 at g' + # This expression generates links to a fictional bugtracker. regex=$regex' -s| #([0-9]+)\b|#\1|g' +s@(^|\s+)#([0-9]+)([^0-9#]|$)@\1#\2\3 at g' sed -re "$regex" -- 1.7.5.2 From larsh at hjemli.net Mon Jun 6 18:57:29 2011 From: larsh at hjemli.net (larsh at hjemli.net) Date: Mon, 6 Jun 2011 16:57:29 +0000 Subject: [PATCH 1/2] avoid memory leak In-Reply-To: <1307143262-11018-2-git-send-email-jamie.couture@gmail.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-2-git-send-email-jamie.couture@gmail.com> Message-ID: <20110606165729.GA6957@hjemli.net> On Fri, Jun 03, 2011 at 07:21:01PM -0400, Jamie Couture wrote: > --- a/scan-tree.c > +++ b/scan-tree.c > @@ -155,6 +155,8 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn) > config_fn = fn; > parse_configfile(xstrdup(p), &repo_config); > } > + > + free(rel); > } > > static void scan_path(const char *base, const char *path, repo_config_fn fn) Thanks. Can I add 'Signed-off by' from you on this? -- larsh From larsh at hjemli.net Mon Jun 6 19:13:44 2011 From: larsh at hjemli.net (larsh at hjemli.net) Date: Mon, 6 Jun 2011 17:13:44 +0000 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> Message-ID: <20110606171344.GB6957@hjemli.net> On Fri, Jun 03, 2011 at 07:21:02PM -0400, Jamie Couture wrote: > +section-from-repo-config:: > + If set to "1" obtain the section name from git config. The expected config > + section.key that is used is "cgit.section". > + Ex: $ git config cgit.section mysection > + An alternative to section-from-path, and will not check git config if > + section-from-path is set. See also: scan-path. This must be defined prior > + to scan-path. > + * What value is added by $GITDIR/config compared to $GITDIR/cgitrc? * If we want to support reading repo-config from $GITDIR/config, why not implement all the options supported by a $GITDIR/cgitrc? -- larsh From larsh at hjemli.net Mon Jun 6 19:27:50 2011 From: larsh at hjemli.net (larsh at hjemli.net) Date: Mon, 6 Jun 2011 17:27:50 +0000 Subject: [PATCH 1/1] commit-links.sh: improve regular expressions In-Reply-To: <1307179260-4984-1-git-send-email-mailings@hupie.com> References: <1307179260-4984-1-git-send-email-mailings@hupie.com> Message-ID: <20110606172750.GC6957@hjemli.net> On Sat, Jun 04, 2011 at 11:21:00AM +0200, Ferry Huberts wrote: > --- a/filters/commit-links.sh > +++ b/filters/commit-links.sh > @@ -15,11 +15,14 @@ > # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) > # > > +regex='' > + > # This expression generates links to commits referenced by their SHA1. > regex=$regex' > -s|\b([0-9a-fA-F]{8,40})\b|\1|g' > +s@(^|\s+)([0-9a-fA-F]{7,40})([^0-9a-fA-F]|$)@\1\2\3 at g' > + Can you explain why explicit prefix/postfix expressions are an improvement over \b? > # This expression generates links to a fictional bugtracker. > regex=$regex' > -s| #([0-9]+)\b|#\1|g' > +s@(^|\s+)#([0-9]+)([^0-9#]|$)@\1#\2\3 at g' Ditto. -- larsh From mailings at hupie.com Mon Jun 6 19:38:13 2011 From: mailings at hupie.com (Ferry Huberts) Date: Mon, 06 Jun 2011 19:38:13 +0200 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <20110606171344.GB6957@hjemli.net> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> <20110606171344.GB6957@hjemli.net> Message-ID: <4DED1085.60906@hupie.com> On 06/06/2011 07:13 PM, larsh at hjemli.net wrote: > On Fri, Jun 03, 2011 at 07:21:02PM -0400, Jamie Couture wrote: >> +section-from-repo-config:: >> + If set to "1" obtain the section name from git config. The expected config >> + section.key that is used is "cgit.section". >> + Ex: $ git config cgit.section mysection >> + An alternative to section-from-path, and will not check git config if >> + section-from-path is set. See also: scan-path. This must be defined prior >> + to scan-path. >> + > > * What value is added by $GITDIR/config compared to $GITDIR/cgitrc? > * If we want to support reading repo-config from $GITDIR/config, why not > implement all the options supported by a $GITDIR/cgitrc? > I thought about this too. It seems attractive but to me is mixing concerns: git and cgit are two different tools (although closely tied). Having cgit store (part of) its configuration in git configuration files is not good architecture, unwise and fragile since it make the cgit configuration directly dependent on git configuration. cgit can't change it's configuration format since it has to follow git's and once git changes its format cgit immediately breaks. I'd prefer not doing this (everything in $GITDIR/config). I think it's better to have $GITDIR/cgitrc files that hold the repo settings. There is this setting called repo.path though that then is kind of an annoyance to set and update. If we always use $GITDIR/cgitrc files then the repo.path setting could be automatically deduced by cgit. -- Ferry Huberts From larsh at hjemli.net Mon Jun 6 19:48:43 2011 From: larsh at hjemli.net (larsh at hjemli.net) Date: Mon, 6 Jun 2011 17:48:43 +0000 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <4DED1085.60906@hupie.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> <20110606171344.GB6957@hjemli.net> <4DED1085.60906@hupie.com> Message-ID: <20110606174843.GA7439@hjemli.net> On Mon, Jun 06, 2011 at 07:38:13PM +0200, Ferry Huberts wrote: > On 06/06/2011 07:13 PM, larsh at hjemli.net wrote: > > * If we want to support reading repo-config from $GITDIR/config, why not > > implement all the options supported by a $GITDIR/cgitrc? > > I'd prefer not doing this (everything in $GITDIR/config). I think it's > better to have $GITDIR/cgitrc files that hold the repo settings. I agree. > There is this setting called repo.path though that then is kind of an > annoyance to set and update. If we always use $GITDIR/cgitrc files then > the repo.path setting could be automatically deduced by cgit. For repo-specific cgitrc-files, repo.path (and repo.url) are automatically set (see http://hjemli.net/git/cgit/tree/cgitrc.5.txt#n446). -- larsh From mailings at hupie.com Mon Jun 6 20:18:47 2011 From: mailings at hupie.com (Ferry Huberts) Date: Mon, 06 Jun 2011 20:18:47 +0200 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <20110606174843.GA7439@hjemli.net> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> <20110606171344.GB6957@hjemli.net> <4DED1085.60906@hupie.com> <20110606174843.GA7439@hjemli.net> Message-ID: <4DED1A07.90008@hupie.com> On 06/06/2011 07:48 PM, larsh at hjemli.net wrote: > On Mon, Jun 06, 2011 at 07:38:13PM +0200, Ferry Huberts wrote: >> On 06/06/2011 07:13 PM, larsh at hjemli.net wrote: >>> * If we want to support reading repo-config from $GITDIR/config, why not >>> implement all the options supported by a $GITDIR/cgitrc? >> >> I'd prefer not doing this (everything in $GITDIR/config). I think it's >> better to have $GITDIR/cgitrc files that hold the repo settings. > > I agree. > > >> There is this setting called repo.path though that then is kind of an >> annoyance to set and update. If we always use $GITDIR/cgitrc files then >> the repo.path setting could be automatically deduced by cgit. > > For repo-specific cgitrc-files, repo.path (and repo.url) are automatically > set (see http://hjemli.net/git/cgit/tree/cgitrc.5.txt#n446). > yeah, but that is dependent on scan-path which I don't use and don't want to use. -- Ferry Huberts From mailings at hupie.com Mon Jun 6 20:23:10 2011 From: mailings at hupie.com (Ferry Huberts) Date: Mon, 06 Jun 2011 20:23:10 +0200 Subject: [PATCH 1/1] commit-links.sh: improve regular expressions In-Reply-To: <20110606172750.GC6957@hjemli.net> References: <1307179260-4984-1-git-send-email-mailings@hupie.com> <20110606172750.GC6957@hjemli.net> Message-ID: <4DED1B0E.7080003@hupie.com> On 06/06/2011 07:27 PM, larsh at hjemli.net wrote: > On Sat, Jun 04, 2011 at 11:21:00AM +0200, Ferry Huberts wrote: >> --- a/filters/commit-links.sh >> +++ b/filters/commit-links.sh >> @@ -15,11 +15,14 @@ >> # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) >> # >> >> +regex='' >> + >> # This expression generates links to commits referenced by their SHA1. >> regex=$regex' >> -s|\b([0-9a-fA-F]{8,40})\b|\1|g' >> +s@(^|\s+)([0-9a-fA-F]{7,40})([^0-9a-fA-F]|$)@\1\2\3 at g' >> + > > Can you explain why explicit prefix/postfix expressions are an improvement > over \b? > >> # This expression generates links to a fictional bugtracker. >> regex=$regex' >> -s| #([0-9]+)\b|#\1|g' >> +s@(^|\s+)#([0-9]+)([^0-9#]|$)@\1#\2\3 at g' > > Ditto. > > -- > larsh I think you're right, will send a new patch in a minute -- Ferry Huberts From jamie.couture at gmail.com Mon Jun 6 20:31:02 2011 From: jamie.couture at gmail.com (Jamie Couture) Date: Mon, 06 Jun 2011 14:31:02 -0400 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <4DED1085.60906@hupie.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> <20110606171344.GB6957@hjemli.net> <4DED1085.60906@hupie.com> Message-ID: <4DED1CE6.9060300@gmail.com> On 11-06-06 01:38 PM, Ferry Huberts wrote: > On 06/06/2011 07:13 PM, larsh at hjemli.net wrote: >> On Fri, Jun 03, 2011 at 07:21:02PM -0400, Jamie Couture wrote: >>> +section-from-repo-config:: >>> + If set to "1" obtain the section name from git config. The expected config >>> + section.key that is used is "cgit.section". >>> + Ex: $ git config cgit.section mysection >>> + An alternative to section-from-path, and will not check git config if >>> + section-from-path is set. See also: scan-path. This must be defined prior >>> + to scan-path. >>> + >> * What value is added by $GITDIR/config compared to $GITDIR/cgitrc? >> * If we want to support reading repo-config from $GITDIR/config, why not >> implement all the options supported by a $GITDIR/cgitrc? >> > I thought about this too. > > It seems attractive but to me is mixing concerns: git and cgit are two > different tools (although closely tied). Having cgit store (part of) its > configuration in git configuration files is not good architecture, > unwise and fragile since it make the cgit configuration directly > dependent on git configuration. cgit can't change it's configuration > format since it has to follow git's and once git changes its format cgit > immediately breaks. The motivation was more about being lazy for those who use scan-path to pick up repositories, and only serves to help the presentation / separation of sections in the front-end, but is by no means easier to maintain. I agree that mixing configuration is clumsy. In my case, I was using gitoilte + cgit. Perhaps I overlooked a feature of gitolite to create repositories based on some path, say: parent/{section1, ..., sectionN}/actual_project.git (the section-from-path feature should have been used in this case). Instead everything is living as children from a common parent, which is how I currently have it setup. > I'd prefer not doing this (everything in $GITDIR/config). I think it's > better to have $GITDIR/cgitrc files that hold the repo settings. > > There is this setting called repo.path though that then is kind of an > annoyance to set and update. If we always use $GITDIR/cgitrc files then > the repo.path setting could be automatically deduced by cgit. > I was trying to do as little touching of cgitrc as possible, with respect to updating / maintaining repository information. Thanks for the consideration; I appreciate the feedback. Jamie Couture From mailings at hupie.com Mon Jun 6 20:34:36 2011 From: mailings at hupie.com (Ferry Huberts) Date: Mon, 6 Jun 2011 20:34:36 +0200 Subject: [PATCH v2 1/1] commit-links.sh: improve regular expressions Message-ID: <1307385276-7264-1-git-send-email-mailings@hupie.com> From: Ferry Huberts Signed-off-by: Ferry Huberts --- filters/commit-links.sh | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/filters/commit-links.sh b/filters/commit-links.sh index d2cd2b3..5881952 100755 --- a/filters/commit-links.sh +++ b/filters/commit-links.sh @@ -15,11 +15,14 @@ # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) # +regex='' + # This expression generates links to commits referenced by their SHA1. regex=$regex' -s|\b([0-9a-fA-F]{8,40})\b|\1|g' +s|\b([0-9a-fA-F]{7,40})\b|\1|g' + # This expression generates links to a fictional bugtracker. regex=$regex' -s| #([0-9]+)\b|#\1|g' +s|#([0-9]+)\b|#\1|g' sed -re "$regex" -- 1.7.5.2 From mailings at hupie.com Mon Jun 6 20:39:34 2011 From: mailings at hupie.com (Ferry Huberts) Date: Mon, 06 Jun 2011 20:39:34 +0200 Subject: [PATCH 2/2] Add feature: obtain repo section from git config In-Reply-To: <4DED1CE6.9060300@gmail.com> References: <1307143262-11018-1-git-send-email-jamie.couture@gmail.com> <1307143262-11018-3-git-send-email-jamie.couture@gmail.com> <20110606171344.GB6957@hjemli.net> <4DED1085.60906@hupie.com> <4DED1CE6.9060300@gmail.com> Message-ID: <4DED1EE6.5030701@hupie.com> On 06/06/2011 08:31 PM, Jamie Couture wrote: > On 11-06-06 01:38 PM, Ferry Huberts wrote: >> On 06/06/2011 07:13 PM, larsh at hjemli.net wrote: >>> On Fri, Jun 03, 2011 at 07:21:02PM -0400, Jamie Couture wrote: >>>> +section-from-repo-config:: >>>> + If set to "1" obtain the section name from git config. The >>>> expected config >>>> + section.key that is used is "cgit.section". >>>> + Ex: $ git config cgit.section mysection >>>> + An alternative to section-from-path, and will not check git >>>> config if >>>> + section-from-path is set. See also: scan-path. This must be >>>> defined prior >>>> + to scan-path. >>>> + >>> * What value is added by $GITDIR/config compared to $GITDIR/cgitrc? >>> * If we want to support reading repo-config from $GITDIR/config, why not >>> implement all the options supported by a $GITDIR/cgitrc? >>> >> I thought about this too. >> >> It seems attractive but to me is mixing concerns: git and cgit are two >> different tools (although closely tied). Having cgit store (part of) its >> configuration in git configuration files is not good architecture, >> unwise and fragile since it make the cgit configuration directly >> dependent on git configuration. cgit can't change it's configuration >> format since it has to follow git's and once git changes its format cgit >> immediately breaks. > The motivation was more about being lazy for those who use scan-path to > pick up repositories, and only serves to help the presentation / > separation of sections in the front-end, but is by no means easier to > maintain. I agree that mixing configuration is clumsy. > > In my case, I was using gitoilte + cgit. Perhaps I overlooked a feature > of gitolite to create repositories based on some path, say: > parent/{section1, ..., sectionN}/actual_project.git (the > section-from-path feature should have been used in this case). Instead > everything is living as children from a common parent, which is how I > currently have it setup. > >> I'd prefer not doing this (everything in $GITDIR/config). I think it's >> better to have $GITDIR/cgitrc files that hold the repo settings. >> >> There is this setting called repo.path though that then is kind of an >> annoyance to set and update. If we always use $GITDIR/cgitrc files then >> the repo.path setting could be automatically deduced by cgit. >> > I was trying to do as little touching of cgitrc as possible, with > respect to updating / maintaining repository information. > You could use something like I do: cgitrc includes a file called 'sections' the sections file includes all separate section files. a separate section file includes all separate repo cgitrc files this makes every include a single line to maintain this allows me to quickly change repos from section without touching the cgitrc. also allows me to quickly change section descriptions without touching cgitrc. and keeps cgit repo config together with the git repo and easy to maintain -- Ferry Huberts From larsh at hjemli.net Tue Jun 7 00:36:44 2011 From: larsh at hjemli.net (larsh at hjemli.net) Date: Mon, 6 Jun 2011 22:36:44 +0000 Subject: [RFC PATCH 1/2] cgit.c: always setup cgit repo environment variables Message-ID: <20110606223644.GA18611@hjemli.net> From: Lars Hjemli When cgit learned to setup environment variables for certain repo settings before invoking a filter process, the setup occurred inside cgit_open_filter(). This patch moves the setup out of cgit_open_filter() and into prepare_repo_cmd() to prepare for additional uses of these variables. Signed-off-by: Lars Hjemli --- cgit.c | 1 + cgit.h | 4 +++- shared.c | 7 +++---- ui-commit.c | 6 +++--- ui-repolist.c | 2 +- ui-snapshot.c | 2 +- ui-summary.c | 2 +- ui-tree.c | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cgit.c b/cgit.c index 6be3754..dd40893 100644 --- a/cgit.c +++ b/cgit.c @@ -463,6 +463,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx) cgit_print_docend(); return 1; } + cgit_prepare_repo_env(ctx->repo); return 0; } diff --git a/cgit.h b/cgit.h index caa9d8e..df7ee5d 100644 --- a/cgit.h +++ b/cgit.h @@ -319,9 +319,11 @@ extern const char *cgit_repobasename(const char *reponame); extern int cgit_parse_snapshots_mask(const char *str); -extern int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo); +extern int cgit_open_filter(struct cgit_filter *filter); extern int cgit_close_filter(struct cgit_filter *filter); +extern void cgit_prepare_repo_env(struct cgit_repo * repo); + extern int readfile(const char *path, char **buf, size_t *size); extern char *expand_macros(const char *txt); diff --git a/shared.c b/shared.c index be2ae59..4adeaa8 100644 --- a/shared.c +++ b/shared.c @@ -374,7 +374,8 @@ typedef struct { char * value; } cgit_env_var; -static void prepare_env(struct cgit_repo * repo) { +void cgit_prepare_repo_env(struct cgit_repo * repo) +{ cgit_env_var env_vars[] = { { .name = "CGIT_REPO_URL", .value = repo->url }, { .name = "CGIT_REPO_NAME", .value = repo->name }, @@ -395,7 +396,7 @@ static void prepare_env(struct cgit_repo * repo) { fprintf(stderr, warn, p->name, p->value); } -int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo) +int cgit_open_filter(struct cgit_filter *filter) { filter->old_stdout = chk_positive(dup(STDOUT_FILENO), @@ -406,8 +407,6 @@ int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo) close(filter->pipe_fh[1]); chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO), "Unable to use pipe as STDIN"); - if (repo) - prepare_env(repo); execvp(filter->cmd, filter->argv); die("Unable to exec subprocess %s: %s (%d)", filter->cmd, strerror(errno), errno); diff --git a/ui-commit.c b/ui-commit.c index a69dec6..536a8e8 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -106,7 +106,7 @@ void cgit_print_commit(char *hex, const char *prefix) html("\n"); html("
"); if (ctx.repo->commit_filter) - cgit_open_filter(ctx.repo->commit_filter, ctx.repo); + cgit_open_filter(ctx.repo->commit_filter); html_txt(info->subject); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); @@ -114,7 +114,7 @@ void cgit_print_commit(char *hex, const char *prefix) html("
"); html("
"); if (ctx.repo->commit_filter) - cgit_open_filter(ctx.repo->commit_filter, ctx.repo); + cgit_open_filter(ctx.repo->commit_filter); html_txt(info->msg); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); @@ -123,7 +123,7 @@ void cgit_print_commit(char *hex, const char *prefix) html("
Notes
"); html("
"); if (ctx.repo->commit_filter) - cgit_open_filter(ctx.repo->commit_filter, ctx.repo); + cgit_open_filter(ctx.repo->commit_filter); html_txt(notes.buf); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); diff --git a/ui-repolist.c b/ui-repolist.c index dce2eac..25c36ce 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -300,7 +300,7 @@ void cgit_print_site_readme() if (!ctx.cfg.root_readme) return; if (ctx.cfg.about_filter) - cgit_open_filter(ctx.cfg.about_filter, NULL); + cgit_open_filter(ctx.cfg.about_filter); html_include(ctx.cfg.root_readme); if (ctx.cfg.about_filter) cgit_close_filter(ctx.cfg.about_filter); diff --git a/ui-snapshot.c b/ui-snapshot.c index 126779d..07cc944 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -19,7 +19,7 @@ static int write_compressed_tar_archive(struct archiver_args *args,const char *f f.argv = malloc(2 * sizeof(char *)); f.argv[0] = f.cmd; f.argv[1] = NULL; - cgit_open_filter(&f, NULL); + cgit_open_filter(&f); rv = write_tar_archive(args); cgit_close_filter(&f); return rv; diff --git a/ui-summary.c b/ui-summary.c index 1e9a1b6..5be2545 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -113,7 +113,7 @@ void cgit_print_repo_readme(char *path) */ html("
"); if (ctx.repo->about_filter) - cgit_open_filter(ctx.repo->about_filter, ctx.repo); + cgit_open_filter(ctx.repo->about_filter); if (ref) cgit_print_file(tmp, ref); else diff --git a/ui-tree.c b/ui-tree.c index 2d8d2f3..442b6be 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -45,7 +45,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) if (ctx.repo->source_filter) { html("
");
 		ctx.repo->source_filter->argv[1] = xstrdup(name);
-		cgit_open_filter(ctx.repo->source_filter, ctx.repo);
+		cgit_open_filter(ctx.repo->source_filter);
 		html_raw(buf, size);
 		cgit_close_filter(ctx.repo->source_filter);
 		free(ctx.repo->source_filter->argv[1]);
-- 
1.7.1




From larsh at hjemli.net  Tue Jun  7 00:37:23 2011
From: larsh at hjemli.net (larsh at hjemli.net)
Date: Mon, 6 Jun 2011 22:37:23 +0000
Subject: [RFC PATCH 2/2] cgit.c: add 'clone-url' setting with support for
 macro expansion
Message-ID: <20110606223723.GA18638@hjemli.net>

From: Lars Hjemli 

The current 'clone-prefix' setting has some known issues:
* All repos get the same 'clone-prefix' value since the setting is not
  adopted during repo registration (in cgitrc, or during scan-path traversal),
  but only when the setting is used.
* The generated clone-urls for a repo is a combination of 'clone-prefix', a
  slash and the repo url. This doesn't work well with e.g. ssh-style urls
  like 'git at example.org:repo.git', since the inserted slash will make the
  repo relative to the filesystem root.
* If 'remove-suffix' is enabled, the generated clone-urls will not work for
  cloning (except for http-urls to cgit itself) since they miss the '.git'
  suffix.

The new 'clone-url' setting is designed to avoid the mentioned issues:
* Each repo adopts the default 'clone-url' when the repo is defined. This
  allows different groups of repos to adopt different values.
* The clone-urls for a repo is generated by expanding environment variables
  in a string template without inserting arbitrary characters, hence any
  kind of clone-url can be generated.
* Macro expansion also eases the 'remove-suffix' pain since it's now
  possible to define e.g. 'clone-url=git://foo.org/$CGIT_REPO_URL.git' for
  a set of repos. A furter improvement would be to define e.g.
  $CGIT_REPO_SUFFIX to '.git' for all repos which had their url prettified,
  or to store the original $CGIT_REPO_URL in e.g. $CGIT_REPO_REAL_URL before
  suffix removal.

While at it, cgitrc.5 is expanded with a section describing the (previously
undocumented) macro expansion feature.

Signed-off-by: Lars Hjemli 
---
 cgit.c                 |    2 ++
 cgit.h                 |    1 +
 cgitrc.5.txt           |   32 ++++++++++++++++++++++++++++++--
 shared.c               |    1 +
 tests/setup.sh         |    1 +
 tests/t0102-summary.sh |    6 ++++++
 ui-summary.c           |    2 +-
 7 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/cgit.c b/cgit.c
index dd40893..51ca78a 100644
--- a/cgit.c
+++ b/cgit.c
@@ -244,6 +244,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.robots = xstrdup(value);
 	else if (!strcmp(name, "clone-prefix"))
 		ctx.cfg.clone_prefix = xstrdup(value);
+	else if (!strcmp(name, "clone-url"))
+		ctx.cfg.clone_url = xstrdup(value);
 	else if (!strcmp(name, "local-time"))
 		ctx.cfg.local_time = atoi(value);
 	else if (!prefixcmp(name, "mimetype."))
diff --git a/cgit.h b/cgit.h
index df7ee5d..bad66f0 100644
--- a/cgit.h
+++ b/cgit.h
@@ -165,6 +165,7 @@ struct cgit_config {
 	char *agefile;
 	char *cache_root;
 	char *clone_prefix;
+	char *clone_url;
 	char *css;
 	char *favicon;
 	char *footer;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 5903a93..c2d2fad 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -76,6 +76,11 @@ clone-prefix::
 	setting is only used if `repo.clone-url` is unspecified. Default value:
 	none.
 
+clone-url::
+	Space-separated list of clone-url templates. This setting is only
+	used if `repo.clone-url` is unspecified. Default value: none. See
+	also: "MACRO EXPANSION", "FILTER API".
+
 commit-filter::
 	Specifies a command which will be invoked to format commit messages.
 	The command will get the message on its STDIN, and the STDOUT from the
@@ -492,6 +497,29 @@ allocated buffer within cgit then only the environment variables that fit
 in the allocated buffer are handed to the filter.
 
 
+MACRO EXPANSION
+---------------
+Certain cgitrc settings supports a simple macro expansion feature, where
+tokens prefixed with '$' are replaced with the value of the environment
+variable named by the token[*]. The settings which supports this feature are
+divided in two groups:
+
+* Settings expanded prior to request processing. These settings are typically
+used to implement virtual hosting based on environment variables set by the
+web-server (e.g. HTTP_HOST):
+  - CGIT_CONFIG (not really a cgitrc setting...)
+  - cache-root
+  - project-list
+  - scan-path
+  - include
+* Settings expanded during request processing. These settings will typically
+also support the environment variables defined in "FILTER API":
+  - clone-url
+  - repo.clone-url
+
+[*] A token is a sequence of alphanumeric characters and underscores.
+
+
 EXAMPLE CGITRC FILE
 -------------------
 
@@ -500,8 +528,8 @@ EXAMPLE CGITRC FILE
 cache-size=1000
 
 
-# Specify some default clone prefixes
-clone-prefix=git://example.com ssh://example.com/pub/git http://example.com/git
+# Specify some default clone urls using macro expansion
+clone-url=git://example.com/$CGIT_REPO_URL.git ssh://example.com/pub/git/$CGIT_REPO_URL.git
 
 # Specify the css url
 css=/css/cgit.css
diff --git a/shared.c b/shared.c
index 4adeaa8..699c362 100644
--- a/shared.c
+++ b/shared.c
@@ -70,6 +70,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
 	ret->about_filter = ctx.cfg.about_filter;
 	ret->commit_filter = ctx.cfg.commit_filter;
 	ret->source_filter = ctx.cfg.source_filter;
+	ret->clone_url = ctx.cfg.clone_url;
 	return ret;
 }
 
diff --git a/tests/setup.sh b/tests/setup.sh
index b2f1169..1e06107 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -62,6 +62,7 @@ enable-log-linecount=1
 summary-log=5
 summary-branches=5
 summary-tags=5
+clone-url=git://example.org/\$CGIT_REPO_URL.git
 
 repo.url=foo
 repo.path=$PWD/trash/repos/foo/.git
diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
index f0b0d9a..f299c5a 100755
--- a/tests/t0102-summary.sh
+++ b/tests/t0102-summary.sh
@@ -9,6 +9,9 @@ run_test 'find commit 1' 'grep -e "commit 1" trash/tmp'
 run_test 'find commit 5' 'grep -e "commit 5" trash/tmp'
 run_test 'find branch master' 'grep -e "master" trash/tmp'
 run_test 'no tags' '! grep -e "tags" trash/tmp'
+run_test 'clone-url expanded correctly' '
+	grep -e "git://example.org/foo.git" trash/tmp
+'
 
 run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp'
 run_test 'no commit 45' '! grep -e "commit 45" trash/tmp'
@@ -16,5 +19,8 @@ run_test 'find commit 46' 'grep -e "commit 46" trash/tmp'
 run_test 'find commit 50' 'grep -e "commit 50" trash/tmp'
 run_test 'find branch master' 'grep -e "master" trash/tmp'
 run_test 'no tags' '! grep -e "tags" trash/tmp'
+run_test 'clone-url expanded correctly' '
+	grep -e "git://example.org/bar.git" trash/tmp
+'
 
 tests_done
diff --git a/ui-summary.c b/ui-summary.c
index 5be2545..227ed27 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -62,7 +62,7 @@ void cgit_print_summary()
 			       NULL, NULL, 0, 0);
 	}
 	if (ctx.repo->clone_url)
-		print_urls(ctx.repo->clone_url, NULL);
+		print_urls(expand_macros(ctx.repo->clone_url), NULL);
 	else if (ctx.cfg.clone_prefix)
 		print_urls(ctx.cfg.clone_prefix, ctx.repo->url);
 	html("");
-- 
1.7.1




From mailings at hupie.com  Tue Jun  7 17:45:56 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Tue, 07 Jun 2011 17:45:56 +0200
Subject: [RFC PATCH 2/2] cgit.c: add 'clone-url' setting with support
 for	macro expansion
In-Reply-To: <20110606223723.GA18638@hjemli.net>
References: <20110606223723.GA18638@hjemli.net>
Message-ID: <4DEE47B4.5030209@hupie.com>

On 06/07/2011 12:37 AM, larsh at hjemli.net wrote:
> From: Lars Hjemli 
> 
> The current 'clone-prefix' setting has some known issues:
> * All repos get the same 'clone-prefix' value since the setting is not
>   adopted during repo registration (in cgitrc, or during scan-path traversal),
>   but only when the setting is used.
> * The generated clone-urls for a repo is a combination of 'clone-prefix', a
>   slash and the repo url. This doesn't work well with e.g. ssh-style urls
>   like 'git at example.org:repo.git', since the inserted slash will make the
>   repo relative to the filesystem root.
> * If 'remove-suffix' is enabled, the generated clone-urls will not work for
>   cloning (except for http-urls to cgit itself) since they miss the '.git'
>   suffix.
> 
> The new 'clone-url' setting is designed to avoid the mentioned issues:
> * Each repo adopts the default 'clone-url' when the repo is defined. This
>   allows different groups of repos to adopt different values.
> * The clone-urls for a repo is generated by expanding environment variables
>   in a string template without inserting arbitrary characters, hence any
>   kind of clone-url can be generated.
> * Macro expansion also eases the 'remove-suffix' pain since it's now
>   possible to define e.g. 'clone-url=git://foo.org/$CGIT_REPO_URL.git' for
>   a set of repos. A furter improvement would be to define e.g.
>   $CGIT_REPO_SUFFIX to '.git' for all repos which had their url prettified,

I think this is a good idea

>   or to store the original $CGIT_REPO_URL in e.g. $CGIT_REPO_REAL_URL before
>   suffix removal.

I prefer this less

> 
> While at it, cgitrc.5 is expanded with a section describing the (previously
> undocumented) macro expansion feature.
> 
> Signed-off-by: Lars Hjemli 
> ---
>  cgit.c                 |    2 ++
>  cgit.h                 |    1 +
>  cgitrc.5.txt           |   32 ++++++++++++++++++++++++++++++--
>  shared.c               |    1 +
>  tests/setup.sh         |    1 +
>  tests/t0102-summary.sh |    6 ++++++
>  ui-summary.c           |    2 +-
>  7 files changed, 42 insertions(+), 3 deletions(-)
> 
> diff --git a/cgit.c b/cgit.c
> index dd40893..51ca78a 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -244,6 +244,8 @@ void config_cb(const char *name, const char *value)
>  		ctx.cfg.robots = xstrdup(value);
>  	else if (!strcmp(name, "clone-prefix"))
>  		ctx.cfg.clone_prefix = xstrdup(value);
> +	else if (!strcmp(name, "clone-url"))
> +		ctx.cfg.clone_url = xstrdup(value);
>  	else if (!strcmp(name, "local-time"))
>  		ctx.cfg.local_time = atoi(value);
>  	else if (!prefixcmp(name, "mimetype."))
> diff --git a/cgit.h b/cgit.h
> index df7ee5d..bad66f0 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -165,6 +165,7 @@ struct cgit_config {
>  	char *agefile;
>  	char *cache_root;
>  	char *clone_prefix;
> +	char *clone_url;
>  	char *css;
>  	char *favicon;
>  	char *footer;
> diff --git a/cgitrc.5.txt b/cgitrc.5.txt
> index 5903a93..c2d2fad 100644
> --- a/cgitrc.5.txt
> +++ b/cgitrc.5.txt
> @@ -76,6 +76,11 @@ clone-prefix::
>  	setting is only used if `repo.clone-url` is unspecified. Default value:
>  	none.
>  
> +clone-url::
> +	Space-separated list of clone-url templates. This setting is only
> +	used if `repo.clone-url` is unspecified. Default value: none. See
> +	also: "MACRO EXPANSION", "FILTER API".
> +
>  commit-filter::
>  	Specifies a command which will be invoked to format commit messages.
>  	The command will get the message on its STDIN, and the STDOUT from the
> @@ -492,6 +497,29 @@ allocated buffer within cgit then only the environment variables that fit
>  in the allocated buffer are handed to the filter.
>  
>  
> +MACRO EXPANSION
> +---------------
> +Certain cgitrc settings supports a simple macro expansion feature, where
> +tokens prefixed with '$' are replaced with the value of the environment
> +variable named by the token[*]. The settings which supports this feature are
> +divided in two groups:
> +
> +* Settings expanded prior to request processing. These settings are typically

better use a '-' here, a '*' could be confusing with the [*] above

> +used to implement virtual hosting based on environment variables set by the
> +web-server (e.g. HTTP_HOST):

so using $HTTP_HOST will be expanded? that would be awesome!

> +  - CGIT_CONFIG (not really a cgitrc setting...)
> +  - cache-root
> +  - project-list
> +  - scan-path
> +  - include
> +* Settings expanded during request processing. These settings will typically

ditto

> +also support the environment variables defined in "FILTER API":
> +  - clone-url
> +  - repo.clone-url
> +
> +[*] A token is a sequence of alphanumeric characters and underscores.
> +
> +
>  EXAMPLE CGITRC FILE
>  -------------------
>  
> @@ -500,8 +528,8 @@ EXAMPLE CGITRC FILE
>  cache-size=1000
>  
>  
> -# Specify some default clone prefixes
> -clone-prefix=git://example.com ssh://example.com/pub/git http://example.com/git
> +# Specify some default clone urls using macro expansion
> +clone-url=git://example.com/$CGIT_REPO_URL.git ssh://example.com/pub/git/$CGIT_REPO_URL.git
>  
>  # Specify the css url
>  css=/css/cgit.css
> diff --git a/shared.c b/shared.c
> index 4adeaa8..699c362 100644
> --- a/shared.c
> +++ b/shared.c
> @@ -70,6 +70,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
>  	ret->about_filter = ctx.cfg.about_filter;
>  	ret->commit_filter = ctx.cfg.commit_filter;
>  	ret->source_filter = ctx.cfg.source_filter;
> +	ret->clone_url = ctx.cfg.clone_url;
>  	return ret;
>  }
>  
> diff --git a/tests/setup.sh b/tests/setup.sh
> index b2f1169..1e06107 100755
> --- a/tests/setup.sh
> +++ b/tests/setup.sh
> @@ -62,6 +62,7 @@ enable-log-linecount=1
>  summary-log=5
>  summary-branches=5
>  summary-tags=5
> +clone-url=git://example.org/\$CGIT_REPO_URL.git
>  
>  repo.url=foo
>  repo.path=$PWD/trash/repos/foo/.git
> diff --git a/tests/t0102-summary.sh b/tests/t0102-summary.sh
> index f0b0d9a..f299c5a 100755
> --- a/tests/t0102-summary.sh
> +++ b/tests/t0102-summary.sh
> @@ -9,6 +9,9 @@ run_test 'find commit 1' 'grep -e "commit 1" trash/tmp'
>  run_test 'find commit 5' 'grep -e "commit 5" trash/tmp'
>  run_test 'find branch master' 'grep -e "master" trash/tmp'
>  run_test 'no tags' '! grep -e "tags" trash/tmp'
> +run_test 'clone-url expanded correctly' '
> +	grep -e "git://example.org/foo.git" trash/tmp
> +'
>  
>  run_test 'generate bar summary' 'cgit_url "bar" >trash/tmp'
>  run_test 'no commit 45' '! grep -e "commit 45" trash/tmp'
> @@ -16,5 +19,8 @@ run_test 'find commit 46' 'grep -e "commit 46" trash/tmp'
>  run_test 'find commit 50' 'grep -e "commit 50" trash/tmp'
>  run_test 'find branch master' 'grep -e "master" trash/tmp'
>  run_test 'no tags' '! grep -e "tags" trash/tmp'
> +run_test 'clone-url expanded correctly' '
> +	grep -e "git://example.org/bar.git" trash/tmp
> +'
>  
>  tests_done
> diff --git a/ui-summary.c b/ui-summary.c
> index 5be2545..227ed27 100644
> --- a/ui-summary.c
> +++ b/ui-summary.c
> @@ -62,7 +62,7 @@ void cgit_print_summary()
>  			       NULL, NULL, 0, 0);
>  	}
>  	if (ctx.repo->clone_url)
> -		print_urls(ctx.repo->clone_url, NULL);
> +		print_urls(expand_macros(ctx.repo->clone_url), NULL);
>  	else if (ctx.cfg.clone_prefix)
>  		print_urls(ctx.cfg.clone_prefix, ctx.repo->url);
>  	html("");

Reviewed-by: Ferry Huberts 


Awesome work Lars!
Thanks!
-- 
Ferry Huberts



From mailings at hupie.com  Tue Jun  7 17:46:07 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Tue, 07 Jun 2011 17:46:07 +0200
Subject: [RFC PATCH 1/2] cgit.c: always setup cgit repo environment
 variables
In-Reply-To: <20110606223644.GA18611@hjemli.net>
References: <20110606223644.GA18611@hjemli.net>
Message-ID: <4DEE47BF.1050907@hupie.com>

On 06/07/2011 12:36 AM, larsh at hjemli.net wrote:
> From: Lars Hjemli 
> 
> When cgit learned to setup environment variables for certain repo
> settings before invoking a filter process, the setup occurred inside
> cgit_open_filter().
> 
> This patch moves the setup out of cgit_open_filter() and into
> prepare_repo_cmd() to prepare for additional uses of these variables.
> 
> Signed-off-by: Lars Hjemli 
> ---
>  cgit.c        |    1 +
>  cgit.h        |    4 +++-
>  shared.c      |    7 +++----
>  ui-commit.c   |    6 +++---
>  ui-repolist.c |    2 +-
>  ui-snapshot.c |    2 +-
>  ui-summary.c  |    2 +-
>  ui-tree.c     |    2 +-
>  8 files changed, 14 insertions(+), 12 deletions(-)
> 
> diff --git a/cgit.c b/cgit.c
> index 6be3754..dd40893 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -463,6 +463,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
>  		cgit_print_docend();
>  		return 1;
>  	}
> +	cgit_prepare_repo_env(ctx->repo);
>  	return 0;
>  }
>  
> diff --git a/cgit.h b/cgit.h
> index caa9d8e..df7ee5d 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -319,9 +319,11 @@ extern const char *cgit_repobasename(const char *reponame);
>  
>  extern int cgit_parse_snapshots_mask(const char *str);
>  
> -extern int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo);
> +extern int cgit_open_filter(struct cgit_filter *filter);
>  extern int cgit_close_filter(struct cgit_filter *filter);
>  
> +extern void cgit_prepare_repo_env(struct cgit_repo * repo);
> +
>  extern int readfile(const char *path, char **buf, size_t *size);
>  
>  extern char *expand_macros(const char *txt);
> diff --git a/shared.c b/shared.c
> index be2ae59..4adeaa8 100644
> --- a/shared.c
> +++ b/shared.c
> @@ -374,7 +374,8 @@ typedef struct {
>  	char * value;
>  } cgit_env_var;
>  
> -static void prepare_env(struct cgit_repo * repo) {
> +void cgit_prepare_repo_env(struct cgit_repo * repo)
> +{
>  	cgit_env_var env_vars[] = {
>  		{ .name = "CGIT_REPO_URL", .value = repo->url },
>  		{ .name = "CGIT_REPO_NAME", .value = repo->name },
> @@ -395,7 +396,7 @@ static void prepare_env(struct cgit_repo * repo) {
>  			fprintf(stderr, warn, p->name, p->value);
>  }
>  
> -int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo)
> +int cgit_open_filter(struct cgit_filter *filter)
>  {
>  
>  	filter->old_stdout = chk_positive(dup(STDOUT_FILENO),
> @@ -406,8 +407,6 @@ int cgit_open_filter(struct cgit_filter *filter, struct cgit_repo * repo)
>  		close(filter->pipe_fh[1]);
>  		chk_non_negative(dup2(filter->pipe_fh[0], STDIN_FILENO),
>  			"Unable to use pipe as STDIN");
> -		if (repo)
> -			prepare_env(repo);
>  		execvp(filter->cmd, filter->argv);
>  		die("Unable to exec subprocess %s: %s (%d)", filter->cmd,
>  			strerror(errno), errno);
> diff --git a/ui-commit.c b/ui-commit.c
> index a69dec6..536a8e8 100644
> --- a/ui-commit.c
> +++ b/ui-commit.c
> @@ -106,7 +106,7 @@ void cgit_print_commit(char *hex, const char *prefix)
>  	html("\n");
>  	html("
"); > if (ctx.repo->commit_filter) > - cgit_open_filter(ctx.repo->commit_filter, ctx.repo); > + cgit_open_filter(ctx.repo->commit_filter); > html_txt(info->subject); > if (ctx.repo->commit_filter) > cgit_close_filter(ctx.repo->commit_filter); > @@ -114,7 +114,7 @@ void cgit_print_commit(char *hex, const char *prefix) > html("
"); > html("
"); > if (ctx.repo->commit_filter) > - cgit_open_filter(ctx.repo->commit_filter, ctx.repo); > + cgit_open_filter(ctx.repo->commit_filter); > html_txt(info->msg); > if (ctx.repo->commit_filter) > cgit_close_filter(ctx.repo->commit_filter); > @@ -123,7 +123,7 @@ void cgit_print_commit(char *hex, const char *prefix) > html("
Notes
"); > html("
"); > if (ctx.repo->commit_filter) > - cgit_open_filter(ctx.repo->commit_filter, ctx.repo); > + cgit_open_filter(ctx.repo->commit_filter); > html_txt(notes.buf); > if (ctx.repo->commit_filter) > cgit_close_filter(ctx.repo->commit_filter); > diff --git a/ui-repolist.c b/ui-repolist.c > index dce2eac..25c36ce 100644 > --- a/ui-repolist.c > +++ b/ui-repolist.c > @@ -300,7 +300,7 @@ void cgit_print_site_readme() > if (!ctx.cfg.root_readme) > return; > if (ctx.cfg.about_filter) > - cgit_open_filter(ctx.cfg.about_filter, NULL); > + cgit_open_filter(ctx.cfg.about_filter); > html_include(ctx.cfg.root_readme); > if (ctx.cfg.about_filter) > cgit_close_filter(ctx.cfg.about_filter); > diff --git a/ui-snapshot.c b/ui-snapshot.c > index 126779d..07cc944 100644 > --- a/ui-snapshot.c > +++ b/ui-snapshot.c > @@ -19,7 +19,7 @@ static int write_compressed_tar_archive(struct archiver_args *args,const char *f > f.argv = malloc(2 * sizeof(char *)); > f.argv[0] = f.cmd; > f.argv[1] = NULL; > - cgit_open_filter(&f, NULL); > + cgit_open_filter(&f); > rv = write_tar_archive(args); > cgit_close_filter(&f); > return rv; > diff --git a/ui-summary.c b/ui-summary.c > index 1e9a1b6..5be2545 100644 > --- a/ui-summary.c > +++ b/ui-summary.c > @@ -113,7 +113,7 @@ void cgit_print_repo_readme(char *path) > */ > html("
"); > if (ctx.repo->about_filter) > - cgit_open_filter(ctx.repo->about_filter, ctx.repo); > + cgit_open_filter(ctx.repo->about_filter); > if (ref) > cgit_print_file(tmp, ref); > else > diff --git a/ui-tree.c b/ui-tree.c > index 2d8d2f3..442b6be 100644 > --- a/ui-tree.c > +++ b/ui-tree.c > @@ -45,7 +45,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) > if (ctx.repo->source_filter) { > html("
");
>  		ctx.repo->source_filter->argv[1] = xstrdup(name);
> -		cgit_open_filter(ctx.repo->source_filter, ctx.repo);
> +		cgit_open_filter(ctx.repo->source_filter);
>  		html_raw(buf, size);
>  		cgit_close_filter(ctx.repo->source_filter);
>  		free(ctx.repo->source_filter->argv[1]);

Reviewed-by: Ferry Huberts 

-- 
Ferry Huberts



From larsh at hjemli.net  Tue Jun  7 18:14:38 2011
From: larsh at hjemli.net (larsh at hjemli.net)
Date: Tue, 7 Jun 2011 16:14:38 +0000
Subject: [RFC PATCH 2/2] cgit.c: add 'clone-url' setting with support for
 macro expansion
In-Reply-To: <4DEE47B4.5030209@hupie.com>
References: <20110606223723.GA18638@hjemli.net> <4DEE47B4.5030209@hupie.com>
Message-ID: <20110607161438.GA766@hjemli.net>

On Tue, Jun 07, 2011 at 05:45:56PM +0200, Ferry Huberts wrote:
> On 06/07/2011 12:37 AM, larsh at hjemli.net wrote:
> > From: Lars Hjemli 
> > * Macro expansion also eases the 'remove-suffix' pain since it's now
> >   possible to define e.g. 'clone-url=git://foo.org/$CGIT_REPO_URL.git' for
> >   a set of repos. A furter improvement would be to define e.g.
> >   $CGIT_REPO_SUFFIX to '.git' for all repos which had their url prettified,
> 
> I think this is a good idea
> 
> >   or to store the original $CGIT_REPO_URL in e.g. $CGIT_REPO_REAL_URL before
> >   suffix removal.
> 
> I prefer this less

I tend to agree.


> > +MACRO EXPANSION
> > +---------------
> > +Certain cgitrc settings supports a simple macro expansion feature, where
> > +tokens prefixed with '$' are replaced with the value of the environment
> > +variable named by the token[*]. The settings which supports this feature are
> > +divided in two groups:
> > +
> > +* Settings expanded prior to request processing. These settings are typically
> 
> better use a '-' here, a '*' could be confusing with the [*] above

Good eyes.

 
> > +used to implement virtual hosting based on environment variables set by the
> > +web-server (e.g. HTTP_HOST):
> 
> so using $HTTP_HOST will be expanded? that would be awesome!

Yes, this has been supported (but not documented) in master since
5c5d1896 (july 2010).


> Reviewed-by: Ferry Huberts 

Thanks.

--
larsh



From mailings at hupie.com  Wed Jun  8 20:51:31 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 08 Jun 2011 20:51:31 +0200
Subject: [RFC PATCH 2/2] cgit.c: add 'clone-url' setting with support
 for macro expansion
In-Reply-To: <20110607161438.GA766@hjemli.net>
References: <20110606223723.GA18638@hjemli.net> <4DEE47B4.5030209@hupie.com>
 <20110607161438.GA766@hjemli.net>
Message-ID: <4DEFC4B3.1050004@hupie.com>

Lars,

I think you'd also want to update cgitrc.5.txt... :-)

On 06/07/2011 06:14 PM, larsh at hjemli.net wrote:
> On Tue, Jun 07, 2011 at 05:45:56PM +0200, Ferry Huberts wrote:
>> On 06/07/2011 12:37 AM, larsh at hjemli.net wrote:
>>> From: Lars Hjemli 
>>> * Macro expansion also eases the 'remove-suffix' pain since it's now
>>>   possible to define e.g. 'clone-url=git://foo.org/$CGIT_REPO_URL.git' for
>>>   a set of repos. A furter improvement would be to define e.g.
>>>   $CGIT_REPO_SUFFIX to '.git' for all repos which had their url prettified,
>>
>> I think this is a good idea
>>
>>>   or to store the original $CGIT_REPO_URL in e.g. $CGIT_REPO_REAL_URL before
>>>   suffix removal.
>>
>> I prefer this less
> 
> I tend to agree.
> 
> 
>>> +MACRO EXPANSION
>>> +---------------
>>> +Certain cgitrc settings supports a simple macro expansion feature, where
>>> +tokens prefixed with '$' are replaced with the value of the environment
>>> +variable named by the token[*]. The settings which supports this feature are
>>> +divided in two groups:
>>> +
>>> +* Settings expanded prior to request processing. These settings are typically
>>
>> better use a '-' here, a '*' could be confusing with the [*] above
> 
> Good eyes.
> 
>  
>>> +used to implement virtual hosting based on environment variables set by the
>>> +web-server (e.g. HTTP_HOST):
>>
>> so using $HTTP_HOST will be expanded? that would be awesome!
> 
> Yes, this has been supported (but not documented) in master since
> 5c5d1896 (july 2010).
> 
> 
>> Reviewed-by: Ferry Huberts 
> 
> Thanks.
> 
> --
> larsh

grtz

-- 
Ferry Huberts



From jugg at hotmail.com  Thu Jun  9 06:40:20 2011
From: jugg at hotmail.com (chris)
Date: Thu, 9 Jun 2011 04:40:20 +0000 (UTC)
Subject: [PATCH v2] guess default branch from HEAD
References: 
 <1301500806-25622-1-git-send-email-plenz@cis.fu-berlin.de>
 
 <20110407104958.GB1004@plenz.com>
 
Message-ID: 

Will this patch be integrated at some point?  Is there anything holding it up?

Thanks,

chris





From naptravel at emark.embluejet.com  Thu Jun  9 20:10:04 2011
From: naptravel at emark.embluejet.com (Nap Travel)
Date: Thu,  9 Jun 2011 15:10:04 -0300 (ART)
Subject: Pasajes aereos en Business
Message-ID: <20110609181004.312E74C389@emark2>

Pasajes aereos en Business


From jugg at hotmail.com  Fri Jun 10 08:42:51 2011
From: jugg at hotmail.com (chris)
Date: Fri, 10 Jun 2011 06:42:51 +0000 (UTC)
Subject: [PATCH] guess default branch from HEAD
References: <20110407104958.GB1004@plenz.com>
 <1302173964-12520-1-git-send-email-plenz@cis.fu-berlin.de>
Message-ID: 

Julius Plenz  writes:
> 
> This is a saner alternative than hardcoding the default branch to be
> "master". The add_repo() function will now check for a symbolic ref in
> repo_path/HEAD. If there is a suitable one, overwrite repo->defbranch
> with it. Note that you'll need to strip the newline from the file (->
> len-17).
> 
> If HEAD is a symbolic link pointing directly to a branch below
> refs/heads/, do a readlink() instead to find the ref name.
> 
> Signed-off-by: Julius Plenz 

I've successfully applied this patch against the current stable branch (commit: 
2a8f5531) and deployed the resulting binary without trouble.  The functionality 
appears to work as advertised.  So, along with setting the default 'readme'
value as:

readme=HEAD:README.md

each project is able to have a sensible default presentation based off of the 
project's default branch.  Very useful as we use gitolite to manage our 
repositories, this saves us further manual configuration outside of gitolite.

I hope this patch can be integrated into the official release.

chris





From hjemli at gmail.com  Sun Jun 12 23:34:40 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Sun, 12 Jun 2011 23:34:40 +0200
Subject: [cgit] Trouble with plain visualizing
In-Reply-To: <1307895150.5899.14.camel@Charon>
References: <1307895150.5899.14.camel@Charon>
Message-ID: 

[Added cgit mailing list to CC]

On Sun, Jun 12, 2011 at 18:12, Karsten Schulz
 wrote:
> I like your implementation of a webinterface for git. But i have a
> trouble with the plain visualizing of the source tree.
>
> At first pls click of the following link:
> http://lenny-linux.dlinkddns.com/cgit/Streetplaner/src.git/tree/src/org/streetplaner
> if you click on any plain visualizing and than on an Java-File you'll
> see the link is wrong.
> For example you click on "math":
> the link-output shows like:
> http://lenny-linux.dlinkddns.com/cgit/Streetplaner/src.git/plain/src/org/streetplaner/math
> And if you now click on any Java-File, "math" will replaced with your
> choose and the webinterface can't find this file.
> For example Line.java the link-output shows:
> http://lenny-linux.dlinkddns.com/cgit/Streetplaner/src.git/plain/src/org/streetplaner/Line.java
>
> Does it a trouble of cgit or configuration of anyone?

This is a bug, which I've now deployed a fix for in my stable and
master branches on hjemli.net/git/cgit.

Mark: my patch conflicts with the work you've put into ui-plain.c
(which has been lingering in the wip branch), but I think it needed to
be done, and I've been considering dropping the patches regarding
symbolic link following in plain view (I think cgit should display the
content of the symbolic link). Opinions?

--
larsh



From larsh at hjemli.net  Mon Jun 13 12:16:22 2011
From: larsh at hjemli.net (larsh at hjemli.net)
Date: Mon, 13 Jun 2011 10:16:22 +0000
Subject: [PATCH] guess default branch from HEAD
In-Reply-To: 
References: <20110407104958.GB1004@plenz.com>
 <1302173964-12520-1-git-send-email-plenz@cis.fu-berlin.de>
 
Message-ID: <20110613101621.GA29265@hjemli.net>

On Fri, Jun 10, 2011 at 06:42:51AM +0000, chris wrote:
> Julius Plenz  writes:
> > 
> > This is a saner alternative than hardcoding the default branch to be
> > "master". The add_repo() function will now check for a symbolic ref in
> > repo_path/HEAD. If there is a suitable one, overwrite repo->defbranch
> > with it. Note that you'll need to strip the newline from the file (->
> > len-17).
> > 
> > If HEAD is a symbolic link pointing directly to a branch below
> > refs/heads/, do a readlink() instead to find the ref name.
> > 
> > Signed-off-by: Julius Plenz 
> 
> I've successfully applied this patch against the current stable branch (commit: 
> 2a8f5531) and deployed the resulting binary without trouble.  The functionality 
> appears to work as advertised.  So, along with setting the default 'readme'
> value as:
> 
> readme=HEAD:README.md
> 
> each project is able to have a sensible default presentation based off of the 
> project's default branch.  Very useful as we use gitolite to manage our 
> repositories, this saves us further manual configuration outside of gitolite.
> 

Thanks for testing.

> I hope this patch can be integrated into the official release.

The last issue with this patch is that it invokes guess_defbranch() once
per repository during scan-path processing, but never for repositories
added manually to cgitrc. I think it shouldn't be invoked at all
during scan-path but instead just once when a repo page has been
selected, i.e. in prepare_repo_cmd(). I can add a fixup patch on top
of the patch from Julius if there's no objections to this plan.

--
larsh



From hjemli at gmail.com  Mon Jun 13 12:16:48 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 13 Jun 2011 12:16:48 +0200
Subject: [PATCH] guess default branch from HEAD
In-Reply-To: <20110613101621.GA29265@hjemli.net>
References: <20110407104958.GB1004@plenz.com>
 <1302173964-12520-1-git-send-email-plenz@cis.fu-berlin.de>
 
 <20110613101621.GA29265@hjemli.net>
Message-ID: 

[Julius should have been CC'ed on this]

---------- Forwarded message ----------
From:  
Date: Mon, Jun 13, 2011 at 12:16
Subject: Re: [PATCH] guess default branch from HEAD
To: chris 
Cc: cgit at hjemli.net


On Fri, Jun 10, 2011 at 06:42:51AM +0000, chris wrote:
> Julius Plenz  writes:
> >
> > This is a saner alternative than hardcoding the default branch to be
> > "master". The add_repo() function will now check for a symbolic ref in
> > repo_path/HEAD. If there is a suitable one, overwrite repo->defbranch
> > with it. Note that you'll need to strip the newline from the file (->
> > len-17).
> >
> > If HEAD is a symbolic link pointing directly to a branch below
> > refs/heads/, do a readlink() instead to find the ref name.
> >
> > Signed-off-by: Julius Plenz 
>
> I've successfully applied this patch against the current stable branch (commit:
> 2a8f5531) and deployed the resulting binary without trouble. ?The functionality
> appears to work as advertised. ?So, along with setting the default 'readme'
> value as:
>
> readme=HEAD:README.md
>
> each project is able to have a sensible default presentation based off of the
> project's default branch. ?Very useful as we use gitolite to manage our
> repositories, this saves us further manual configuration outside of gitolite.
>

Thanks for testing.

> I hope this patch can be integrated into the official release.

The last issue with this patch is that it invokes guess_defbranch() once
per repository during scan-path processing, but never for repositories
added manually to cgitrc. I think it shouldn't be invoked at all
during scan-path but instead just once when a repo page has been
selected, i.e. in prepare_repo_cmd(). I can add a fixup patch on top
of the patch from Julius if there's no objections to this plan.

--
larsh



From larsh at hjemli.net  Mon Jun 13 14:49:54 2011
From: larsh at hjemli.net (larsh at hjemli.net)
Date: Mon, 13 Jun 2011 12:49:54 +0000
Subject: [ANNOUNCE] CGIT 0.9.0.1
Message-ID: <20110613124954.GA737@hjemli.net>

A bugfix release of cgit (a web interface to git repositories) is now
available from http://hjemli.net/git/cgit.

Shortlog since v0.9
===================
Ferry Huberts (2):
      source_filter: fix a memory leak
      new_filter: correctly initialise all arguments for a new filter

Jamie Couture (1):
      scan-tree.c: avoid memory leak

Jonathon Mah (1):
      Fix escaping of paths with spaces

Julius Plenz (2):
      fix two encoding bugs
      Add advice about scan-path in cgitrc.5.txt

Lars Hjemli (9):
      cgitrc.5: tar.xz is a supported snapshot format
      tests/setup.sh: add support for known bugs
      tests: add tests for links with space in path and/or args
      shared.c: do not modify const memory
      ui-repolist.c: do not return random/stale data from read_agefile
      ui-snapshot.c: remove debug cruft
      ui-log.c: do not link from age column
      ui-plain.c: fix html and links generated by print_dir() and print_dir_entry()
      CGIT 0.9.0.1

Lukas Fleischer (5):
      Remove unused variable from cgit_diff_tree().
      Fix memory leak in http_parse_querystring().
      Avoid null pointer dereference in reencode().
      Avoid null pointer dereference in cgit_print_diff().
      Properly escape ampersands inside HTML attributes

Mark Lodato (1):
      fix virtual-root if script-name is ""

Stefan Gehn (1):
      Fix crash when projectsfile cannot be opened




From hjemli at gmail.com  Mon Jun 13 16:42:59 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 13 Jun 2011 16:42:59 +0200
Subject: [ANNOUNCE] CGIT 0.9.0.1
In-Reply-To: <20110613134919.GJ14016@inocybe.localdomain>
References: <20110613124954.GA737@hjemli.net>
 <20110613134919.GJ14016@inocybe.localdomain>
Message-ID: 

On Mon, Jun 13, 2011 at 15:49, Todd Zullinger  wrote:
> larsh at hjemli.net wrote:
>> A bugfix release of cgit (a web interface to git repositories) is now
>> available from http://hjemli.net/git/cgit.
>
> Did the v0.9.0.1 not get pushed yet?

I forgot to push the tag, thanks for noticing.

--
larsh



From hjemli at gmail.com  Tue Jun 14 01:44:56 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Tue, 14 Jun 2011 01:44:56 +0200
Subject: About cgit
In-Reply-To: <4DF57685.2040407@returnfalse.net>
References: <4DF57685.2040407@returnfalse.net>
Message-ID: 

[Added cgit mailing list to CC]

On Mon, Jun 13, 2011 at 04:31, "H.G?khan Sar?"  wrote:
> Is there a supported format for about page? I am using asciidoc by default,
> but although i created about-filter with command "asciidoc -s -o -" it
> doesn't work because -i think- it takes sometime for asciidoc to output. I
> also tried the same for source-filter but it didn't work, either.

On hjemli.net, I use the discount flavour of markdown
(http://www.pell.portland.or.us/~orc/Code/discount/), which has worked
perfectly.


> My next question is that, i saw you created a wiki like structure for about
> page. It contains links and new page opens when link is clicked.

Yes.


> My final question is, my source filter does not work when i define it for
> all repositories. I had to specify it for each repository one by one to get
> it working (using repo.source-filter, instead of source-filter). Is this a
> bug or something?

Not that I know of. Could it be that you specified source-filter
_after_ having specified the various repos? The cgitrc-options are
handled in 'parse-order'.

-- 
larsh



From hjemli at gmail.com  Tue Jun 14 13:45:53 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Tue, 14 Jun 2011 13:45:53 +0200
Subject: Bug in cgit
In-Reply-To: 
References: 
Message-ID: 

[added cgit mailing list to CC]

On Thu, May 19, 2011 at 13:53, Dmitriy Kruglikov
 wrote:
> If the file /etc/cgitrc provide remove-suffix=1,
> then the repository list looks nice,
> but the clone URL is created without the suffix (.git).

This is an inherent problem with the clone-prefix option, but I've
finally been able to create a work-around.

If you use the latest master from hjemli.net/git/cgit, you'll see that
we now support the option clone-url (which works as a template for
repo.clone-url), i.e. you can literally specify

  clone-url=git://example.org/$CGIT_REPO_URL.git

in /etc/cgitrc, and the $CGIT_REPO_URL part will then be replaced by
the (relative) url generated for the repo during scan-path processing.

See http://hjemli.net/git/cgit/tree/cgitrc.5.txt for further details,
especially the "FILTER API" section which enumerates the various
tokens you can use in the clone-url template.

hth
--
larsh



From hjemli at gmail.com  Wed Jun 15 11:12:36 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Wed, 15 Jun 2011 11:12:36 +0200
Subject: [RFC] Improved submodule support
Message-ID: 

The wip-branch on hjemli.net/git now contains some patches which adds
support for `repo.module-link.` options. This seems (to me) like
a reasonable way to handle repositories with more than one submodule
(or a submodule checked out at different paths in different
revisions), but I'd love to get some feedback on the design and
implementation before considering merging this to master.

-- 
larsh



From mailings at hupie.com  Wed Jun 15 11:28:04 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 15 Jun 2011 11:28:04 +0200
Subject: [RFC] Improved submodule support
In-Reply-To: 
References: 
Message-ID: <4DF87B24.6030207@hupie.com>

On 06/15/2011 11:12 AM, Lars Hjemli wrote:
> The wip-branch on hjemli.net/git now contains some patches which adds
> support for `repo.module-link.` options. This seems (to me) like
> a reasonable way to handle repositories with more than one submodule
> (or a submodule checked out at different paths in different
> revisions), but I'd love to get some feedback on the design and
> implementation before considering merging this to master.
> 
I never use submodules, so no feedback from me ;-)

-- 
Ferry Huberts



From dpmcgee at gmail.com  Thu Jun 16 16:42:05 2011
From: dpmcgee at gmail.com (Dan McGee)
Date: Thu, 16 Jun 2011 09:42:05 -0500
Subject: =?UTF-8?q?=5BPATCH=5D=20Remove=20bogus=20warning=20in=20submodule=20link=20code?=
In-Reply-To: 
References: 
Message-ID: <1308235325-7882-1-git-send-email-dpmcgee@gmail.com>

In reality, len should ever be unset here if the conditions are right,
but there is insufficient info for the compiler to realize this so it
spits an error. Initialize len so gcc doesn't spit an error.

Signed-off-by: Dan McGee 
---

Fixes:

    CC ui-shared.o
	ui-shared.c: In function ?cgit_submodule_link?:
	ui-shared.c:559:7: warning: ?len? may be used uninitialized in this function [-Wuninitialized]

 ui-shared.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ui-shared.c b/ui-shared.c
index 3150d48..ac3503c 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -523,7 +523,7 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
 	struct string_list *list;
 	struct string_list_item *item;
 	char tail, *dir;
-	size_t len;
+	size_t len = 0;
 
 	tail = 0;
 	list = &ctx.repo->submodules;
-- 
1.7.5.2




From dpmcgee at gmail.com  Thu Jun 16 16:46:44 2011
From: dpmcgee at gmail.com (Dan McGee)
Date: Thu, 16 Jun 2011 09:46:44 -0500
Subject: [PATCH] Update to use pathspec in read_tree_recursive calls
In-Reply-To: <1307041273-16994-1-git-send-email-dpmcgee@gmail.com>
References: <1307041273-16994-1-git-send-email-dpmcgee@gmail.com>
Message-ID: <1308235604-9558-1-git-send-email-dpmcgee@gmail.com>

This is needed after commit f0096c06 in the git.git repo (a post 1.7.4
change).

Signed-off-by: Dan McGee 
---

This updates the previously sent patch for the read_tree_recursive() call in
ui-plain.c.

 shared.c   |   10 +++++-----
 ui-blob.c  |   16 +++++++++++-----
 ui-plain.c |    5 ++++-
 ui-tree.c  |   10 ++++++++--
 4 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/shared.c b/shared.c
index 0add2e5..ddbb217 100644
--- a/shared.c
+++ b/shared.c
@@ -307,7 +307,6 @@ void cgit_diff_tree(const unsigned char *old_sha1,
 		    filepair_fn fn, const char *prefix, int ignorews)
 {
 	struct diff_options opt;
-	int prefixlen;
 
 	diff_setup(&opt);
 	opt.output_format = DIFF_FORMAT_CALLBACK;
@@ -319,10 +318,10 @@ void cgit_diff_tree(const unsigned char *old_sha1,
 	opt.format_callback = cgit_diff_tree_cb;
 	opt.format_callback_data = fn;
 	if (prefix) {
-		opt.nr_paths = 1;
-		opt.paths = &prefix;
-		prefixlen = strlen(prefix);
-		opt.pathlens = &prefixlen;
+		const char *paths[] = {prefix, NULL};
+		init_pathspec(&opt.pathspec, paths);
+	} else {
+		init_pathspec(&opt.pathspec, NULL);
 	}
 	diff_setup_done(&opt);
 
@@ -332,6 +331,7 @@ void cgit_diff_tree(const unsigned char *old_sha1,
 		diff_root_tree_sha1(new_sha1, "", &opt);
 	diffcore_std(&opt);
 	diff_flush(&opt);
+	free_pathspec(&opt.pathspec);
 }
 
 void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)
diff --git a/ui-blob.c b/ui-blob.c
index ec435e1..f3b0d0d 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -32,16 +32,19 @@ int cgit_print_file(char *path, const char *head)
 	char *buf;
 	unsigned long size;
 	struct commit *commit;
-	const char *paths[] = {path, NULL};
 	if (get_sha1(head, sha1))
 		return -1;
 	type = sha1_object_info(sha1, &size);
 	if(type == OBJ_COMMIT && path) {
+		struct pathspec pathspec;
+		const char *paths[] = {path, NULL};
 		commit = lookup_commit_reference(sha1);
 		match_path = path;
 		matched_sha1 = sha1;
 		found_path = 0;
-		read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL);
+		init_pathspec(&pathspec, paths);
+		read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL);
+		free_pathspec(&pathspec);
 		if (!found_path)
 			return -1;
 		type = sha1_object_info(sha1, &size);
@@ -63,7 +66,6 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
 	char *buf;
 	unsigned long size;
 	struct commit *commit;
-	const char *paths[] = {path, NULL};
 
 	if (hex) {
 		if (get_sha1_hex(hex, sha1)){
@@ -80,11 +82,15 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
 	type = sha1_object_info(sha1, &size);
 
 	if((!hex) && type == OBJ_COMMIT && path) {
+		struct pathspec pathspec;
+		const char *paths[] = {path, NULL};
 		commit = lookup_commit_reference(sha1);
 		match_path = path;
 		matched_sha1 = sha1;
-		read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL);
-		type = sha1_object_info(sha1,&size);
+		init_pathspec(&pathspec, paths);
+		read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL);
+		free_pathspec(&pathspec);
+		type = sha1_object_info(sha1, &size);
 	}
 
 	if (type == OBJ_BAD) {
diff --git a/ui-plain.c b/ui-plain.c
index 2abd210..1fc44cc 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -147,6 +147,7 @@ void cgit_print_plain(struct cgit_context *ctx)
 	const char *rev = ctx->qry.sha1;
 	unsigned char sha1[20];
 	struct commit *commit;
+	struct pathspec pathspec;
 	const char *paths[] = {ctx->qry.path, NULL};
 
 	if (!rev)
@@ -168,7 +169,9 @@ void cgit_print_plain(struct cgit_context *ctx)
 	}
 	else
 		match_baselen = basedir_len(paths[0]);
-	read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL);
+	init_pathspec(&pathspec, paths);
+	read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL);
+	free_pathspec(&pathspec);
 	if (!match)
 		html_status(404, "Not found", 0);
 	else if (match == 2)
diff --git a/ui-tree.c b/ui-tree.c
index b1adcc7..a799556 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -202,6 +202,7 @@ static void ls_tail()
 static void ls_tree(const unsigned char *sha1, char *path)
 {
 	struct tree *tree;
+	struct pathspec pathspec;
 
 	tree = parse_tree_indirect(sha1);
 	if (!tree) {
@@ -211,7 +212,9 @@ static void ls_tree(const unsigned char *sha1, char *path)
 	}
 
 	ls_head();
-	read_tree_recursive(tree, "", 0, 1, NULL, ls_item, NULL);
+	init_pathspec(&pathspec, NULL);
+	read_tree_recursive(tree, "", 0, 1, &pathspec, ls_item, NULL);
+	free_pathspec(&pathspec);
 	ls_tail();
 }
 
@@ -252,6 +255,7 @@ void cgit_print_tree(const char *rev, char *path)
 {
 	unsigned char sha1[20];
 	struct commit *commit;
+	struct pathspec pathspec;
 	const char *paths[] = {path, NULL};
 
 	if (!rev)
@@ -274,6 +278,8 @@ void cgit_print_tree(const char *rev, char *path)
 	}
 
 	match_path = path;
-	read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL);
+	init_pathspec(&pathspec, paths);
+	read_tree_recursive(commit->tree, "", 0, 0, &pathspec, walk_tree, NULL);
+	free_pathspec(&pathspec);
 	ls_tail();
 }
-- 
1.7.5.2




From plenz at cis.fu-berlin.de  Thu Jun 16 16:59:21 2011
From: plenz at cis.fu-berlin.de (Julius Plenz)
Date: Thu, 16 Jun 2011 16:59:21 +0200
Subject: [PATCH] guess default branch from HEAD
In-Reply-To: 
References: <20110407104958.GB1004@plenz.com>
 <1302173964-12520-1-git-send-email-plenz@cis.fu-berlin.de>
 
 <20110613101621.GA29265@hjemli.net>
 
Message-ID: <20110616145921.GA5875@plenz.com>

Hi, Lars!

* Lars Hjemli  [2011-06-13 12:18]:
> [Julius should have been CC'ed on this]

I'm on the list and happy that someone has a use case for this patch,
too. :-)

> > I hope this patch can be integrated into the official release.
> 
> The last issue with this patch is that it invokes guess_defbranch() once
> per repository during scan-path processing, but never for repositories
> added manually to cgitrc. I think it shouldn't be invoked at all
> during scan-path but instead just once when a repo page has been
> selected, i.e. in prepare_repo_cmd().

You mentioned that before, I was not sure where to place it, though.

> I can add a fixup patch on top of the patch from Julius if there's
> no objections to this plan.

To the contrary, I'd appreciate your patch. Thanks. :-)

Julius



From dejan1 at gmail.com  Sat Jun 18 00:12:14 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Fri, 17 Jun 2011 18:12:14 -0400
Subject: Unable to browse Public repo
Message-ID: 

After installing cgit, I went into the configuration and changed this:

repo.url=test
repo.path=/home/dtolj/repositories/test
repo.desc=the master foo repository
repo.owner=dtolj at example.com
repo.readme=info/web/about.html

I create a new public repo like so:
git init --bare /home/dtolj/repositories/test

But I get an error message:
Not a git repository: '/home/dtolj/repositories/test'



From hjemli at gmail.com  Sat Jun 18 09:10:56 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Sat, 18 Jun 2011 09:10:56 +0200
Subject: Fwd: Unable to browse Public repo
In-Reply-To: 
References: 
 
Message-ID: 

[Forgot to CC the list]


---------- Forwarded message ----------
From: Lars Hjemli 
Date: Sat, Jun 18, 2011 at 09:09
Subject: Re: Unable to browse Public repo
To: Dejan Tolj 


On Sat, Jun 18, 2011 at 00:12, Dejan Tolj  wrote:
> After installing cgit, I went into the configuration and changed this:
>
> repo.url=test
> repo.path=/home/dtolj/repositories/test
> repo.desc=the master foo repository
> repo.owner=dtolj at example.com
> repo.readme=info/web/about.html
>
> I create a new public repo like so:
> git init --bare /home/dtolj/repositories/test
>
> But I get an error message:
> Not a git repository: '/home/dtolj/repositories/test'

This is usually a permission problem: cgit needs to stat a few files
in the repo and read the content of HEAD when "opening" the repo, and
if this fails you'll get the quoted error message. Since cgit is
executed by your webserver, you'll have to make sure that the
webserver user account has read-access to the repositories.

--
larsh



From dejan1 at gmail.com  Mon Jun 20 17:43:36 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Mon, 20 Jun 2011 11:43:36 -0400
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
Message-ID: 

Hi
I have set all permissions to 777 in the project directory and in the
.git directory but still get the same error message.
I am using cgit v.0.9

I have played around with the cgitrc file, for repo.path tried:
repo.path=/root/projects/proj/.git
repo.path=/root/projects/proj/proj.git

repo.url=proj1
repo.path=/root/projects/proj/.git
repo.desc=the master foo repository
repo.owner=dtolj at example.com
repo.readme=info/web/about.html


On Sat, Jun 18, 2011 at 3:10 AM, Lars Hjemli  wrote:
> [Forgot to CC the list]
>
>
> ---------- Forwarded message ----------
> From: Lars Hjemli 
> Date: Sat, Jun 18, 2011 at 09:09
> Subject: Re: Unable to browse Public repo
> To: Dejan Tolj 
>
>
> On Sat, Jun 18, 2011 at 00:12, Dejan Tolj  wrote:
>> After installing cgit, I went into the configuration and changed this:
>>
>> repo.url=test
>> repo.path=/home/dtolj/repositories/test
>> repo.desc=the master foo repository
>> repo.owner=dtolj at example.com
>> repo.readme=info/web/about.html
>>
>> I create a new public repo like so:
>> git init --bare /home/dtolj/repositories/test
>>
>> But I get an error message:
>> Not a git repository: '/home/dtolj/repositories/test'
>
> This is usually a permission problem: cgit needs to stat a few files
> in the repo and read the content of HEAD when "opening" the repo, and
> if this fails you'll get the quoted error message. Since cgit is
> executed by your webserver, you'll have to make sure that the
> webserver user account has read-access to the repositories.
>
> --
> larsh
>
> _______________________________________________
> cgit mailing list
> cgit at hjemli.net
> http://hjemli.net/mailman/listinfo/cgit
>



From mailings at hupie.com  Mon Jun 20 17:50:32 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Mon, 20 Jun 2011 17:50:32 +0200
Subject: Unable to browse Public repo
In-Reply-To: 
References: 		
 
Message-ID: <4DFF6C48.3020901@hupie.com>

On 06/20/2011 05:43 PM, Dejan Tolj wrote:
> Hi
> I have set all permissions to 777 in the project directory and in the
> .git directory but still get the same error message.
> I am using cgit v.0.9
> 
> I have played around with the cgitrc file, for repo.path tried:
> repo.path=/root/projects/proj/.git
> repo.path=/root/projects/proj/proj.git
> 
> repo.url=proj1
> repo.path=/root/projects/proj/.git
> repo.desc=the master foo repository
> repo.owner=dtolj at example.com
> repo.readme=info/web/about.html
> 

you need to toggle the selinux boolean that lets apache access files
under /home

> 
> On Sat, Jun 18, 2011 at 3:10 AM, Lars Hjemli  wrote:
>> [Forgot to CC the list]
>>
>>
>> ---------- Forwarded message ----------
>> From: Lars Hjemli 
>> Date: Sat, Jun 18, 2011 at 09:09
>> Subject: Re: Unable to browse Public repo
>> To: Dejan Tolj 
>>
>>
>> On Sat, Jun 18, 2011 at 00:12, Dejan Tolj  wrote:
>>> After installing cgit, I went into the configuration and changed this:
>>>
>>> repo.url=test
>>> repo.path=/home/dtolj/repositories/test
>>> repo.desc=the master foo repository
>>> repo.owner=dtolj at example.com
>>> repo.readme=info/web/about.html
>>>
>>> I create a new public repo like so:
>>> git init --bare /home/dtolj/repositories/test
>>>
>>> But I get an error message:
>>> Not a git repository: '/home/dtolj/repositories/test'
>>
>> This is usually a permission problem: cgit needs to stat a few files
>> in the repo and read the content of HEAD when "opening" the repo, and
>> if this fails you'll get the quoted error message. Since cgit is
>> executed by your webserver, you'll have to make sure that the
>> webserver user account has read-access to the repositories.
>>
>> --
>> larsh
>>
>> _______________________________________________
>> cgit mailing list
>> cgit at hjemli.net
>> http://hjemli.net/mailman/listinfo/cgit
>>
> 
> _______________________________________________
> cgit mailing list
> cgit at hjemli.net
> http://hjemli.net/mailman/listinfo/cgit


-- 
Ferry Huberts



From dejan1 at gmail.com  Mon Jun 20 20:31:22 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Mon, 20 Jun 2011 14:31:22 -0400
Subject: Unable to browse Public repo
In-Reply-To: <4DFF6C48.3020901@hupie.com>
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
Message-ID: 

Still no luck, I have completely disabled selinux.
What is the correct expression for  repo.path?
Is this the correct one: repo.path=/root/projects/proj/.git
It contains the HEAD and other git configs.

On Mon, Jun 20, 2011 at 11:50 AM, Ferry Huberts  wrote:
> On 06/20/2011 05:43 PM, Dejan Tolj wrote:
>> Hi
>> I have set all permissions to 777 in the project directory and in the
>> .git directory but still get the same error message.
>> I am using cgit v.0.9
>>
>> I have played around with the cgitrc file, for repo.path tried:
>> repo.path=/root/projects/proj/.git
>> repo.path=/root/projects/proj/proj.git
>>
>> repo.url=proj1
>> repo.path=/root/projects/proj/.git
>> repo.desc=the master foo repository
>> repo.owner=dtolj at example.com
>> repo.readme=info/web/about.html
>>
>
> you need to toggle the selinux boolean that lets apache access files
> under /home
>
>>
>> On Sat, Jun 18, 2011 at 3:10 AM, Lars Hjemli  wrote:
>>> [Forgot to CC the list]
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: Lars Hjemli 
>>> Date: Sat, Jun 18, 2011 at 09:09
>>> Subject: Re: Unable to browse Public repo
>>> To: Dejan Tolj 
>>>
>>>
>>> On Sat, Jun 18, 2011 at 00:12, Dejan Tolj  wrote:
>>>> After installing cgit, I went into the configuration and changed this:
>>>>
>>>> repo.url=test
>>>> repo.path=/home/dtolj/repositories/test
>>>> repo.desc=the master foo repository
>>>> repo.owner=dtolj at example.com
>>>> repo.readme=info/web/about.html
>>>>
>>>> I create a new public repo like so:
>>>> git init --bare /home/dtolj/repositories/test
>>>>
>>>> But I get an error message:
>>>> Not a git repository: '/home/dtolj/repositories/test'
>>>
>>> This is usually a permission problem: cgit needs to stat a few files
>>> in the repo and read the content of HEAD when "opening" the repo, and
>>> if this fails you'll get the quoted error message. Since cgit is
>>> executed by your webserver, you'll have to make sure that the
>>> webserver user account has read-access to the repositories.
>>>
>>> --
>>> larsh
>>>
>>> _______________________________________________
>>> cgit mailing list
>>> cgit at hjemli.net
>>> http://hjemli.net/mailman/listinfo/cgit
>>>
>>
>> _______________________________________________
>> cgit mailing list
>> cgit at hjemli.net
>> http://hjemli.net/mailman/listinfo/cgit
>
>
> --
> Ferry Huberts
>
> _______________________________________________
> cgit mailing list
> cgit at hjemli.net
> http://hjemli.net/mailman/listinfo/cgit
>



From hjemli at gmail.com  Mon Jun 20 20:31:46 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 20 Jun 2011 20:31:46 +0200
Subject: [PATCH] Remove bogus warning in submodule link code
In-Reply-To: <1308235325-7882-1-git-send-email-dpmcgee@gmail.com>
References: 
 <1308235325-7882-1-git-send-email-dpmcgee@gmail.com>
Message-ID: 

On Thu, Jun 16, 2011 at 16:42, Dan McGee  wrote:
> In reality, len should ever be unset here if the conditions are right,
> but there is insufficient info for the compiler to realize this so it
> spits an error. Initialize len so gcc doesn't spit an error.

Thanks. I've applied your patch, but moved the initialization out of
the declaration block:

--- a/ui-shared.c
+++ b/ui-shared.c
@@ -525,7 +525,7 @@ void cgit_submodule_link(
 	char tail, *dir;
 	size_t len;

-	tail = 0;
+	len = tail = 0;
 	list = &ctx.repo->submodules;
 	item = lookup_path(list, path);
 	if (!item) {

--
larsh



From hjemli at gmail.com  Mon Jun 20 20:44:19 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 20 Jun 2011 20:44:19 +0200
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
Message-ID: 

On Mon, Jun 20, 2011 at 20:31, Dejan Tolj  wrote:
> What is the correct expression for ?repo.path?
> Is this the correct one: repo.path=/root/projects/proj/.git
> It contains the HEAD and other git configs.

That seems right: repo.path should be the absolute path to the git
directory, i.e. the directory containing HEAD, the objects dir etc.

To verify that the repo is ok, do the following:

$ cd /root/projects/proj/.git && git show

You can then try running cgit from the commandline like this:

$ PATH_INFO=proj1 /path/to/cgit.cgi | less

If the generated html still claims that /root/projects/proj/.git is
not a git repository, try

$ PATH_INFO=proj1 strace /path/to/cgit.cgi  1>/dev/null 2>strace.log

Then look into strace.log and see if you can find any interesting errors.

-- 
larsh



From hjemli at gmail.com  Mon Jun 20 20:53:27 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 20 Jun 2011 20:53:27 +0200
Subject: Patch for clone url and SSH
In-Reply-To: 
References: 
Message-ID: 

[CC the cgit mailing list]

On Sun, Jun 19, 2011 at 22:48, Sander van Veen  wrote:
> Today I cloned git://hjemli.net/pub/git/cgit and wrote a patch to fix a bug.
> If I set "clone-prefix=git at host:" in cgitrc, it appends a slash, which
> results in "git at host:/repos". However, my repos is stored in git's homedir,
> so "git at host:repos" should be used.

Thanks, but this is a known misfeature which we really cannot fix (we
need to stay backwards compatible).

The good news is that the latest master on hjemli.net supports a
global 'clone-url' option which doesn't have this and other issues:
see http://hjemli.net/git/cgit/commit/?id=a1429dbc for further
details.

-- 
larsh



From dejan1 at gmail.com  Mon Jun 20 21:12:48 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Mon, 20 Jun 2011 15:12:48 -0400
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
Message-ID: 

$ git show
commit 508c91c5475935d10832bc3cfc59fea0cd0590b6
Author: root 
Date:   Mon Jun 20 14:56:44 2011 -0400

    first commit

diff --git a/hi.c b/hi.c
new file mode 100644
index 0000000..3b18e51
--- /dev/null
+++ b/hi.c
@@ -0,0 +1 @@
+hello world

I don't see cgit.cgi anywhere!

$ PATH_INFO=proj1 /var/www/cgi-bin/cgit
returns Segmentation fault

Here is the strace dump.

[root at WEB01]~/projects/proj/.git $ cat strace.log
execve("/var/www/cgi-bin/cgit", ["/var/www/cgi-bin/cgit"], [/* 26 vars */]) = 0
brk(0)                                  = 0x99a1000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=58064, ...}) = 0
mmap2(NULL, 58064, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fa6000
close(3)                                = 0
open("/usr/lib/libz.so.1", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\240\246\233\0004\0\0\0"...,
512) = 512
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fa5000
fstat64(3, {st_mode=S_IFREG|0755, st_size=75284, ...}) = 0
mmap2(0x9b9000, 76656, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0x9b9000
mmap2(0x9cb000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11) = 0x9cb000
close(3)                                = 0
open("/lib/libpthread.so.0", O_RDONLY)  = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0P(\232\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=137908, ...}) = 0
mmap2(0x99e000, 98788, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0x99e000
mmap2(0x9b3000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15) = 0x9b3000
mmap2(0x9b5000, 4580, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x9b5000
close(3)                                = 0
open("/lib/libcrypto.so.6", O_RDONLY)   = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\200\205\273\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1296964, ...}) = 0
mmap2(0xb85000, 1312992, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb85000
mmap2(0xcaf000, 77824, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x129) = 0xcaf000
mmap2(0xcc2000, 14560, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xcc2000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3

[15:10:41]
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\340o\202\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1693812, ...}) = 0
mmap2(0x811000, 1410500, PROT_READ|PROT_EXEC,
MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x811000
mmap2(0x964000, 12288, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x153) = 0x964000
mmap2(0x967000, 9668, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x967000
close(3)                                = 0
open("/lib/libdl.so.2", O_RDONLY)       = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p\312\226\0004\0\0\0"...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=20668, ...}) = 0
mmap2(0x96c000, 16504, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0x96c000
mmap2(0x96f000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2) = 0x96f000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fa4000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fa3000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7fa36c0,
limit:1048575, seg_32bit:1, contents:0, read_exec_only:0,
limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0x96f000, 4096, PROT_READ)     = 0
mprotect(0x964000, 8192, PROT_READ)     = 0
mprotect(0x9b3000, 4096, PROT_READ)     = 0
mprotect(0x80d000, 4096, PROT_READ)     = 0
munmap(0xb7fa6000, 58064)               = 0
set_tid_address(0xb7fa3708)             = 14539
set_robust_list(0xb7fa3710, 0xc)        = 0
futex(0xbf877714, FUTEX_WAKE_PRIVATE, 1) = 0
rt_sigaction(SIGRTMIN, {0x9a23e0, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x9a22e0, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys="Linux", node="WEB01.x.local", ...}) = 0
brk(0)                                  = 0x99a1000
brk(0x99c2000)                          = 0x99c2000
time(NULL)                              = 1308596639
open("/etc/cgitrc", O_RDONLY)           = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2058, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7fb4000
read(3, "#\n# See cgitrc(5) or /usr/share/"..., 4096) = 2058
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0xb7fb4000, 4096)                = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++




On Mon, Jun 20, 2011 at 2:44 PM, Lars Hjemli  wrote:
> On Mon, Jun 20, 2011 at 20:31, Dejan Tolj  wrote:
>> What is the correct expression for ?repo.path?
>> Is this the correct one: repo.path=/root/projects/proj/.git
>> It contains the HEAD and other git configs.
>
> That seems right: repo.path should be the absolute path to the git
> directory, i.e. the directory containing HEAD, the objects dir etc.
>
> To verify that the repo is ok, do the following:
>
> $ cd /root/projects/proj/.git && git show
>
> You can then try running cgit from the commandline like this:
>
> $ PATH_INFO=proj1 /path/to/cgit.cgi | less
>
> If the generated html still claims that /root/projects/proj/.git is
> not a git repository, try
>
> $ PATH_INFO=proj1 strace /path/to/cgit.cgi ?1>/dev/null 2>strace.log
>
> Then look into strace.log and see if you can find any interesting errors.
>
> --
> larsh
>



From hjemli at gmail.com  Mon Jun 20 21:25:00 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 20 Jun 2011 21:25:00 +0200
Subject: [PATCH] guess default branch from HEAD
In-Reply-To: <20110616145921.GA5875@plenz.com>
References: <20110407104958.GB1004@plenz.com>
 <1302173964-12520-1-git-send-email-plenz@cis.fu-berlin.de>
 
 <20110613101621.GA29265@hjemli.net>
 
 <20110616145921.GA5875@plenz.com>
Message-ID: 

On Thu, Jun 16, 2011 at 16:59, Julius Plenz  wrote:
>> I can add a fixup patch on top of the patch from Julius if there's
>> no objections to this plan.
>
> To the contrary, I'd appreciate your patch. Thanks. :-)

Your patch and my fixup is now part of the wip branch on hjemli.net/git/cgit.

-- 
larsh



From hjemli at gmail.com  Mon Jun 20 21:30:25 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 20 Jun 2011 21:30:25 +0200
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
 
Message-ID: 

On Mon, Jun 20, 2011 at 21:12, Dejan Tolj  wrote:
> $ PATH_INFO=proj1 /var/www/cgi-bin/cgit
> returns Segmentation fault
>
> Here is the strace dump.
[snip]

The strace looked ok. Could you repeat this experiment, but using gdb
instead of strace to get a backtrace when the segfault occurs?

$ PATH_INFO=proj1 gdb /var/www/cgi-bin/cgit
(gdb) r
....[segfault]...
(gdb) bt

-- 
larsh



From dejan1 at gmail.com  Mon Jun 20 21:37:49 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Mon, 20 Jun 2011 15:37:49 -0400
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
 
 
Message-ID: 

(gdb) r
Starting program: /var/www/cgi-bin/cgit
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x0805066e in pthread_key_create ()
(gdb) bt
#0  0x0805066e in pthread_key_create ()
#1  0x0804bc2c in pthread_key_create ()
#2  0x00826e9c in __libc_start_main () from /lib/libc.so.6
#3  0x0804a4f1 in pthread_key_create ()
(gdb)


On Mon, Jun 20, 2011 at 3:30 PM, Lars Hjemli  wrote:
> On Mon, Jun 20, 2011 at 21:12, Dejan Tolj  wrote:
>> $ PATH_INFO=proj1 /var/www/cgi-bin/cgit
>> returns Segmentation fault
>>
>> Here is the strace dump.
> [snip]
>
> The strace looked ok. Could you repeat this experiment, but using gdb
> instead of strace to get a backtrace when the segfault occurs?
>
> $ PATH_INFO=proj1 gdb /var/www/cgi-bin/cgit
> (gdb) r
> ....[segfault]...
> (gdb) bt
>
> --
> larsh
>



From hjemli at gmail.com  Mon Jun 20 22:43:07 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Mon, 20 Jun 2011 22:43:07 +0200
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
 
 
 
Message-ID: 

On Mon, Jun 20, 2011 at 21:37, Dejan Tolj  wrote:
> (gdb) r
> Starting program: /var/www/cgi-bin/cgit
> [Thread debugging using libthread_db enabled]
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0805066e in pthread_key_create ()
> (gdb) bt
> #0 ?0x0805066e in pthread_key_create ()
> #1 ?0x0804bc2c in pthread_key_create ()
> #2 ?0x00826e9c in __libc_start_main () from /lib/libc.so.6
> #3 ?0x0804a4f1 in pthread_key_create ()
> (gdb)

Hmm, something fishy seems to be going on. How did you build/install
cgit, and on what linux distro and hardware are you running it?

--
larsh



From dejan1 at gmail.com  Mon Jun 20 22:51:52 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Mon, 20 Jun 2011 16:51:52 -0400
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
 
 
 
 
Message-ID: 

I am running RHEL5.6 on a esx server
I pulled cgit from EPEL repo.

On Mon, Jun 20, 2011 at 4:43 PM, Lars Hjemli  wrote:
> On Mon, Jun 20, 2011 at 21:37, Dejan Tolj  wrote:
>> (gdb) r
>> Starting program: /var/www/cgi-bin/cgit
>> [Thread debugging using libthread_db enabled]
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x0805066e in pthread_key_create ()
>> (gdb) bt
>> #0 ?0x0805066e in pthread_key_create ()
>> #1 ?0x0804bc2c in pthread_key_create ()
>> #2 ?0x00826e9c in __libc_start_main () from /lib/libc.so.6
>> #3 ?0x0804a4f1 in pthread_key_create ()
>> (gdb)
>
> Hmm, something fishy seems to be going on. How did you build/install
> cgit, and on what linux distro and hardware are you running it?
>
> --
> larsh
>



From larsh at hjemli.net  Tue Jun 21 01:37:01 2011
From: larsh at hjemli.net (larsh at hjemli.net)
Date: Mon, 20 Jun 2011 23:37:01 +0000
Subject: [PATCH] cgit.c: use resolve_ref() to guess_defbranch()
Message-ID: <20110620233701.GA11444@hjemli.net>

The resolve_ref() function handles reading of git- and filesystem
symbolic links (including proper whitespace trimming) and packed refs.
There's no point in reimplementing this function in cgit.

Signed-off-by: Lars Hjemli 
--
After deploying the wip-branch on hjemli.net, I noticed that the
default branch in the git.git repository wasn't correctly set. This was
due the HEAD symbolic ref having two trailing newlines, so I started
looking into how the git code handled this case and ended up with this
patch.

diff --git a/cgit.c b/cgit.c
index e3fbbf4..624cb2c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -418,33 +418,13 @@ char *find_default_branch(struct cgit_repo *repo)
 
 static char *guess_defbranch(const char *repo_path)
 {
-	int fd, len;
-	char buffer[256];
-	char *ref_start;
-	char *head;
-
-	head = fmt("%s/HEAD", repo_path);
-	fd = open(head, O_RDONLY);
-	if (fd == -1)
-		return xstrdup("master");
-
-	memset(buffer, 0, sizeof(buffer));
-	len = read_in_full(fd, buffer, sizeof(buffer) - 1);
-	close(fd);
-
-	if(!memcmp(buffer, "ref: refs/heads/", 16))
-		return xstrndup(buffer + 16, len - 17);
-
-	if(strlen(buffer) == 41) {
-		/* probably contains a SHA1 sum */
-		memset(buffer, 0, sizeof(buffer));
-		if(readlink(head, buffer, sizeof(buffer)-1)) {
-			ref_start = memmem(buffer, sizeof(buffer)-1, "refs/heads/", 11);
-			if(ref_start)
-				return xstrdup(ref_start+11);
-		}
-	}
-	return xstrdup("master");
+	const char *ref;
+	unsigned char sha1[20];
+
+	ref = resolve_ref("HEAD", sha1, 0, NULL);
+	if (!ref || prefixcmp(ref, "refs/heads/"))
+		return "master";
+	return xstrdup(ref + 11);
 }
 
 static int prepare_repo_cmd(struct cgit_context *ctx)



From hjemli at gmail.com  Tue Jun 21 01:39:27 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Tue, 21 Jun 2011 01:39:27 +0200
Subject: Fwd: [PATCH] cgit.c: use resolve_ref() to guess_defbranch()
In-Reply-To: <20110620233701.GA11444@hjemli.net>
References: <20110620233701.GA11444@hjemli.net>
Message-ID: 

[Resend since I failed to CC Julius, sorry for the noise]

---------- Forwarded message ----------
From:  
Date: Tue, Jun 21, 2011 at 01:37
Subject: [PATCH] cgit.c: use resolve_ref() to guess_defbranch()
To: cgit at hjemli.net


The resolve_ref() function handles reading of git- and filesystem
symbolic links (including proper whitespace trimming) and packed refs.
There's no point in reimplementing this function in cgit.

Signed-off-by: Lars Hjemli 
--
After deploying the wip-branch on hjemli.net, I noticed that the
default branch in the git.git repository wasn't correctly set. This was
due the HEAD symbolic ref having two trailing newlines, so I started
looking into how the git code handled this case and ended up with this
patch.

diff --git a/cgit.c b/cgit.c
index e3fbbf4..624cb2c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -418,33 +418,13 @@ char *find_default_branch(struct cgit_repo *repo)

?static char *guess_defbranch(const char *repo_path)
?{
- ? ? ? int fd, len;
- ? ? ? char buffer[256];
- ? ? ? char *ref_start;
- ? ? ? char *head;
-
- ? ? ? head = fmt("%s/HEAD", repo_path);
- ? ? ? fd = open(head, O_RDONLY);
- ? ? ? if (fd == -1)
- ? ? ? ? ? ? ? return xstrdup("master");
-
- ? ? ? memset(buffer, 0, sizeof(buffer));
- ? ? ? len = read_in_full(fd, buffer, sizeof(buffer) - 1);
- ? ? ? close(fd);
-
- ? ? ? if(!memcmp(buffer, "ref: refs/heads/", 16))
- ? ? ? ? ? ? ? return xstrndup(buffer + 16, len - 17);
-
- ? ? ? if(strlen(buffer) == 41) {
- ? ? ? ? ? ? ? /* probably contains a SHA1 sum */
- ? ? ? ? ? ? ? memset(buffer, 0, sizeof(buffer));
- ? ? ? ? ? ? ? if(readlink(head, buffer, sizeof(buffer)-1)) {
- ? ? ? ? ? ? ? ? ? ? ? ref_start = memmem(buffer, sizeof(buffer)-1,
"refs/heads/", 11);
- ? ? ? ? ? ? ? ? ? ? ? if(ref_start)
- ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return xstrdup(ref_start+11);
- ? ? ? ? ? ? ? }
- ? ? ? }
- ? ? ? return xstrdup("master");
+ ? ? ? const char *ref;
+ ? ? ? unsigned char sha1[20];
+
+ ? ? ? ref = resolve_ref("HEAD", sha1, 0, NULL);
+ ? ? ? if (!ref || prefixcmp(ref, "refs/heads/"))
+ ? ? ? ? ? ? ? return "master";
+ ? ? ? return xstrdup(ref + 11);
?}

?static int prepare_repo_cmd(struct cgit_context *ctx)



From mailings at hupie.com  Wed Jun 22 21:10:39 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 22 Jun 2011 21:10:39 +0200
Subject: mime types
Message-ID: <4E023E2F.7050702@hupie.com>

Hi

Instead of hardcoding the mime types cgit knows about, why not read
/etc/mime.types when a mime type is needed?

grtz

-- 
Ferry Huberts



From mailings at hupie.com  Wed Jun 22 22:46:23 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 22 Jun 2011 22:46:23 +0200
Subject: [RESEND] [PATCH v2 1/1] commit-links.sh: improve regular expressions
Message-ID: <1308775583-22566-1-git-send-email-mailings@hupie.com>

From: Ferry Huberts 

Signed-off-by: Ferry Huberts 
---
 filters/commit-links.sh |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/filters/commit-links.sh b/filters/commit-links.sh
index d2cd2b3..5881952 100755
--- a/filters/commit-links.sh
+++ b/filters/commit-links.sh
@@ -15,11 +15,14 @@
 # CGIT_REPO_CLONE_URL  ( = repo.clone-url setting )
 #
 
+regex=''
+
 # This expression generates links to commits referenced by their SHA1.
 regex=$regex'
-s|\b([0-9a-fA-F]{8,40})\b|\1|g'
+s|\b([0-9a-fA-F]{7,40})\b|\1|g'
+
 # This expression generates links to a fictional bugtracker.
 regex=$regex'
-s| #([0-9]+)\b|#\1|g'
+s|#([0-9]+)\b|#\1|g'
 
 sed -re "$regex"
-- 
1.7.5.4




From hjemli at gmail.com  Wed Jun 22 23:01:00 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Wed, 22 Jun 2011 23:01:00 +0200
Subject: mime types
In-Reply-To: <4E023E2F.7050702@hupie.com>
References: <4E023E2F.7050702@hupie.com>
Message-ID: 

On Wed, Jun 22, 2011 at 21:10, Ferry Huberts  wrote:
> Instead of hardcoding the mime types cgit knows about, why not read
> /etc/mime.types when a mime type is needed?

Yeah, an option to specify the path to a (httpd style) mime.types file
and then looking into this file when a mimetype lookup is needed (i.e.
in ui-plain.c) sounds like a good idea.

--
larsh



From hjemli at gmail.com  Wed Jun 22 23:09:04 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Wed, 22 Jun 2011 23:09:04 +0200
Subject: [RESEND] [PATCH v2 1/1] commit-links.sh: improve regular
 expressions
In-Reply-To: <1308775583-22566-1-git-send-email-mailings@hupie.com>
References: <1308775583-22566-1-git-send-email-mailings@hupie.com>
Message-ID: 

On Wed, Jun 22, 2011 at 22:46, Ferry Huberts  wrote:
> From: Ferry Huberts 
>
> Signed-off-by: Ferry Huberts 

I still would like a commit message for this patch which describes the
rationale for the changes it introduces, i.e. what's wrong with the
first usage of $regex, why is 7 a better number than 8, and why
shouldn't the ticket hash be prefixed by a space? And are there any
other changes in the patch which I didn't spot?

--
larsh



From hjemli at gmail.com  Wed Jun 22 23:15:33 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Wed, 22 Jun 2011 23:15:33 +0200
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
 
 
 
 
 
Message-ID: 

[Could you please not top-post?]

On Mon, Jun 20, 2011 at 22:51, Dejan Tolj  wrote:
> On Mon, Jun 20, 2011 at 4:43 PM, Lars Hjemli  wrote:
>> On Mon, Jun 20, 2011 at 21:37, Dejan Tolj  wrote:
>>> (gdb) r
>>> Starting program: /var/www/cgi-bin/cgit
>>> [Thread debugging using libthread_db enabled]
>>>
>>> Program received signal SIGSEGV, Segmentation fault.
>>> 0x0805066e in pthread_key_create ()
>>> (gdb) bt
>>> #0 ?0x0805066e in pthread_key_create ()
>>> #1 ?0x0804bc2c in pthread_key_create ()
>>> #2 ?0x00826e9c in __libc_start_main () from /lib/libc.so.6
>>> #3 ?0x0804a4f1 in pthread_key_create ()
>>> (gdb)
>>
>> Hmm, something fishy seems to be going on. How did you build/install
>> cgit, and on what linux distro and hardware are you running it?
>>
> I am running RHEL5.6 on a esx server
> I pulled cgit from EPEL repo.

Ok, this is a long shot, but could you try the following:

$ git clone git://hjemli.net/pub/git/cgit
$ cd cgit
$ make get-git
$ make test

The last `make` invocation compiles a fresh cgit binary and puts it
through the cgit test-suite, which hopefully can give us some further
clues about your cgit issues.

-- 
larsh



From mailings at hupie.com  Wed Jun 22 23:22:19 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 22 Jun 2011 23:22:19 +0200
Subject: mime types
In-Reply-To: 
References: <4E023E2F.7050702@hupie.com>
 
Message-ID: <4E025D0B.8040507@hupie.com>

On 06/22/2011 11:01 PM, Lars Hjemli wrote:
> On Wed, Jun 22, 2011 at 21:10, Ferry Huberts  wrote:
>> Instead of hardcoding the mime types cgit knows about, why not read
>> /etc/mime.types when a mime type is needed?
> 
> Yeah, an option to specify the path to a (httpd style) mime.types file
> and then looking into this file when a mimetype lookup is needed (i.e.
> in ui-plain.c) sounds like a good idea.

already working on it :-)

found ui-plain.c::print_object to change


With the httpd style I hope you mean the same format as /etc/mime.types?
My /etc/mime.types is provided by mailcap on F15 and CentOS/RHEL 5
It's format is very simple:
- comments are empty lines or lines starting with a #
- other lines are: mimetype [extension]+


I propose a new parameter called mime-types with a default of
/etc/mime.types

-- 
Ferry Huberts



From hjemli at gmail.com  Wed Jun 22 23:26:59 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Wed, 22 Jun 2011 23:26:59 +0200
Subject: [RESEND] [PATCH v2 1/1] commit-links.sh: improve regular
 expressions
In-Reply-To: <4E025ADA.7030603@hupie.com>
References: <1308775583-22566-1-git-send-email-mailings@hupie.com>
 
 <4E025ADA.7030603@hupie.com>
Message-ID: 

On Wed, Jun 22, 2011 at 23:12, Ferry Huberts  wrote:
> On 06/22/2011 11:09 PM, Lars Hjemli wrote:
>> I still would like a commit message for this patch which describes the
>> rationale for the changes it introduces
>
> [snip]
>
> or do you want a new patch?

Yes. I do agree that all three changes are improvements, but it would
be nice to get an explanation of the improvements in the commit
message.

-- 
larsh



From hjemli at gmail.com  Wed Jun 22 23:55:40 2011
From: hjemli at gmail.com (Lars Hjemli)
Date: Wed, 22 Jun 2011 23:55:40 +0200
Subject: mime types
In-Reply-To: <4E025D0B.8040507@hupie.com>
References: <4E023E2F.7050702@hupie.com>
 
 <4E025D0B.8040507@hupie.com>
Message-ID: 

On Wed, Jun 22, 2011 at 23:22, Ferry Huberts  wrote:
> On 06/22/2011 11:01 PM, Lars Hjemli wrote:
>> On Wed, Jun 22, 2011 at 21:10, Ferry Huberts  wrote:
>>> Instead of hardcoding the mime types cgit knows about, why not read
>>> /etc/mime.types when a mime type is needed?
>>
>> Yeah, an option to specify the path to a (httpd style) mime.types file
>> and then looking into this file when a mimetype lookup is needed (i.e.
>> in ui-plain.c) sounds like a good idea.
>
> already working on it :-)

Great.

> With the httpd style I hope you mean the same format as /etc/mime.types?

I think so. See below...

> My /etc/mime.types is provided by mailcap on F15 and CentOS/RHEL 5
> It's format is very simple:
> - comments are empty lines or lines starting with a #
> - other lines are: mimetype [extension]+
>

On my box (slackware 13), there's no /etc/mime.types but there's
/etc/httpd/mime.types which seems to match your description [1]. But
`man mime.types` documents a different format used by CUPS, which
seems to be much more complex [2]. We probably don't want to support
the latter variant.

> I propose a new parameter called mime-types with a default of
> /etc/mime.types

I don't think the parameter should have a default value - not everyone
agree that plain-view should return the "correct" mimetypes for blobs
(due to security _and_ philosophy), hence the use of hardcoded
"plain/text" and "application/octet-stream" when no (matching)
mimetype-mapping is specified in cgitrc.

Also, since we already have the option 'mimetype.', I propose the
name 'mimetype-file' for this new option.

-- 
larsh

[1] $ head -20 /etc/httpd/mime.types
# This file maps Internet media types to unique file extension(s).
# Although created for httpd, this file is used by many software systems
# and has been placed in the public domain for unlimited redisribution.
#
# The table below contains both registered and (common) unregistered types.
# A type that has no unique extension can be ignored -- they are listed
# here to guide configurations toward known types and to make it easier to
# identify "new" types.  File extensions are also commonly used to indicate
# content languages and encodings, so choose them carefully.
#
# Internet media types should be registered as described in RFC 4288.
# The registry is at .
#
# MIME type					Extensions
# application/3gpp-ims+xml
# application/activemessage
application/andrew-inset			ez
# application/applefile
application/applixware				aw
application/atom+xml				atom

[2] $ man mime.types|cat
mime.types(5)                     Apple Inc.                     mime.types(5)

NAME
       mime.types - mime type description file for cups

DESCRIPTION
       The mime.types file defines the recognized file types.

       Additional  file  types  can  be added to mime.types or (preferably) in
       additional files in the CUPS configuration directory with the extension
       ".types".

       Each  line  in  the  mime.types file is a comment, blank, or rule line.
       Comment lines start with the # character. Rule  lines  start  with  the
       MIME type name and are optionally followed by a series of file recogni?
       tion rules that are used to automatically identify print and web files:

           super/type rule [ ... ruleN]
       The rules may be grouped using parenthesis, joined using "+" for a log?
       ical AND and "," or whitespace for a logical OR, and negated using "!".

RULES
       Rules  take  two  forms  - a filename extension by itself and functions
       with test values inside parenthesis. The following functions are avail?
       able:

       match("pattern")
            Pattern match on filename

       ascii(offset,length)
            True if bytes are valid printable ASCII (CR, NL, TAB, BS, 32-126)

       printable(offset,length)
            True  if bytes are printable 8-bit chars (CR, NL, TAB, BS, 32-126,
            128-254)

       string(offset,"string")
            True if bytes are identical to string

       istring(offset,"string")
            True if a case-insensitive comparison of the bytes is identical

       char(offset,value)
            True if byte is identical

       short(offset,value)
            True if 16-bit integer is identical

       int(offset,value)
            True if 32-bit integer is identical

       locale("string")
            True if current locale matches string

       contains(offset,range,"string")
            True if the range contains the string

STRING CONSTANTS
       String constants can be specified inside quotes ("") for  strings  con?
       taining whitespace and angle brackets (<>) for hexadecimal strings.

SEE ALSO
       classes.conf(5),   cupsd(8),   cupsd.conf(5),   mime.convs(5),   print?
       ers.conf(5),
       http://localhost:631/help

COPYRIGHT
       Copyright 2007 by Apple Inc.

12 February 2006          Common UNIX Printing System            mime.types(5)



From mailings at hupie.com  Thu Jun 23 00:02:59 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 23 Jun 2011 00:02:59 +0200
Subject: mime types
In-Reply-To: 
References: <4E023E2F.7050702@hupie.com>		<4E025D0B.8040507@hupie.com>
 
Message-ID: <4E026693.4070004@hupie.com>

On 06/22/2011 11:55 PM, Lars Hjemli wrote:
> On my box (slackware 13), there's no /etc/mime.types but there's
> /etc/httpd/mime.types which seems to match your description [1]. But
> `man mime.types` documents a different format used by CUPS, which
> seems to be much more complex [2]. We probably don't want to support
> the latter variant.
> 

agreed

>> I propose a new parameter called mime-types with a default of
>> /etc/mime.types
> 
> I don't think the parameter should have a default value - not everyone
> agree that plain-view should return the "correct" mimetypes for blobs
> (due to security _and_ philosophy), hence the use of hardcoded
> "plain/text" and "application/octet-stream" when no (matching)
> mimetype-mapping is specified in cgitrc.
> 
> Also, since we already have the option 'mimetype.', I propose the
> name 'mimetype-file' for this new option.
> 

ok

I will first start to implement without the parameter anyway.

-- 
Ferry Huberts



From mailings at hupie.com  Thu Jun 23 02:02:08 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 23 Jun 2011 02:02:08 +0200
Subject: [PATCH 1/1] ui_plain: automatically lookup mimetype when
 mimetype-file is set
Message-ID: <1308787328-7538-1-git-send-email-mailings@hupie.com>

From: Ferry Huberts 

Signed-off-by: Ferry Huberts 
---
 cgit.c       |    2 ++
 cgit.h       |    1 +
 cgitrc.5.txt |   10 ++++++++++
 ui-plain.c   |   41 ++++++++++++++++++++++++++++++++++++++---
 4 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/cgit.c b/cgit.c
index b7807ad..abb698b 100644
--- a/cgit.c
+++ b/cgit.c
@@ -236,6 +236,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.ssdiff = atoi(value);
 	else if (!strcmp(name, "agefile"))
 		ctx.cfg.agefile = xstrdup(value);
+	else if (!strcmp(name, "mimetype-file"))
+		ctx.cfg.mimetype_file = xstrdup(value);
 	else if (!strcmp(name, "renamelimit"))
 		ctx.cfg.renamelimit = atoi(value);
 	else if (!strcmp(name, "remove-suffix"))
diff --git a/cgit.h b/cgit.h
index bad66f0..db24941 100644
--- a/cgit.h
+++ b/cgit.h
@@ -175,6 +175,7 @@ struct cgit_config {
 	char *index_info;
 	char *logo;
 	char *logo_link;
+	char *mimetype_file;
 	char *module_link;
 	char *project_list;
 	char *readme;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 4721c1e..3a3d1b6 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -222,6 +222,16 @@ max-stats::
 	"month", "quarter" and "year". If unspecified, statistics are
 	disabled. Default value: none. See also: "repo.max-stats".
 
+mimetype-file::
+	Specifies the file to use for automatic mimetype lookup. If specified
+	then this field takes precedence over "mimetype.". If unspecified
+	then no such lookup is performed. Default value: none.
+	See also: "mimetype.". The format of the file must comply to:
+	- a comment line is an empty line or a line starting hash (#) optional
+	  preceded by whitespace,
+	- a non-comment line starts with the mimetype (like image/png), followed
+	  by one or more file extensions, all separated by whitespace.
+
 mimetype.::
 	Set the mimetype for the specified filename extension. This is used
 	by the `plain` command when returning blob content.
diff --git a/ui-plain.c b/ui-plain.c
index 733db4d..7062733 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -6,6 +6,8 @@
  *   (see COPYING for full license text)
  */
 
+#include 
+#include 
 #include "cgit.h"
 #include "html.h"
 #include "ui-shared.h"
@@ -13,12 +15,39 @@
 int match_baselen;
 int match;
 
+static char * getMimeFromFile(char *ext) {
+	static const char * delimiters = " \t\r\n";
+	char * result = NULL;
+	FILE * fd;
+	char line[1024];
+	char * mimetype;
+	char * token;
+
+	fd = fopen("/etc/mime.types", "r");
+	if (fd) {
+		while (fgets(line, sizeof(line), fd)) {
+			mimetype = strtok(line, delimiters);
+			if (mimetype && (mimetype[0] != '#')) {
+				while ((token = strtok(NULL, delimiters))) {
+					if (!strcasecmp(ext, token)) {
+						result = xstrdup(mimetype);
+						goto endloop;
+					}
+				}
+			}
+		}
+		endloop: fclose(fd);
+	}
+	return result;
+}
+
 static void print_object(const unsigned char *sha1, const char *path)
 {
 	enum object_type type;
 	char *buf, *ext;
 	unsigned long size;
 	struct string_list_item *mime;
+	bool freemime = false;
 
 	type = sha1_object_info(sha1, &size);
 	if (type == OBJ_BAD) {
@@ -34,9 +63,13 @@ static void print_object(const unsigned char *sha1, const char *path)
 	ctx.page.mimetype = NULL;
 	ext = strrchr(path, '.');
 	if (ext && *(++ext)) {
-		mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
-		if (mime)
-			ctx.page.mimetype = (char *)mime->util;
+		if (ctx.cfg.mimetype_file && (ctx.page.mimetype = getMimeFromFile(ext))) {
+			freemime = true;
+		} else {
+			mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
+			if (mime)
+				ctx.page.mimetype = (char *)mime->util;
+		}
 	}
 	if (!ctx.page.mimetype) {
 		if (buffer_is_binary(buf, size))
@@ -50,6 +83,8 @@ static void print_object(const unsigned char *sha1, const char *path)
 	cgit_print_http_headers(&ctx);
 	html_raw(buf, size);
 	match = 1;
+	if (freemime)
+		free(ctx.page.mimetype);
 }
 
 static char *buildpath(const char *base, int baselen, const char *path)
-- 
1.7.5.4




From mailings at hupie.com  Thu Jun 23 02:04:14 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 23 Jun 2011 02:04:14 +0200
Subject: [PATCH 1/1] ui_plain: automatically lookup mimetype
 when	mimetype-file is set
In-Reply-To: <1308787328-7538-1-git-send-email-mailings@hupie.com>
References: <1308787328-7538-1-git-send-email-mailings@hupie.com>
Message-ID: <4E0282FE.8050502@hupie.com>

forget this patch please.

It's 2AM and it appears I need some sleep.
Will send a new patch in the morning

On 06/23/2011 02:02 AM, Ferry Huberts wrote:
> From: Ferry Huberts 
> 
> Signed-off-by: Ferry Huberts 
> ---
>  cgit.c       |    2 ++
>  cgit.h       |    1 +
>  cgitrc.5.txt |   10 ++++++++++
>  ui-plain.c   |   41 ++++++++++++++++++++++++++++++++++++++---
>  4 files changed, 51 insertions(+), 3 deletions(-)
> 
> diff --git a/cgit.c b/cgit.c
> index b7807ad..abb698b 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -236,6 +236,8 @@ void config_cb(const char *name, const char *value)
>  		ctx.cfg.ssdiff = atoi(value);
>  	else if (!strcmp(name, "agefile"))
>  		ctx.cfg.agefile = xstrdup(value);
> +	else if (!strcmp(name, "mimetype-file"))
> +		ctx.cfg.mimetype_file = xstrdup(value);
>  	else if (!strcmp(name, "renamelimit"))
>  		ctx.cfg.renamelimit = atoi(value);
>  	else if (!strcmp(name, "remove-suffix"))
> diff --git a/cgit.h b/cgit.h
> index bad66f0..db24941 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -175,6 +175,7 @@ struct cgit_config {
>  	char *index_info;
>  	char *logo;
>  	char *logo_link;
> +	char *mimetype_file;
>  	char *module_link;
>  	char *project_list;
>  	char *readme;
> diff --git a/cgitrc.5.txt b/cgitrc.5.txt
> index 4721c1e..3a3d1b6 100644
> --- a/cgitrc.5.txt
> +++ b/cgitrc.5.txt
> @@ -222,6 +222,16 @@ max-stats::
>  	"month", "quarter" and "year". If unspecified, statistics are
>  	disabled. Default value: none. See also: "repo.max-stats".
>  
> +mimetype-file::
> +	Specifies the file to use for automatic mimetype lookup. If specified
> +	then this field takes precedence over "mimetype.". If unspecified
> +	then no such lookup is performed. Default value: none.
> +	See also: "mimetype.". The format of the file must comply to:
> +	- a comment line is an empty line or a line starting hash (#) optional
> +	  preceded by whitespace,
> +	- a non-comment line starts with the mimetype (like image/png), followed
> +	  by one or more file extensions, all separated by whitespace.
> +
>  mimetype.::
>  	Set the mimetype for the specified filename extension. This is used
>  	by the `plain` command when returning blob content.
> diff --git a/ui-plain.c b/ui-plain.c
> index 733db4d..7062733 100644
> --- a/ui-plain.c
> +++ b/ui-plain.c
> @@ -6,6 +6,8 @@
>   *   (see COPYING for full license text)
>   */
>  
> +#include 
> +#include 
>  #include "cgit.h"
>  #include "html.h"
>  #include "ui-shared.h"
> @@ -13,12 +15,39 @@
>  int match_baselen;
>  int match;
>  
> +static char * getMimeFromFile(char *ext) {
> +	static const char * delimiters = " \t\r\n";
> +	char * result = NULL;
> +	FILE * fd;
> +	char line[1024];
> +	char * mimetype;
> +	char * token;
> +
> +	fd = fopen("/etc/mime.types", "r");
> +	if (fd) {
> +		while (fgets(line, sizeof(line), fd)) {
> +			mimetype = strtok(line, delimiters);
> +			if (mimetype && (mimetype[0] != '#')) {
> +				while ((token = strtok(NULL, delimiters))) {
> +					if (!strcasecmp(ext, token)) {
> +						result = xstrdup(mimetype);
> +						goto endloop;
> +					}
> +				}
> +			}
> +		}
> +		endloop: fclose(fd);
> +	}
> +	return result;
> +}
> +
>  static void print_object(const unsigned char *sha1, const char *path)
>  {
>  	enum object_type type;
>  	char *buf, *ext;
>  	unsigned long size;
>  	struct string_list_item *mime;
> +	bool freemime = false;
>  
>  	type = sha1_object_info(sha1, &size);
>  	if (type == OBJ_BAD) {
> @@ -34,9 +63,13 @@ static void print_object(const unsigned char *sha1, const char *path)
>  	ctx.page.mimetype = NULL;
>  	ext = strrchr(path, '.');
>  	if (ext && *(++ext)) {
> -		mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
> -		if (mime)
> -			ctx.page.mimetype = (char *)mime->util;
> +		if (ctx.cfg.mimetype_file && (ctx.page.mimetype = getMimeFromFile(ext))) {
> +			freemime = true;
> +		} else {
> +			mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
> +			if (mime)
> +				ctx.page.mimetype = (char *)mime->util;
> +		}
>  	}
>  	if (!ctx.page.mimetype) {
>  		if (buffer_is_binary(buf, size))
> @@ -50,6 +83,8 @@ static void print_object(const unsigned char *sha1, const char *path)
>  	cgit_print_http_headers(&ctx);
>  	html_raw(buf, size);
>  	match = 1;
> +	if (freemime)
> +		free(ctx.page.mimetype);
>  }
>  
>  static char *buildpath(const char *base, int baselen, const char *path)


-- 
Ferry Huberts



From mailings at hupie.com  Thu Jun 23 02:31:02 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 23 Jun 2011 02:31:02 +0200
Subject: [PATCH 1/1] ui_plain: automatically lookup mimetype when
 mimetype-file is set
Message-ID: <1308789062-13132-1-git-send-email-mailings@hupie.com>

From: Ferry Huberts 

Signed-off-by: Ferry Huberts 
---
 cgit.c       |    2 ++
 cgit.h       |    1 +
 cgitrc.5.txt |   11 +++++++++++
 ui-plain.c   |   44 +++++++++++++++++++++++++++++++++++++++++---
 4 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/cgit.c b/cgit.c
index b7807ad..abb698b 100644
--- a/cgit.c
+++ b/cgit.c
@@ -236,6 +236,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.ssdiff = atoi(value);
 	else if (!strcmp(name, "agefile"))
 		ctx.cfg.agefile = xstrdup(value);
+	else if (!strcmp(name, "mimetype-file"))
+		ctx.cfg.mimetype_file = xstrdup(value);
 	else if (!strcmp(name, "renamelimit"))
 		ctx.cfg.renamelimit = atoi(value);
 	else if (!strcmp(name, "remove-suffix"))
diff --git a/cgit.h b/cgit.h
index bad66f0..db24941 100644
--- a/cgit.h
+++ b/cgit.h
@@ -175,6 +175,7 @@ struct cgit_config {
 	char *index_info;
 	char *logo;
 	char *logo_link;
+	char *mimetype_file;
 	char *module_link;
 	char *project_list;
 	char *readme;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 4721c1e..b1a41b2 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -222,6 +222,17 @@ max-stats::
 	"month", "quarter" and "year". If unspecified, statistics are
 	disabled. Default value: none. See also: "repo.max-stats".
 
+mimetype-file::
+	Specifies the file to use for automatic mimetype lookup. If specified
+	then this field takes precedence over "mimetype.". If unspecified
+	then no such lookup is performed. The typical file to use on a Linux
+	system /etc/mime.types. Default value: none. See also: "mimetype.".
+	The format of the file must comply to:
+	- a comment line is an empty line or a line starting hash (#) optional
+	  preceded by whitespace,
+	- a non-comment line starts with the mimetype (like image/png), followed
+	  by one or more file extensions, all separated by whitespace.
+
 mimetype.::
 	Set the mimetype for the specified filename extension. This is used
 	by the `plain` command when returning blob content.
diff --git a/ui-plain.c b/ui-plain.c
index 733db4d..85ea7da 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -6,6 +6,8 @@
  *   (see COPYING for full license text)
  */
 
+#include 
+#include 
 #include "cgit.h"
 #include "html.h"
 #include "ui-shared.h"
@@ -13,12 +15,42 @@
 int match_baselen;
 int match;
 
+static char *get_mimetype_from_file(const char *filename, const char *ext) {
+	static const char *delimiters = " \t\r\n";
+	char *result = NULL;
+	FILE *fd;
+	char line[1024];
+	char *mimetype;
+	char *token;
+
+	if (!filename)
+		return NULL;
+
+	fd = fopen(filename, "r");
+	if (fd) {
+		while (fgets(line, sizeof(line), fd)) {
+			mimetype = strtok(line, delimiters);
+			if (mimetype && (mimetype[0] != '#')) {
+				while ((token = strtok(NULL, delimiters))) {
+					if (!strcasecmp(ext, token)) {
+						result = xstrdup(mimetype);
+						goto endloop;
+					}
+				}
+			}
+		}
+		endloop: fclose(fd);
+	}
+	return result;
+}
+
 static void print_object(const unsigned char *sha1, const char *path)
 {
 	enum object_type type;
 	char *buf, *ext;
 	unsigned long size;
 	struct string_list_item *mime;
+	bool freemime = false;
 
 	type = sha1_object_info(sha1, &size);
 	if (type == OBJ_BAD) {
@@ -34,9 +66,13 @@ static void print_object(const unsigned char *sha1, const char *path)
 	ctx.page.mimetype = NULL;
 	ext = strrchr(path, '.');
 	if (ext && *(++ext)) {
-		mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
-		if (mime)
-			ctx.page.mimetype = (char *)mime->util;
+		if ((ctx.page.mimetype = get_mimetype_from_file(ctx.cfg.mimetype_file, ext))) {
+			freemime = true;
+		} else {
+			mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
+			if (mime)
+				ctx.page.mimetype = (char *)mime->util;
+		}
 	}
 	if (!ctx.page.mimetype) {
 		if (buffer_is_binary(buf, size))
@@ -50,6 +86,8 @@ static void print_object(const unsigned char *sha1, const char *path)
 	cgit_print_http_headers(&ctx);
 	html_raw(buf, size);
 	match = 1;
+	if (freemime)
+		free(ctx.page.mimetype);
 }
 
 static char *buildpath(const char *base, int baselen, const char *path)
-- 
1.7.5.4




From mailings at hupie.com  Thu Jun 23 02:32:03 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 23 Jun 2011 02:32:03 +0200
Subject: [PATCH 1/1] ui_plain: automatically lookup mimetype
 when	mimetype-file is set
In-Reply-To: <1308789062-13132-1-git-send-email-mailings@hupie.com>
References: <1308789062-13132-1-git-send-email-mailings@hupie.com>
Message-ID: <4E028983.302@hupie.com>

couldn't resist :-)

-- 
Ferry Huberts



From mailings at hupie.com  Thu Jun 23 02:43:52 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 23 Jun 2011 02:43:52 +0200
Subject: [PATCH v3 1/1] commit-links.sh: improve regular expressions
In-Reply-To: <1308775583-22566-1-git-send-email-mailings@hupie.com>
References: <1308775583-22566-1-git-send-email-mailings@hupie.com>
Message-ID: <1308789832-13625-1-git-send-email-mailings@hupie.com>

From: Ferry Huberts 

The default length for sha1 abbreviations in git is 7.

A '#num' at the beginning of the commit message is now
recognised, a ':#num' as well, etc.: a '#num' anywhere
is now converted to a link.

Signed-off-by: Ferry Huberts 
---
 filters/commit-links.sh |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/filters/commit-links.sh b/filters/commit-links.sh
index d2cd2b3..5881952 100755
--- a/filters/commit-links.sh
+++ b/filters/commit-links.sh
@@ -15,11 +15,14 @@
 # CGIT_REPO_CLONE_URL  ( = repo.clone-url setting )
 #
 
+regex=''
+
 # This expression generates links to commits referenced by their SHA1.
 regex=$regex'
-s|\b([0-9a-fA-F]{8,40})\b|\1|g'
+s|\b([0-9a-fA-F]{7,40})\b|\1|g'
+
 # This expression generates links to a fictional bugtracker.
 regex=$regex'
-s| #([0-9]+)\b|#\1|g'
+s|#([0-9]+)\b|#\1|g'
 
 sed -re "$regex"
-- 
1.7.5.4




From mailings at hupie.com  Fri Jun 24 19:23:04 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Fri, 24 Jun 2011 19:23:04 +0200
Subject: [PATCH 1/1] Makefile: fix oversight of not using $(DESTDIR) in
 uninstall
Message-ID: <1308936184-16736-1-git-send-email-mailings@hupie.com>

From: Ferry Huberts 

Signed-off-by: Ferry Huberts 
---
 Makefile |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index f6d6968..538a9f8 100644
--- a/Makefile
+++ b/Makefile
@@ -198,9 +198,9 @@ install-pdf: doc-pdf
 	$(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir)
 
 uninstall:
-	rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
-	rm -f $(CGIT_DATA_PATH)/cgit.css
-	rm -f $(CGIT_DATA_PATH)/cgit.png
+	rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
+	rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
+	rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
 
 uninstall-doc: uninstall-man uninstall-html uninstall-pdf
 
-- 
1.7.5.4




From dejan1 at gmail.com  Sat Jun 25 17:49:28 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Sat, 25 Jun 2011 11:49:28 -0400
Subject: Unable to browse Public repo
In-Reply-To: 
References: 
 
 
 
 <4DFF6C48.3020901@hupie.com>
 
 
 
 
 
 
 
 
Message-ID: 

Thanks, all tests have passed and I am able to see my repo now.

On Wed, Jun 22, 2011 at 5:15 PM, Lars Hjemli  wrote:
> [Could you please not top-post?]
>
> On Mon, Jun 20, 2011 at 22:51, Dejan Tolj  wrote:
>> On Mon, Jun 20, 2011 at 4:43 PM, Lars Hjemli  wrote:
>>> On Mon, Jun 20, 2011 at 21:37, Dejan Tolj  wrote:
>>>> (gdb) r
>>>> Starting program: /var/www/cgi-bin/cgit
>>>> [Thread debugging using libthread_db enabled]
>>>>
>>>> Program received signal SIGSEGV, Segmentation fault.
>>>> 0x0805066e in pthread_key_create ()
>>>> (gdb) bt
>>>> #0 ?0x0805066e in pthread_key_create ()
>>>> #1 ?0x0804bc2c in pthread_key_create ()
>>>> #2 ?0x00826e9c in __libc_start_main () from /lib/libc.so.6
>>>> #3 ?0x0804a4f1 in pthread_key_create ()
>>>> (gdb)
>>>
>>> Hmm, something fishy seems to be going on. How did you build/install
>>> cgit, and on what linux distro and hardware are you running it?
>>>
>> I am running RHEL5.6 on a esx server
>> I pulled cgit from EPEL repo.
>
> Ok, this is a long shot, but could you try the following:
>
> $ git clone git://hjemli.net/pub/git/cgit
> $ cd cgit
> $ make get-git
> $ make test
>
> The last `make` invocation compiles a fresh cgit binary and puts it
> through the cgit test-suite, which hopefully can give us some further
> clues about your cgit issues.
>
> --
> larsh
>



From dejan1 at gmail.com  Tue Jun 28 21:39:20 2011
From: dejan1 at gmail.com (Dejan Tolj)
Date: Tue, 28 Jun 2011 15:39:20 -0400
Subject: Unable to browse Public repo
In-Reply-To: <20110625175654.GJ14016@inocybe.localdomain>
References: <4DFF6C48.3020901@hupie.com>
 
 
 
 
 
 
 
 
 
 <20110625175654.GJ14016@inocybe.localdomain>
Message-ID: 

Hi Todd,
Thanks for maintaining cgit rpm.
I have reverted back to rpm from EPEL v. 0.9-1.el5 instead of trunk.

My problem was with some configs. I am new to git in general and from
some other discussion boards I discovered the correct way to setup a
git repository.
In short, I copied the .git directory to /var/lib/git/myproj.git set
that path for 'repo.path'
and the repo was picked up by cgit.



From mailings at hupie.com  Wed Jun 29 14:53:34 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 29 Jun 2011 14:53:34 +0200
Subject: [PATCH 1/1] Makefile: fix oversight of not using $(DESTDIR) in
 uninstall
In-Reply-To: <1308936184-16736-1-git-send-email-mailings@hupie.com>
References: <1308936184-16736-1-git-send-email-mailings@hupie.com>
Message-ID: <4E0B204E.5020604@hupie.com>

Lars?

On 06/24/2011 07:23 PM, Ferry Huberts wrote:
> From: Ferry Huberts 
> 
> Signed-off-by: Ferry Huberts 
> ---
>  Makefile |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index f6d6968..538a9f8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -198,9 +198,9 @@ install-pdf: doc-pdf
>  	$(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir)
>  
>  uninstall:
> -	rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
> -	rm -f $(CGIT_DATA_PATH)/cgit.css
> -	rm -f $(CGIT_DATA_PATH)/cgit.png
> +	rm -f $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
> +	rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
> +	rm -f $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
>  
>  uninstall-doc: uninstall-man uninstall-html uninstall-pdf
>  


-- 
Ferry Huberts



From mailings at hupie.com  Wed Jun 29 14:53:56 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 29 Jun 2011 14:53:56 +0200
Subject: [PATCH 1/1] ui_plain: automatically lookup mimetype
 when	mimetype-file is set
In-Reply-To: <1308789062-13132-1-git-send-email-mailings@hupie.com>
References: <1308789062-13132-1-git-send-email-mailings@hupie.com>
Message-ID: <4E0B2064.70806@hupie.com>

Lars?

On 06/23/2011 02:31 AM, Ferry Huberts wrote:
> From: Ferry Huberts 
> 
> Signed-off-by: Ferry Huberts 
> ---
>  cgit.c       |    2 ++
>  cgit.h       |    1 +
>  cgitrc.5.txt |   11 +++++++++++
>  ui-plain.c   |   44 +++++++++++++++++++++++++++++++++++++++++---
>  4 files changed, 55 insertions(+), 3 deletions(-)
> 
> diff --git a/cgit.c b/cgit.c
> index b7807ad..abb698b 100644
> --- a/cgit.c
> +++ b/cgit.c
> @@ -236,6 +236,8 @@ void config_cb(const char *name, const char *value)
>  		ctx.cfg.ssdiff = atoi(value);
>  	else if (!strcmp(name, "agefile"))
>  		ctx.cfg.agefile = xstrdup(value);
> +	else if (!strcmp(name, "mimetype-file"))
> +		ctx.cfg.mimetype_file = xstrdup(value);
>  	else if (!strcmp(name, "renamelimit"))
>  		ctx.cfg.renamelimit = atoi(value);
>  	else if (!strcmp(name, "remove-suffix"))
> diff --git a/cgit.h b/cgit.h
> index bad66f0..db24941 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -175,6 +175,7 @@ struct cgit_config {
>  	char *index_info;
>  	char *logo;
>  	char *logo_link;
> +	char *mimetype_file;
>  	char *module_link;
>  	char *project_list;
>  	char *readme;
> diff --git a/cgitrc.5.txt b/cgitrc.5.txt
> index 4721c1e..b1a41b2 100644
> --- a/cgitrc.5.txt
> +++ b/cgitrc.5.txt
> @@ -222,6 +222,17 @@ max-stats::
>  	"month", "quarter" and "year". If unspecified, statistics are
>  	disabled. Default value: none. See also: "repo.max-stats".
>  
> +mimetype-file::
> +	Specifies the file to use for automatic mimetype lookup. If specified
> +	then this field takes precedence over "mimetype.". If unspecified
> +	then no such lookup is performed. The typical file to use on a Linux
> +	system /etc/mime.types. Default value: none. See also: "mimetype.".
> +	The format of the file must comply to:
> +	- a comment line is an empty line or a line starting hash (#) optional
> +	  preceded by whitespace,
> +	- a non-comment line starts with the mimetype (like image/png), followed
> +	  by one or more file extensions, all separated by whitespace.
> +
>  mimetype.::
>  	Set the mimetype for the specified filename extension. This is used
>  	by the `plain` command when returning blob content.
> diff --git a/ui-plain.c b/ui-plain.c
> index 733db4d..85ea7da 100644
> --- a/ui-plain.c
> +++ b/ui-plain.c
> @@ -6,6 +6,8 @@
>   *   (see COPYING for full license text)
>   */
>  
> +#include 
> +#include 
>  #include "cgit.h"
>  #include "html.h"
>  #include "ui-shared.h"
> @@ -13,12 +15,42 @@
>  int match_baselen;
>  int match;
>  
> +static char *get_mimetype_from_file(const char *filename, const char *ext) {
> +	static const char *delimiters = " \t\r\n";
> +	char *result = NULL;
> +	FILE *fd;
> +	char line[1024];
> +	char *mimetype;
> +	char *token;
> +
> +	if (!filename)
> +		return NULL;
> +
> +	fd = fopen(filename, "r");
> +	if (fd) {
> +		while (fgets(line, sizeof(line), fd)) {
> +			mimetype = strtok(line, delimiters);
> +			if (mimetype && (mimetype[0] != '#')) {
> +				while ((token = strtok(NULL, delimiters))) {
> +					if (!strcasecmp(ext, token)) {
> +						result = xstrdup(mimetype);
> +						goto endloop;
> +					}
> +				}
> +			}
> +		}
> +		endloop: fclose(fd);
> +	}
> +	return result;
> +}
> +
>  static void print_object(const unsigned char *sha1, const char *path)
>  {
>  	enum object_type type;
>  	char *buf, *ext;
>  	unsigned long size;
>  	struct string_list_item *mime;
> +	bool freemime = false;
>  
>  	type = sha1_object_info(sha1, &size);
>  	if (type == OBJ_BAD) {
> @@ -34,9 +66,13 @@ static void print_object(const unsigned char *sha1, const char *path)
>  	ctx.page.mimetype = NULL;
>  	ext = strrchr(path, '.');
>  	if (ext && *(++ext)) {
> -		mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
> -		if (mime)
> -			ctx.page.mimetype = (char *)mime->util;
> +		if ((ctx.page.mimetype = get_mimetype_from_file(ctx.cfg.mimetype_file, ext))) {
> +			freemime = true;
> +		} else {
> +			mime = string_list_lookup(&ctx.cfg.mimetypes, ext);
> +			if (mime)
> +				ctx.page.mimetype = (char *)mime->util;
> +		}
>  	}
>  	if (!ctx.page.mimetype) {
>  		if (buffer_is_binary(buf, size))
> @@ -50,6 +86,8 @@ static void print_object(const unsigned char *sha1, const char *path)
>  	cgit_print_http_headers(&ctx);
>  	html_raw(buf, size);
>  	match = 1;
> +	if (freemime)
> +		free(ctx.page.mimetype);
>  }
>  
>  static char *buildpath(const char *base, int baselen, const char *path)


-- 
Ferry Huberts



From sconvey at idirect.net  Wed Jun 29 20:41:42 2011
From: sconvey at idirect.net (Convey, Simon)
Date: Wed, 29 Jun 2011 14:41:42 -0400
Subject: Interposing administrator defined javascript in cgit....
Message-ID: 

Dear cgit devteam,
         We are moving a large CVS rpository to git. ( We did a long mercurial vs git eval, and git won hands down ). CVS  has a web based code brower, and whilst its nowhere near as pretty as cgit,, it has one feature which cgit lacks, and that's an arbitrary file diff.  We implemented this this using javascript, and we've realised that being able to interpose javascript in cgit is a really useful feature. I have added code to cgit to do this, and some example javascript which does useful things.  I tried a git push earlier, but its not accepting pushes. Do you need my IP address ? 206.205.108.*

Here's the added code.....

cgit.c   Added an extra config options to void config_cb(const char *name,const char *value)

          
                else if (!strcmp(name, "javascript"))
                        ctx.cfg.javascript = xstrdup(value);

          
cgit.h    Added the typedef to struct cgit_config
           
                        char *javascript;

ui-shared.c   Added a call to html_include as soon as  is sent.
             
                   if (ctx-cfg.header)
                           html_include(ctx->cfg.header);
                   html_include(ctx-cfg.javascript);

And added a README.js, and example code to a contrib directory, updated cgitrc.5.txt with an example stanza.

If these changes are OK, please you you allow us to push them ?

Many thanks,
Simon Convey
Ahmed Elsabbahy







_____________________________________________________
This electronic message and any files transmitted with it contains
information from iDirect, which may be privileged, proprietary
and/or confidential. It is intended solely for the use of the individual
or entity to whom they are addressed. If you are not the original
recipient or the person responsible for delivering the email to the
intended recipient, be advised that you have received this email
in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you received this email
in error, please delete it and immediately notify the sender.
_____________________________________________________

From mailings at hupie.com  Wed Jun 29 21:54:49 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Wed, 29 Jun 2011 21:54:49 +0200
Subject: Interposing administrator defined javascript in cgit....
In-Reply-To: 
References: 
Message-ID: <4E0B8309.80503@hupie.com>

On 06/29/2011 08:41 PM, Convey, Simon wrote:
> Dear cgit devteam,
>          We are moving a large CVS rpository to git. ( We did a long mercurial vs git eval, and git won hands down ). CVS  has a web based code brower, and whilst its nowhere near as pretty as cgit,, it has one feature which cgit lacks, and that's an arbitrary file diff.  We implemented this this using javascript, and we've realised that being able to interpose javascript in cgit is a really useful feature. I have added code to cgit to do this, and some example javascript which does useful things.  I tried a git push earlier, but its not accepting pushes. Do you need my IP address ? 206.205.108.*
> 
> Here's the added code.....

send patches or publish your code somewhere (like github) please
that's much easier to look at :-)


-- 
Ferry Huberts



From sconvey at idirect.net  Thu Jun 30 20:07:09 2011
From: sconvey at idirect.net (Convey, Simon)
Date: Thu, 30 Jun 2011 14:07:09 -0400
Subject: Interposing administrator defined javascript in cgit.... Patches
 included .....
In-Reply-To: <4E0B8309.80503@hupie.com>
References: 
 <4E0B8309.80503@hupie.com>
Message-ID: 

First patch is the example javascript, second path is changes to C source.


Many thanks,
Simon Convey 

_____________________________________________________
This electronic message and any files transmitted with it contains
information from iDirect, which may be privileged, proprietary
and/or confidential. It is intended solely for the use of the individual
or entity to whom they are addressed. If you are not the original
recipient or the person responsible for delivering the email to the
intended recipient, be advised that you have received this email
in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you received this email
in error, please delete it and immediately notify the sender.
_____________________________________________________

From mailings at hupie.com  Thu Jun 30 22:12:15 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 30 Jun 2011 22:12:15 +0200
Subject: Interposing administrator defined javascript in cgit.... Patches
 included .....
In-Reply-To: 
References: 	<4E0B8309.80503@hupie.com>
 
Message-ID: <4E0CD89F.8080804@hupie.com>

use the force luke....

git help format-patch
git help send-email



1. make sure your patches are on a branch that is rebased on master
2. git format-patch -C --find-copies-harder -n --cover-letter master --
3. git send-email --to=cgit at hjemli.net *.patch


On 06/30/2011 08:07 PM, Convey, Simon wrote:
> First patch is the example javascript, second path is changes to C source.
> 
> 
> Many thanks,
> Simon Convey 
> 

> _____________________________________________________
> This electronic message and any files transmitted with it contains
> information from iDirect, which may be privileged, proprietary
> and/or confidential. It is intended solely for the use of the individual
> or entity to whom they are addressed. If you are not the original
> recipient or the person responsible for delivering the email to the
intended recipient, be advised that you have received this email
> in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you received this email
> in error, please delete it and immediately notify the sender.
> _____________________________________________________ >
> 
> 
> 
> _______________________________________________
> cgit mailing list
> cgit at hjemli.net
> http://hjemli.net/mailman/listinfo/cgit

grtz

-- 
Ferry Huberts



From mailings at hupie.com  Thu Jun 30 22:13:35 2011
From: mailings at hupie.com (Ferry Huberts)
Date: Thu, 30 Jun 2011 22:13:35 +0200
Subject: Interposing administrator defined javascript in cgit.... Patches
 included .....
In-Reply-To: <4E0CD89F.8080804@hupie.com>
References: 	<4E0B8309.80503@hupie.com>
 
 <4E0CD89F.8080804@hupie.com>
Message-ID: <4E0CD8EF.9040005@hupie.com>



On 06/30/2011 10:12 PM, Ferry Huberts wrote:
> use the force luke....
> 
> git help format-patch
> git help send-email
> 
> 
> 
> 1. make sure your patches are on a branch that is rebased on master
> 2. git format-patch -C --find-copies-harder -n --cover-letter master --

2b. edit the cover letter patch file: fill in subject and description


> 3. git send-email --to=cgit at hjemli.net *.patch
> 
> 

grtz

-- 
Ferry Huberts