summaryrefslogtreecommitdiffstatshomepage
path: root/ui-tree.c (unfollow)
Commit message (Collapse)AuthorLines
2014-01-12filter: pass extra arguments via cgit_open_filterJohn Keeping-4/+3
This avoids poking into the filter data structure at various points in the code. We rely on the fact that the number of arguments is fixed based on the filter type (set in cgit_new_filter) and that the call sites all know which filter type they're using. Signed-off-by: John Keeping <john@keeping.me.uk>
2014-01-08Update copyright informationLukas Fleischer-1/+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>
2014-01-08Reduce line number bloat, fix hover effectPeter Wu-2/+1
Currently line numbers look like (for blob view and sdiff respectively): <a class='no' id='n68' name='n68' href='#n68'>68</a> <td class='lineno'><a class='no' href='...#n1' id='n1' name='n1'>1</a></td> name=".." is unnecessary if the id attribute is set (this even applies to IE6), so drop it. (aside, in HTML5, the name attribute is gone.) The line number links can be selected through their parent classes, no need for another class "no", so drop it too. For a file with 2000 lines, this yields a saving of 40% (29% gzipped). While at it, fix the hover effect of line numbers: now the line number get a black background as was intended. Signed-off-by: Peter Wu <lekensteyn@gmail.com> Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-04-08use struct strbuf instead of static buffersJohn Keeping-16/+17
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-8/+5
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-04cgit_print_tree(): Free curr_rev after usageLukas Fleischer-2/+6
Fixes following memory leak seen with "PATH_INFO=/cgit/tree/": ==15715== 7 bytes in 1 blocks are definitely lost in loss record 4 of 51 ==15715== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==15715== by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so) ==15715== by 0x46CAA8: xstrdup (wrapper.c:35) ==15715== by 0x418A4C: cgit_print_tree (ui-tree.c:274) ==15715== by 0x407D91: tree_fn (cmd.c:131) ==15715== by 0x405E16: process_request (cgit.c:574) ==15715== by 0x4074C8: cache_process (cache.c:322) ==15715== by 0x406C4F: main (cgit.c:872) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-tree.c: Use a context structure in walk_tree()Lukas Fleischer-22/+29
Use the context pointer to pass context information instead of misusing global variables, as we already did in "ui-blob.c" and in "ui-plain.c". In addition to the fixes to walk_tree(), pass the same structure to ls_tree() and ls_item() which is read_tree_recursive()-based as well. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-tree.c: Drop the header variableLukas Fleischer-6/+2
Instead, use the value of the state variable to determine whether the footer needs to be drawn. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-tree.c: Declare the state variable globallyLukas Fleischer-1/+2
This allows for removing the header variable in a following patch. We can use the state variable to check whether the tail needs to be printed instead. Note that the state variable will be moved into a context structure later. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04ui-tree.c: Pass current revision to print_object()Lukas Fleischer-3/+3
No longer access the global curr_rev variable in print_object(). This will make it easier to squash the curr_rev variable into a context structure without having to pass the context to the print_object() function. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-04White space around control verbs.Jason A. Donenfeld-1/+1
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2013-03-04Fix several whitespace errorsLukas Fleischer-2/+2
* Remove whitespace at the end of lines. * Replace space indentation by tabs. * Add whitespace before/after several operators ("+", "-", "*", ...) * Add whitespace to assignments ("foo = bar;"). * Fix whitespace in parameter lists ("foobar(foo, bar, 42)"). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-03-02Update git to v1.7.6.5John Keeping-3/+13
struct pathspec is now used in more places. Signed-off-by: John Keeping <john@keeping.me.uk>
2011-06-15ui-tree.c: add support for path-selected submodule linksLars Hjemli-9/+4
The current 'repo.module-link' option is sufficient when all gitlinks in a repository can be converted to commit links in a uniform way, but not when different submodules/paths needs different settings. This patch adds support for 'repo.module-link.<path>', which will be used for linking to submodules at paths matching one such entry. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
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-03-26source_filter: fix a memory leakFerry Huberts-0/+2
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl> 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-04prefer html_raw() to write()Mark Lodato-1/+1
To make the code more consistent, and to not rely on the implementation of html(), always use html_raw(...) instead of write(htmlfd, ...). Signed-off-by: Mark Lodato <lodatom@gmail.com>
2010-09-04fix errors in printf-style format stringsMark Lodato-2/+2
There were many places where the arguments to a printf-like function did not match the format string. Mostly, these were a missing 'l' flag, but there were three exceptions: - In ui-stats.c, a size_t argument must be printed. C99 has the "%zu" flag for this purpose, but not all compilers support this. Therefore, we mimic what git does - use a NO_C99_FORMAT Makefile variable. - In ui-stats.c, cgit_print_error() was called with a pointer instead of a character. - In ui-log.c, the "columns" argument was never used. Signed-off-by: Mark Lodato <lodatom@gmail.com>
2010-06-19ui-tree: Remove unnecessary path breadcrumb navigationJohan Herland-13/+2
The path breadcrumb navigation at the top of the 'tree' page has now been duplicated in ui-shared, which leaves the ui-tree implementation unnecessary. This patch removes the breadcrumb navigation from ui-tree, and moves the "(plain)" link that followed the breadcrumb when displaying blobs to the end of the next line, following the blob SHA1. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2010-02-28ui-tree: add link to plain view for blobs in tree listingLars Hjemli-0/+2
Suggested-by: Robert Weidlich <mail@robertweidlich.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-12-12Fix segfault on ppc when browsing treeMartins Polakovs-1/+1
2009-11-28"max-blob-size" config var to limit generated HTML sizeGeorg Lukas-0/+6
Sometimes it is not feasible to generate the HTML pretty-print for large files, especially if a source-filter is involved or binary data is to be displayed. The "max-blob-size" config var allows to disable HTML output for blobs bigger than X KBytes. Plain downloads are not affected. Signed-off-by: Georg Lukas <georg@op-co.de>
2009-08-21Rename "linenumbers" to "enable-tree-linenumbers", change default to "1"Lars Hjemli-1/+1
This makes the name of the cgitrc option more descriptive and at the same time changes the default from "0" to "1" in an attempt to stay backwards compatible - prior to the introduction of "source-filter" and "linenumbers", cgit always generated linenumber links in the tree view, but now this feature can be turned off (one might want to do this if the source-filter performs line-wrapping etc). While at it, the documentation is updated to match the surrounding descriptions. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-21Add 'linenumbers' config optionFlorian Pritz-11/+16
Signed-off-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-21ui-tree.c: show line numbers when highlightingFlorian Pritz-9/+11
When source-filter is enabled, cgit currently will not display linenumbers in the tree view. This patch restores the linenumber function. Signed-off-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-09Add support for repo.commit-filter and repo.source-filterLars Hjemli-4/+4
These options can be used to override the default commit- and source- filter settings per repository. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-08-08Expose file extension in tree lists as class to allow nicer tree stylingMartin Szulecki-1/+7
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
2009-07-31ui-tree: add support for source-filter optionLars Hjemli-4/+14
This new option is used to specify an external command which will be executed when displaying blob content in the tree view. Blob content will be written to STDIN of the filter and STDOUT from the filter will be included verbatim in the html output from cgit. The file name of the blob will be passed as the only argument to the filter command. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-03-15fix segfault when displaying empty blobsEric Wong-5/+8
When size is zero, subtracting one from it turns it into ULONG_MAX which causes an out-of-bounds access on buf. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-02-12ui-tree: escape ascii-text properly in hexdump viewLars Hjemli-4/+9
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-01-31ui-tree: show hexdump of binary blobsLars Hjemli-23/+48
This teaches ui-tree to detect binary blobs and display them similar to `hexdump -C` (only wider). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-01-10changed objects are outputted, allowing for selections of code onlyOnne Gorter-15/+16
2009-01-06ui-tree.c: do not add blank line when displaying blobsLars Hjemli-2/+4
Also, fix a related bug in the test-suite. Noticed-by: Jim Meyering <jim@meyering.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-12-07ui-tree: add link to stats page per pathLars Hjemli-0/+3
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-11-29ui-log: add support for showing the full commit messageLars Hjemli-1/+1
Some users prefer to see the full message, so to make these users happy the new querystring parameter "showmsg" can be used to print the full commit message per log entry. A link is provided in the log heading to make this function accessible, and all links and forms tries to preserve the users preference. Note: the new link is not displayed on the summary page since the point of the summary page is to be a summary, but it is still obeyed if specified manually. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-08-06ui-tree: link to plain view instead of blob viewLars Hjemli-4/+4
The urls for plain view makes it possible to download blobs without knowing their SHA1, but the function needs to be promoted and the link from tree view seems like a perfect fit. PS: Although hidden, the blob view still is nice for direct blob access so there's no point in removing it. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-07-21Adjust to new calling convention for read_tree_recursive()Lars Hjemli-5/+7
In GIT-1.6.0, read_tree_recursive takes an extra void pointer for callback data. We might want to use this to avoid some global variables, but for now lets just make sure that we can still compile. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-05-20ui-tree.c: avoid peeking at GITLINK objectsLars Hjemli-6/+8
When an object in the tree has GITLINK mode-bits we don't need to get any more info about that particular object (and trying to get more info about it will usually generate an annoying warning on stderr since the object typically doesn't exist in the repo anyways). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-04-08Don't specify mimetype in ui-blob.cLars Hjemli-1/+2
But be sure to specify correct filename. This way, the client can hopefully guess a sensible mimetype based on the filename suffix, and cgit can ignore the issue altogether. 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-18Introduce html.hLars Hjemli-1/+2
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>
2008-02-16Move cgit_repo into cgit_contextLars Hjemli-1/+1
This removes the global variable which is used to keep track of the currently selected repository, and adds a new variable in the cgit_context structure. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-02-16Introduce struct cgit_contextLars Hjemli-10/+10
This struct will hold all the cgit runtime information currently found in a multitude of global variables. The first cleanup removes all querystring-related variables. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-11-11Fix html error detected by test-suiteLars Hjemli-3/+3
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-11-03Add search parameters to cgit_log_linkLars Hjemli-1/+1
This makes the [prev] and [next] links work correctly on search results. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-09-20Remove a few compiler warningsLars Hjemli-1/+1
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-09-20ui-tree: show last line of blobLars Hjemli-2/+5
The last line in a blob was never printed by ui-tree::print_object(), which was particularly annoying when the blob missed a final newline. This fixes the issue. Noticed-by: <mkraai@beckman.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-09-19ui-tree: specify parameter position for all htmlf formatsLars Hjemli-1/+1
The GNU C library manual tells us that behavior is undefined if only some formats has a specification for the parameter position. Noticed-by: <mkraai@beckman.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>