diff options
author | Lars Hjemli | 2008-10-05 21:12:08 +0200 |
---|---|---|
committer | Lars Hjemli | 2008-10-05 21:12:08 +0200 |
commit | 8b5fc6de036cf159ffa61a55158044749bd6f4d9 (patch) | |
tree | c1accdd309b0af0f17fd97e91b8980185db79b21 | |
parent | ui-shared: use html_url_path() to get properly escaped url in form action (diff) | |
download | cgit-8b5fc6de036cf159ffa61a55158044749bd6f4d9.tar.gz cgit-8b5fc6de036cf159ffa61a55158044749bd6f4d9.zip |
ui-shared: generate proper links in cgit_object_link()
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | ui-shared.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/ui-shared.c b/ui-shared.c index 1e12529..a959224 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -359,29 +359,21 @@ void cgit_patch_link(char *name, char *title, char *class, char *head, | |||
359 | 359 | ||
360 | void cgit_object_link(struct object *obj) | 360 | void cgit_object_link(struct object *obj) |
361 | { | 361 | { |
362 | char *page, *arg, *url; | 362 | char *page, *rev, *name; |
363 | 363 | ||
364 | if (obj->type == OBJ_COMMIT) { | 364 | if (obj->type == OBJ_COMMIT) { |
365 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, | 365 | cgit_commit_link(fmt("commit %s", sha1_to_hex(obj->sha1)), NULL, NULL, |
366 | ctx.qry.head, sha1_to_hex(obj->sha1)); | 366 | ctx.qry.head, sha1_to_hex(obj->sha1)); |
367 | return; | 367 | return; |
368 | } else if (obj->type == OBJ_TREE) { | 368 | } else if (obj->type == OBJ_TREE) |
369 | page = "tree"; | 369 | page = "tree"; |
370 | arg = "id"; | 370 | else if (obj->type == OBJ_TAG) |
371 | } else if (obj->type == OBJ_TAG) { | ||
372 | page = "tag"; | 371 | page = "tag"; |
373 | arg = "id"; | 372 | else |
374 | } else { | ||
375 | page = "blob"; | 373 | page = "blob"; |
376 | arg = "id"; | 374 | rev = sha1_to_hex(obj->sha1); |
377 | } | 375 | name = fmt("%s %s", typename(obj->type), rev); |
378 | 376 | reporevlink(page, name, NULL, NULL, ctx.qry.head, rev, NULL); | |
379 | url = cgit_pageurl(ctx.qry.repo, page, | ||
380 | fmt("%s=%s", arg, sha1_to_hex(obj->sha1))); | ||
381 | html_link_open(url, NULL, NULL); | ||
382 | htmlf("%s %s", typename(obj->type), | ||
383 | sha1_to_hex(obj->sha1)); | ||
384 | html_link_close(); | ||
385 | } | 377 | } |
386 | 378 | ||
387 | void cgit_print_date(time_t secs, char *format, int local_time) | 379 | void cgit_print_date(time_t secs, char *format, int local_time) |