From: hjemli at gmail.com (Lars Hjemli)
Subject: clone url generation issue
Date: Tue, 24 May 2011 00:41:00 +0200 [thread overview]
Message-ID: <BANLkTikioicDc97g26Awazug6OK2vh+=cw@mail.gmail.com> (raw)
In-Reply-To: <loom.20110506T055454-770@post.gmane.org>
On Fri, May 6, 2011 at 06:03, chris <jugg at hotmail.com> wrote:
> Julius Plenz <plenz at ...> writes:
>> * chris <jugg at ...> [2011-05-04 13:56]:
>> > git at ...:/<project>
>> >
>> > Notice the erroneous forward slash being inserted between the
>> > clone-prefix and project name.
>>
>> As far as I can see the print_url() function is responsible
>> (ui-summary.c), which does a simple fmt("%s/%s", base, suffix). So
>> you'd have to do some patching there in order to support that short
>> notion you're using.
>
> From my reading of the code, that concatenation is only used when a url-prefix
> is defined. ?In which case, simply changing the line from:
>
> ?base = fmt("%s/%s", base, suffix);
>
> to
>
> ?base = fmt("%s%s", base, suffix);
>
> allowing the forward slash to be specified as part of the prefix insetad.
>
Such a change would correctly fix your problem, but it would break
existing installations. I think a better solution is to introduce a
new setting, clone-url, which is adopted by each repo during
config/scanning and which supports expansion of environment variables
like $CGIT_REPO_NAME. Maybe something like this untested (and
gmail-mangled) patch:
diff --git a/cgit.c b/cgit.c
index 6be3754..b651843 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."))
@@ -463,6 +465,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
cgit_print_docend();
return 1;
}
+ cgit_prepare_env(ctx->repo);
return 0;
}
diff --git a/cgit.h b/cgit.h
index caa9d8e..21f4815 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;
@@ -319,6 +320,8 @@ extern const char *cgit_repobasename(const char *reponame);
extern int cgit_parse_snapshots_mask(const char *str);
+extern void cgit_prepare_env(struct cgit_repo *repo);
+
extern int cgit_open_filter(struct cgit_filter *filter, struct
cgit_repo * repo);
extern int cgit_close_filter(struct cgit_filter *filter);
diff --git a/shared.c b/shared.c
index be2ae59..af1f403 100644
--- a/shared.c
+++ b/shared.c
@@ -66,6 +66,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->max_stats = ctx.cfg.max_stats;
ret->module_link = ctx.cfg.module_link;
ret->readme = ctx.cfg.readme;
+ ret->clone_url = ctx.cfg.clone_url;
ret->mtime = -1;
ret->about_filter = ctx.cfg.about_filter;
ret->commit_filter = ctx.cfg.commit_filter;
@@ -374,7 +375,8 @@ typedef struct {
char * value;
} cgit_env_var;
-static void prepare_env(struct cgit_repo * repo) {
+void cgit_prepare_env(struct cgit_repo *repo)
+{
cgit_env_var env_vars[] = {
{ .name = "CGIT_REPO_URL", .value = repo->url },
{ .name = "CGIT_REPO_NAME", .value = repo->name },
@@ -406,8 +408,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-summary.c b/ui-summary.c
index 1e9a1b6..d8a745a 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("</table>");
--
larsh
prev parent reply other threads:[~2011-05-23 22:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 11:53 jugg
2011-05-05 14:58 ` plenz
2011-05-06 4:03 ` jugg
2011-05-06 4:07 ` jugg
2011-05-23 22:41 ` hjemli [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='BANLkTikioicDc97g26Awazug6OK2vh+=cw@mail.gmail.com' \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).