summaryrefslogtreecommitdiffstatshomepage
path: root/ui-snapshot.c (unfollow)
Commit message (Collapse)AuthorLines
2015-08-14snapshot: don't reimplement cgit_print_error_page()John Keeping-17/+4
cgit_print_error_page() has the advantage that it sets a suitable HTTP status code for the response. Note that setting "mimetype" is redundant here since it cannot have changed since being initialized in cgit.c::prepare_context(), so we do not need to worry that cgit_print_error_page() does not set it. Signed-off-by: John Keeping <john@keeping.me.uk>
2015-08-14snapshot: use cgit_print_error_page() for HTTP status codesJohn Keeping-2/+4
This is a bugfix as well as an improvement to the HTTP status code handling since previously we would not print HTTP headers on any of these code paths. Signed-off-by: John Keeping <john@keeping.me.uk>
2015-08-14snapshot: use cgit_print_error_page() instead of html_status()John Keeping-1/+1
This provides a formatted error response rather than a simple HTTP error. Signed-off-by: John Keeping <john@keeping.me.uk>
2015-01-28Add Etags for snapshotsJanus-0/+1
2014-06-28git: update for git 2.0Christian Hesse-2/+2
prefixcmp() and suffixcmp() have been remove, functionality is now provided by starts_with() and ends_with(). Retrurn values have been changed, so instead of just renaming we have to fix logic. Everything else looks just fine.
2014-02-21Remove unused parameter from cgit_print_snapshot()Lukas Fleischer-1/+1
2014-01-17Switch to exclusively using global ctxLukas Fleischer-4/+4
Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2014-01-14filter: add interface layerJohn Keeping-6/+5
Change the existing cgit_{open,close,fprintf}_filter functions to delegate to filter-specific implementations accessed via function pointers on the cgit_filter object. We treat the "exec" filter type slightly specially here by putting its structure definition in the header file and providing an "init" function to set up the function pointers. This is required so that the ui-snapshot.c code that applies a compression filter can continue to use the filter interface to do so. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-01-12ui-snapshot: set unused cgit_filter fields to zeroJohn Keeping-4/+4
By switching the assignment of fields in the cgit_filter structure to use designated initializers, the compiler will initialize all other fields to their default value. This will be needed when we add the extra_args field in the next patch. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-01-10ui-snapshot.c: Do not reinvent suffixcmp()Lukas Fleischer-6/+1
Use suffixcmp() from Git instead of reimplementing it. This is a preparation for moving to ends_with() in Git 1.8.6. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2014-01-08Update copyright informationLukas Fleischer-2/+1
* Name "cgit Development Team" as copyright holder to avoid listing every single developer. * Update copyright ranges. Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
2013-05-25cgit.c: Do not reset HOME after unsetting it.Jason A. Donenfeld-9/+0
The number of odd cases in which git will try to read config is far too great to keep putting a bandaid over each one, so we'll just unset it. If it turns out that scripts really liked to know about $HOME, we can always reset it in the filter forks. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-04-30ui-snapshot: do not access $HOMEJason A. Donenfeld-0/+9
It's a bit tedious to have to do this here too. If we encounter other issues with $HOME down the line, I'll look into adding some nice utility functions to handle this, or perhaps giving up on the hope that we could keep $HOME defined for scripts. This commit additionally adds a test case, should the issue surface again. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-04-10ui-snapshot.c: Prepend "V" when guessing ref namesLukas Fleischer-2/+6
In cgit_print_snapshot_links() we strip leading "v" and "V", while we currently only prepend a lower case "v" when parsing a snapshot file name. This results in broken snapshot links for tags that start with an upper case "V". Avoid this by prepending a "V" as a fallback. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-04-08use struct strbuf instead of static buffersJohn Keeping-17/+43
Use "struct strbuf" from Git to remove the limit on file path length. Notes on scan-tree: This is slightly involved since I decided to pass the strbuf into add_repo() and modify if whenever a new file name is required, which should avoid any extra allocations within that function. The pattern there is to append the filename, use it and then reset the buffer to its original length (retaining a trailing '/'). Notes on ui-snapshot: Since write_archive modifies the argv array passed to it we copy the argv_array values into a new array of char* and then free the original argv_array structure and the new array without worrying about what the values now look like. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-04-08Convert cgit_print_error to a variadic functionJohn Keeping-6/+10
This removes many uses of "fmt" which uses a fixed size static pool of fixed size buffers. Instead of relying on these, we now pass around argument lists for as long as possible before using a strbuf to render content of an arbitrary size. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-04-08Always #include corresponding .h in .c filesJohn Keeping-0/+1
While doing this, remove declarations from header files where the corresponding definition is declared "static" in order to avoid build errors. Also re-order existing headers in ui-*.c so that the file-specific header always comes immediately after "cgit.h", helping with future consistency. Signed-off-by: John Keeping <john@keeping.me.uk>
2013-03-04Mark several functions/variables staticLukas Fleischer-1/+1
Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-snapshot.c: Fill argv[0] with dummy.Jason A. Donenfeld-0/+1
parse_archive_args does not pass PARSE_OPT_KEEP_ARGV0 to parse_args, which means the first argument will be discarded, as though it were a function being called from the command-line. Thus, we fill argv[0] with a dummy argument to prevent this from happening. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-03-04White space around control verbs.Jason A. Donenfeld-2/+2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-03-02Update git to v1.7.7.7John Keeping-25/+35
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>
2012-09-27ui-snapshot: pass -n to gzip, to suppress timestampJason A. Donenfeld-8/+10
Since cgit snapshots of tags are often used for releases, we don't want the rarely used feature of the gzip compressor that includes an embedded timestamp into the archive, since this makes each tarball of the same (potentially signed) tag different. This commit refactors the archive handling code a bit so that each different format is able to run with an arbitrary argv for the filter.
2011-06-13cgit.c: always setup cgit repo environment variablesLars Hjemli-1/+1
When cgit learned to setup environment variables for certain repo settings before invoking a filter process, the setup occurred inside cgit_open_filter(). This patch moves the setup out of cgit_open_filter() and into prepare_repo_cmd() to prepare for additional uses of these variables. Reviewed-by: Ferry Huberts <mailings@hupie.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-06-02ui-snapshot.c: remove debug cruftLars Hjemli-2/+0
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2011-03-26cgit_open_filter: also take the repo as a parameterFerry Huberts-1/+1
To prepare for handing repo configuration to the filter script that is executed. Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-09-01ui-snapshot: actually compress zip archivesLars Hjemli-0/+1
Since cgit linked with git-1.6.0 all zip archives has been uncompressed. This patch fixes the issue by specifying Z_DEFAULT_COMPRESSION. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-12-08Add .tar.xz-snapshot supportAndreas Wiese-4/+10
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-31ui-snapshot: use cgit_{open|close}_filter() to execute compressorsLars Hjemli-28/+7
This simplifies the code in ui-snapshot.c and makes the test-suite verify the new filter-functions. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-03-15ui-snapshot: avoid segfault when no filename is specifiedLars Hjemli-6/+17
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-12-28return 404 if snapshot is not foundNatanael Copa-3/+5
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-12-26ui-snapshot.c: change mime-type for tar.gz and tar.bz2Lars Hjemli-2/+2
The updated mime-types seems to work better than the old ones with both safari and firefox. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-12-01ui-snapshot: improve extraction of revision from snapshot nameLars Hjemli-43/+37
The modified get_ref_from_filename() supports the following snapshot formats: * $REV.$EXT * $REPO[-_]*v?$REV.$EXT This implies that the following urls will retrieve the expected revision: * http://hjemli.net/git/cgit/snapshot/v0.8.1.tar.gz * http://hjemli.net/git/cgit/snapshot/0.8.1.tar.gz * http://hjemli.net/git/cgit/snapshot/cgit-0.8.1.tar.gz * http://hjemli.net/git/cgit/snapshot/cgit-140012d7a8.tar.gz Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-30Set prefix in snapshots when using dwimmeryNatanael Copa-2/+12
This patch sets the directory prefix in archives to be the filename, excluding the suffix (.tar.gz, .tar.bz2 etc). The patch also removes the prefix parameter in cgit_print_snapshot() as the prefix might differ. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-10-11ui-snapshot: add dwimmeryLars Hjemli-13/+81
When downloading a snapshot, the snapshot name will often contain the repo name combined with a tag. This patch tries to exploit this so that the correct revision is downloaded even if no specific revision is specified. PS: this only occurs if neither 'h' nor 'id' is specified in the query- string. PPS: this also fixes a bug which occurs when trying to download a filename with an unsupported suffix: it used to try to print an error message to the user but failed since it didn't prepare the output properly. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-10-05ui-snapshot.c: specify archiver_args.baselenLars Hjemli-1/+7
The struct member was introduces in git commit d53fe8187c38, but the cgit testsuite failed to detect that cgit always generated archives without prefixes, i.e. the result from cgit_repobasename was ignored. This fixes the bug and the testsuite. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-24Add ui-shared.hLars Hjemli-0/+1
This is finally a proper headerfile for the shared ui-functions which used to reside in cgit.h Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-24Refactor snapshot supportLars Hjemli-85/+39
The snapshot support needs to be split between output- and config-related functions to get the layering between shared.c and ui-*.c right. There is also some codestyle-issues which needs fixing to make the snapshot functions more similar to the rest of the cgit code. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-24Remove obsolete cacheitem parameter to ui-functionsLars Hjemli-2/+1
This parameter hasn't been used for a very long time... Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-24Add struct cgit_page to cgit_contextLars Hjemli-1/+3
This struct is used when generating http headers, and as such is another small step towards the goal of the whole cleanup series; to invoke each page/view function with a function pointer. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-18Introduce html.hLars Hjemli-0/+1
All html-functions can be quite easily separated from the rest of cgit, so lets do it; the only issue was html_filemode which uses some git-defined macros so the function is moved into ui-shared.c::cgit_print_filemode(). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-12-03Compare string lengths when parsing the snapshot maskLars Hjemli-3/+4
We used to rely on the result from strncmp() without comparing the length of the strings involved. Even worse, any single-character format specifier would enable zip-format due to the optional '.'-prefix since the length of the mask then would become zero. Noticed-by: Evan Martin <sys@neugierig.org> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-11-11Set commit date on snapshot contentsLars Hjemli-0/+1
The testsuite revealed that cgit snapshots don't set any useful timestamp on the files contained in the snapshot. Cherry-picked-from: 2ff33a8a0405b420cd75e0e207c7efeecd6f130b Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-11-11Set commit date on snapshot contentsLars Hjemli-0/+1
The testsuite revealed that cgit snapshots don't set any useful timestamp on the files contained in the snapshot. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-07-23ui-snapshot: whitespace/formatting cleanupLars Hjemli-24/+24
Introduce a #define for number of snapshot archive entries, move all decls to function entrypoint, remove some trailing whitespace and reformat a few lines. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-07-23cgit_print_snapshot_links: use url to specify snapshot nameLars Hjemli-14/+24
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-07-21allow selective enabling of snapshotsMichael Krelin-7/+36
snapshot configuration parameter now can be a space/slash/comma/colon/semicolon/pipe-separated list of snaphot suffixes as listed in ui-snapshot.c Signed-off-by: Michael Krelin <hacker@klever.net>
2007-07-21shorten snapshot names to repo basenameMichael Krelin-1/+1
Signed-off-by: Michael Krelin <hacker@klever.net>
2007-07-21added snapshot filename to the linkMichael Krelin-1/+1
- changed cgit_pageurl into cgit_fileurl with the filename parameter - rewritten cgit_pageurl as a wrapper around cgit_fileurl Signed-off-by: Michael Krelin <hacker@klever.net>
2007-07-21add plain uncompressed tar snapshort formatMichael Krelin-1/+2
time to make available snapshots selectable Signed-off-by: Michael Krelin <hacker@klever.net>
2007-07-21introduced .tar.bz2 snapshotsMichael Krelin-31/+42
- reworked write_tar_gzip_archive to handle arbitrary filter as a write_compressed_tar_archive - reformatted whitespaces in the said function to adhere to common cgit standards - added wrappers around write_compressed_tar_archive for .tar.gz and .tar.bz2 - added a hint for vim to use 8 characters shift width by default Signed-off-by: Michael Krelin <hacker@klever.net>