summaryrefslogtreecommitdiffabout
path: root/ui-snapshot.c
Unidiff
Diffstat (limited to 'ui-snapshot.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-snapshot.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 84bf8f7..7076b50 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -64,53 +64,53 @@ static const struct snapshot_archive_t {
64 { ".tar", "application/x-tar", write_tar_archive } 64 { ".tar", "application/x-tar", write_tar_archive }
65}; 65};
66 66
67void cgit_print_snapshot(struct cacheitem *item, const char *hex, 67void cgit_print_snapshot(struct cacheitem *item, const char *hex,
68 const char *prefix, const char *filename) 68 const char *prefix, const char *filename)
69{ 69{
70 int fnl = strlen(filename); 70 int fnl = strlen(filename);
71 int f; 71 int f;
72 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { 72 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) {
73 const struct snapshot_archive_t* sat = &snapshot_archives[f]; 73 const struct snapshot_archive_t* sat = &snapshot_archives[f];
74 int sl = strlen(sat->suffix); 74 int sl = strlen(sat->suffix);
75 if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix)) 75 if(fnl<sl || strcmp(&filename[fnl-sl],sat->suffix))
76 continue; 76 continue;
77 77
78 struct archiver_args args; 78 struct archiver_args args;
79 struct commit *commit; 79 struct commit *commit;
80 unsigned char sha1[20]; 80 unsigned char sha1[20];
81 81
82 if(get_sha1(hex, sha1)) { 82 if(get_sha1(hex, sha1)) {
83 cgit_print_error(fmt("Bad object id: %s", hex)); 83 cgit_print_error(fmt("Bad object id: %s", hex));
84 return; 84 return;
85 } 85 }
86 commit = lookup_commit_reference(sha1); 86 commit = lookup_commit_reference(sha1);
87 87
88 if(!commit) { 88 if(!commit) {
89 cgit_print_error(fmt("Not a commit reference: %s", hex)); 89 cgit_print_error(fmt("Not a commit reference: %s", hex));
90 return;; 90 return;;
91 } 91 }
92 92
93 memset(&args,0,sizeof(args)); 93 memset(&args,0,sizeof(args));
94 args.base = fmt("%s/", prefix); 94 args.base = fmt("%s/", prefix);
95 args.tree = commit->tree; 95 args.tree = commit->tree;
96 96
97 cgit_print_snapshot_start(sat->mimetype, filename, item); 97 cgit_print_snapshot_start(sat->mimetype, filename, item);
98 (*sat->write_func)(&args); 98 (*sat->write_func)(&args);
99 return; 99 return;
100 } 100 }
101 cgit_print_error(fmt("Unsupported snapshot format: %s", filename)); 101 cgit_print_error(fmt("Unsupported snapshot format: %s", filename));
102} 102}
103 103
104void cgit_print_snapshot_links(const char *repo,const char *hex) 104void cgit_print_snapshot_links(const char *repo,const char *hex)
105{ 105{
106 char *filename; 106 char *filename;
107 int f; 107 int f;
108 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) { 108 for(f=0;f<(sizeof(snapshot_archives)/sizeof(*snapshot_archives));++f) {
109 const struct snapshot_archive_t* sat = &snapshot_archives[f]; 109 const struct snapshot_archive_t* sat = &snapshot_archives[f];
110 filename = fmt("%s-%s%s",repo,hex,sat->suffix); 110 filename = fmt("%s-%s%s",repo,hex,sat->suffix);
111 htmlf("<a href='%s'>%s</a><br/>", 111 htmlf("<a href='%s'>%s</a><br/>",
112 cgit_pageurl(repo,"snapshot", 112 cgit_fileurl(repo,"snapshot",filename,
113 fmt("id=%s&amp;name=%s",hex,filename)), filename); 113 fmt("id=%s&amp;name=%s",hex,filename)), filename);
114 } 114 }
115} 115}
116/* vim:set sw=8: */ 116/* vim:set sw=8: */