diff options
author | John Keeping <john@keeping.me.uk> | 2013-03-02 21:32:12 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2013-03-03 00:38:03 (JST) |
commit | 2ab1cd9f3b796fa679c9d1b1ce338aaa2b0b1e53 (patch) | |
tree | aa51e514b7858f51d1141f613b57815b2fba5bcb /ui-snapshot.c | |
parent | c1633c6befb6762e1ac9434a29980e4df5ffee21 (diff) | |
download | cgit-2ab1cd9f3b796fa679c9d1b1ce338aaa2b0b1e53.zip cgit-2ab1cd9f3b796fa679c9d1b1ce338aaa2b0b1e53.tar.gz |
Update git to v1.7.7.7
This release changes the archive interface so that we now need to pass
argv into write_archive().
Signed-off-by: John Keeping <john@keeping.me.uk>
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r-- | ui-snapshot.c | 60 |
1 files changed, 35 insertions, 25 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c index 47432bd..7374d9d 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c | |||
@@ -11,7 +11,31 @@ | |||
11 | #include "html.h" | 11 | #include "html.h" |
12 | #include "ui-shared.h" | 12 | #include "ui-shared.h" |
13 | 13 | ||
14 | static int write_compressed_tar_archive(struct archiver_args *args, char *filter_argv[]) | 14 | static int write_archive_type(const char *format, const char *hex, const char *prefix) |
15 | { | ||
16 | struct argv_array argv = ARGV_ARRAY_INIT; | ||
17 | argv_array_push(&argv, format); | ||
18 | if (prefix) { | ||
19 | argv_array_push(&argv, "--prefix"); | ||
20 | argv_array_push(&argv, fmt("%s/", prefix)); | ||
21 | } | ||
22 | argv_array_push(&argv, hex); | ||
23 | return write_archive(argv.argc, argv.argv, NULL, 1, NULL, 0); | ||
24 | } | ||
25 | |||
26 | static int write_tar_archive(const char *hex, const char *prefix) | ||
27 | { | ||
28 | return write_archive_type("--format=tar", hex, prefix); | ||
29 | } | ||
30 | |||
31 | static int write_zip_archive(const char *hex, const char *prefix) | ||
32 | { | ||
33 | return write_archive_type("--format=zip", hex, prefix); | ||
34 | } | ||
35 | |||
36 | static int write_compressed_tar_archive(const char *hex, | ||
37 | const char *prefix, | ||
38 | char *filter_argv[]) | ||
15 | { | 39 | { |
16 | int rv; | 40 | int rv; |
17 | struct cgit_filter f; | 41 | struct cgit_filter f; |
@@ -19,27 +43,27 @@ static int write_compressed_tar_archive(struct archiver_args *args, char *filter | |||
19 | f.cmd = filter_argv[0]; | 43 | f.cmd = filter_argv[0]; |
20 | f.argv = filter_argv; | 44 | f.argv = filter_argv; |
21 | cgit_open_filter(&f); | 45 | cgit_open_filter(&f); |
22 | rv = write_tar_archive(args); | 46 | rv = write_tar_archive(hex, prefix); |
23 | cgit_close_filter(&f); | 47 | cgit_close_filter(&f); |
24 | return rv; | 48 | return rv; |
25 | } | 49 | } |
26 | 50 | ||
27 | static int write_tar_gzip_archive(struct archiver_args *args) | 51 | static int write_tar_gzip_archive(const char *hex, const char *prefix) |
28 | { | 52 | { |
29 | char *argv[] = { "gzip", "-n", NULL }; | 53 | char *argv[] = { "gzip", "-n", NULL }; |
30 | return write_compressed_tar_archive(args, argv); | 54 | return write_compressed_tar_archive(hex, prefix, argv); |
31 | } | 55 | } |
32 | 56 | ||
33 | static int write_tar_bzip2_archive(struct archiver_args *args) | 57 | static int write_tar_bzip2_archive(const char *hex, const char *prefix) |
34 | { | 58 | { |
35 | char *argv[] = { "bzip2", NULL }; | 59 | char *argv[] = { "bzip2", NULL }; |
36 | return write_compressed_tar_archive(args, argv); | 60 | return write_compressed_tar_archive(hex, prefix, argv); |
37 | } | 61 | } |
38 | 62 | ||
39 | static int write_tar_xz_archive(struct archiver_args *args) | 63 | static int write_tar_xz_archive(const char *hex, const char *prefix) |
40 | { | 64 | { |
41 | char *argv[] = { "xz", NULL }; | 65 | char *argv[] = { "xz", NULL }; |
42 | return write_compressed_tar_archive(args, argv); | 66 | return write_compressed_tar_archive(hex, prefix, argv); |
43 | } | 67 | } |
44 | 68 | ||
45 | const struct cgit_snapshot_format cgit_snapshot_formats[] = { | 69 | const struct cgit_snapshot_format cgit_snapshot_formats[] = { |
@@ -71,34 +95,20 @@ static int make_snapshot(const struct cgit_snapshot_format *format, | |||
71 | const char *hex, const char *prefix, | 95 | const char *hex, const char *prefix, |
72 | const char *filename) | 96 | const char *filename) |
73 | { | 97 | { |
74 | struct archiver_args args; | ||
75 | struct commit *commit; | ||
76 | unsigned char sha1[20]; | 98 | unsigned char sha1[20]; |
77 | 99 | ||
78 | if(get_sha1(hex, sha1)) { | 100 | if (get_sha1(hex, sha1)) { |
79 | cgit_print_error(fmt("Bad object id: %s", hex)); | 101 | cgit_print_error(fmt("Bad object id: %s", hex)); |
80 | return 1; | 102 | return 1; |
81 | } | 103 | } |
82 | commit = lookup_commit_reference(sha1); | 104 | if (!lookup_commit_reference(sha1)) { |
83 | if(!commit) { | ||
84 | cgit_print_error(fmt("Not a commit reference: %s", hex)); | 105 | cgit_print_error(fmt("Not a commit reference: %s", hex)); |
85 | return 1; | 106 | return 1; |
86 | } | 107 | } |
87 | memset(&args, 0, sizeof(args)); | ||
88 | if (prefix) { | ||
89 | args.base = fmt("%s/", prefix); | ||
90 | args.baselen = strlen(prefix) + 1; | ||
91 | } else { | ||
92 | args.base = ""; | ||
93 | args.baselen = 0; | ||
94 | } | ||
95 | args.tree = commit->tree; | ||
96 | args.time = commit->date; | ||
97 | args.compression_level = Z_DEFAULT_COMPRESSION; | ||
98 | ctx.page.mimetype = xstrdup(format->mimetype); | 108 | ctx.page.mimetype = xstrdup(format->mimetype); |
99 | ctx.page.filename = xstrdup(filename); | 109 | ctx.page.filename = xstrdup(filename); |
100 | cgit_print_http_headers(&ctx); | 110 | cgit_print_http_headers(&ctx); |
101 | format->write_func(&args); | 111 | format->write_func(hex, prefix); |
102 | return 0; | 112 | return 0; |
103 | } | 113 | } |
104 | 114 | ||