aboutsummaryrefslogtreecommitdiff
path: root/ui-snapshot.c
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index d157222..556d3ed 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -6,8 +6,6 @@
* (see COPYING for full license text)
*/
-#define USE_THE_REPOSITORY_VARIABLE
-
#include "cgit.h"
#include "ui-snapshot.h"
#include "html.h"
@@ -15,32 +13,32 @@
static int write_archive_type(const char *format, const char *hex, const char *prefix)
{
- struct strvec argv = STRVEC_INIT;
+ struct argv_array argv = ARGV_ARRAY_INIT;
const char **nargv;
int result;
- strvec_push(&argv, "snapshot");
- strvec_push(&argv, format);
+ argv_array_push(&argv, "snapshot");
+ argv_array_push(&argv, format);
if (prefix) {
struct strbuf buf = STRBUF_INIT;
strbuf_addstr(&buf, prefix);
strbuf_addch(&buf, '/');
- strvec_push(&argv, "--prefix");
- strvec_push(&argv, buf.buf);
+ argv_array_push(&argv, "--prefix");
+ argv_array_push(&argv, buf.buf);
strbuf_release(&buf);
}
- strvec_push(&argv, hex);
+ argv_array_push(&argv, hex);
/*
* Now we need to copy the pointers to arguments into a new
* structure because write_archive will rearrange its arguments
* which may result in duplicated/missing entries causing leaks
- * or double-frees in strvec_clear.
+ * or double-frees in argv_array_clear.
*/
- nargv = xmalloc(sizeof(char *) * (argv.nr + 1));
- /* strvec guarantees a trailing NULL entry. */
- memcpy(nargv, argv.v, sizeof(char *) * (argv.nr + 1));
+ nargv = xmalloc(sizeof(char *) * (argv.argc + 1));
+ /* argv_array guarantees a trailing NULL entry. */
+ memcpy(nargv, argv.argv, sizeof(char *) * (argv.argc + 1));
- result = write_archive(argv.nr, nargv, NULL, the_repository, NULL, 0);
- strvec_clear(&argv);
+ result = write_archive(argv.argc, nargv, NULL, the_repository, NULL, 0);
+ argv_array_clear(&argv);
free(nargv);
return result;
}
@@ -119,7 +117,7 @@ const struct object_id *cgit_snapshot_get_sig(const char *ref,
struct notes_tree *tree;
struct object_id oid;
- if (repo_get_oid(the_repository, ref, &oid))
+ if (get_oid(ref, &oid))
return NULL;
tree = &snapshot_sig_notes[f - &cgit_snapshot_formats[0]];
@@ -158,7 +156,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format,
{
struct object_id oid;
- if (repo_get_oid(the_repository, hex, &oid)) {
+ if (get_oid(hex, &oid)) {
cgit_print_error_page(404, "Not found",
"Bad object id: %s", hex);
return 1;
@@ -192,7 +190,7 @@ static int write_sig(const struct cgit_snapshot_format *format,
return 0;
}
- buf = odb_read_object(the_repository->objects, note, &type, &size);
+ buf = read_object_file(note, &type, &size);
if (!buf) {
cgit_print_error_page(404, "Not found", "Not found");
return 0;
@@ -232,7 +230,7 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo,
strbuf_addstr(&snapshot, filename);
strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix));
- if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
reponame = cgit_snapshot_prefix(repo);
@@ -244,15 +242,15 @@ static const char *get_ref_from_filename(const struct cgit_repo *repo,
strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0);
}
- if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
strbuf_insert(&snapshot, 0, "v", 1);
- if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
strbuf_splice(&snapshot, 0, 1, "V", 1);
- if (repo_get_oid(the_repository, snapshot.buf, &oid) == 0)
+ if (get_oid(snapshot.buf, &oid) == 0)
goto out;
result = 0;