commit - 17e0f8afea3d95e8055318764a21d75fd8acb938
commit + d6aafba8ef79a513680838efe5739bb56e116c3d
blob - 667de1ed8c7587e8a3413be3fbbca4f143b31d90
blob + 2a53abe53d796a041d06addd056ad983393fc759
--- gotwebd/got_operations.c
+++ gotwebd/got_operations.c
const struct got_error *
got_open_blob_for_output(struct got_blob_object **blob, int *fd,
- int *binary, struct request *c)
+ int *binary, struct request *c, const char *directory, const char *file,
+ const char *commitstr)
{
const struct got_error *error = NULL;
- struct transport *t = c->t;
- struct got_repository *repo = t->repo;
- struct querystring *qs = c->t->qs;
+ struct got_repository *repo = c->t->repo;
struct got_commit_object *commit = NULL;
struct got_object_id *commit_id = NULL;
struct got_reflist_head refs;
*fd = -1;
*binary = 0;
- if (asprintf(&path, "%s%s%s", qs->folder ? qs->folder : "",
- qs->folder ? "/" : "", qs->file) == -1) {
+ error = got_ref_list(&refs, repo, "refs/heads",
+ got_ref_cmp_by_name, NULL);
+ if (error)
+ goto done;
+
+ if (asprintf(&path, "%s%s%s", directory ? directory : "",
+ directory ? "/" : "", file) == -1) {
error = got_error_from_errno("asprintf");
goto done;
}
if (error)
goto done;
- error = got_repo_match_object_id(&commit_id, NULL, qs->commit,
+ if (commitstr == NULL)
+ commitstr = "HEAD";
+
+ error = got_repo_match_object_id(&commit_id, NULL, commitstr,
GOT_OBJ_TYPE_COMMIT, &refs, repo);
if (error)
goto done;
*blob = NULL;
}
+ got_ref_list_free(&refs);
free(in_repo_path);
free(commit_id);
free(path);
blob - 5a9e5219a1429b6a682151e03ff69c6f506f26b2
blob + 48e5696942f0483cf0bac6ae07df6e03d218ee3e
--- gotwebd/gotweb.c
+++ gotwebd/gotweb.c
goto err;
error = got_open_blob_for_output(&c->t->blob, &c->t->fd,
- &binary, c);
+ &binary, c, qs->folder, qs->file, qs->commit);
if (error)
goto err;
}
blob - c480587a135af9f8131850e847e558875813395f
blob + 4efd134dfaaf502699cb7769db9b07549b2ee41b
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
int got_output_repo_tree(struct request *, char **,
int (*)(struct template *, struct got_tree_entry *));
const struct got_error *got_open_blob_for_output(struct got_blob_object **,
- int *, int *, struct request *);
+ int *, int *, struct request *, const char *, const char *, const char *);
int got_output_blob_by_lines(struct template *, struct got_blob_object *,
int (*)(struct template *, const char *, size_t));
const struct got_error *got_output_file_blame(struct request *,
blob - 71b947250c088a0e8583d92979d83beeb5f851d2
blob + ccfb72d73ff3acccb9daee5236e0ef30544a3d88
--- gotwebd/pages.tmpl
+++ gotwebd/pages.tmpl
const struct got_error *error;
struct request *c = tp->tp_arg;
struct transport *t = c->t;
+ struct querystring *qs = t->qs;
struct repo_commit *rc = TAILQ_FIRST(&t->repo_commits);
struct gotweb_url url;
char *readme = NULL;
<table id="tree">
{{ render got_output_repo_tree(c, &readme, gotweb_render_tree_item) }}
</table>
- {!/* a commit id is *required* */!}
- {{ if readme && t->qs->commit }}
+ {{ if readme }}
{!
- /* sigh... */
- t->qs->file = readme;
- error = got_open_blob_for_output(&t->blob, &t->fd, &binary, c);
- t->qs->file = NULL;
-
+ error = got_open_blob_for_output(&t->blob, &t->fd, &binary, c,
+ qs->folder, readme, qs->commit);
if (error) {
free(readme);
return (-1);