aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* ui-patch: Rename variablesLukas Fleischer2013-08-202-17/+19
| | | | | | | Rename parameters and local variables to match those from ui-diff. Also, convert a "char *" to "const char *". Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Allow for creating patch seriesLukas Fleischer2013-08-203-7/+20
| | | | | | | | | This allows for specifying a revision range using the id2 parameter of /patch/. The output that is produced is similar to $ git format-patch --stdout id2..id Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-patch.c: Use log_tree_commit() to generate diffsLukas Fleischer2013-08-201-23/+28
| | | | | | | | | Instead of using our own formatting, use log_tree_commit() from Git to create patches. This removes unnecessary duplicate code and also fixes a bug with e-mail address formatting that existed in our own implementation. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-diff: Check the return value of get_sha1()Lukas Fleischer2013-08-201-14/+9
| | | | | | | | | Sync with what we do everywhere else and check the return value of get_sha1() instead of calling sha1_object_info() to validate the object. Note that we later call lookup_commit_reference(), which checks that both SHA1 values refer to commits, anyway. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* cmd.c: Add a "rawdiff" commandLukas Fleischer2013-08-161-0/+6
| | | | | | | | | This can be used to generate raw diffs between arbitrary revisions using something like /rawdiff/?id=v0.9&id2=v0.9.1 Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Allow for creating raw diffs with cgit_print_diff()Lukas Fleischer2013-08-164-4/+12
| | | | | | | This adds a parameter to cgit_print_diff() to create raw diffs, using the same format as `git diff <commit>`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Extract filepair_cb from ui-patch.cLukas Fleischer2013-08-163-73/+74
Move filepair_cb() from ui-patch.c to ui-shared.c and rename it to filepair_cb_raw(). This callback will be used in ui-diff.c in a follow-up patch. Note that it is not straightforward to extract filepair_cb() from ui-diff.c which is why it is not done here as well. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Fix section-from-path > 1Lukas Fleischer2013-08-121-4/+4
| | | | | | | | | | | When having found the first path separator occurrence at position i, we invoked strchr() on the same position i in subsequent iterations resulting in the same path separator being returned by strchr() over and over again. Increase the position by one to skip the occurrence that has just been found and advance to the next separator. Reported-by: Konstantin Ryabitsev <mricon@kernel.org> Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Makefile: Change default prefix to "/usr/local"Lukas Fleischer2013-08-121-1/+1
| | | | | | | Locally installed packages are usually installed to /usr/local. Packagers can use `make prefix=/usr` to get back the old behavior. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Use strbuf for reading configuration filesLukas Fleischer2013-08-122-31/+35
Use struct strbuf from Git instead of fixed-size buffers to remove the limit on the length of configuration file lines and refactor read_config_line() to improve readability. Note that this also fixes a buffer overflow that existed with the original fixed-size buffer implementation. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-snapshot.c: Prepend "V" when guessing ref namesLukas Fleischer2013-04-101-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>
* t0107: Skip ZIP tests if unzip(1) isn't availableLukas Fleischer2013-04-101-4/+10
| | | | | | | | Note that we cannot use skip_all here since some tests have already been executed when ZIP tests are reached. Use test prerequisites to skip everything using unzip(1) if the binary is not available instead. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* tests/: Do not use `sed -i`Lukas Fleischer2013-04-102-5/+8
"-i" isn't part of the POSIX standard and doesn't work on several platforms such as OpenBSD. Use a temporary file instead. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* cgit.c: Do not restore unset environment variablesLukas Fleischer2013-04-101-2/+4
| | | | | | | | | | | getenv() returns a NULL pointer if the specified variable name cannot be found in the environment. However, some setenv() implementations crash if a NULL pointer is passed as second argument. Only restore variables that are not NULL. See commit d96d2c98ebc4c2d3765f5b35c4142e0e828a421b for a related patch. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* t0107: Use `tar -z` for gzip'ed archivesLukas Fleischer2013-04-091-1/+1
Some tar(1) versions do not support auto detection of the compression type. Explicitly specify "-z" to decompress a ".tar.gz" archive. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-refs.c: Refactor print_tag()Lukas Fleischer2013-04-081-29/+27
| | | | | | | | The code snippets for OBJ_TAG and other object types are almost equivalent. Merge them and use a couple of inline if conditions to select proper fields. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-refs.c: Remove global header variableLukas Fleischer2013-04-081-6/+0
| | | | | | | | | | | | print_tag_header() is only called from cgit_print_tags() -- the conditional invocation in print_tag() is never executed since print_tag() is only called by cgit_print_tags() which already executes print_tag_header() before (resulting in the global variable being always set in when the condition is evaluated). Remove the global variable and the conditional invocation. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* html.c: Replace strdup() with xstrdup()Lukas Fleischer2013-04-081-5/+2
Use the xstrdup() wrapper which already bails out if strdup() returns a NULL pointer. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Do not unnecessarily strdup() environment variablesLukas Fleischer2013-04-081-15/+10
| | | | | | | | | | This reverts the memory duplication introduced in commit 60a2627, while keeping everything else that has been cleaned up. The environment variables are never modified, so we do not need to call xstrdupn() here. Also, remove xstrdupn() which is no longer needed. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Maŕk cgit_environment members constLukas Fleischer2013-04-082-12/+12
| | | | | | | | These reflect the values of environment variables and should never be changed. Add another xstrdup() when we assign environment variables to strings that are potentially non-constant. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Return const char * in cgit_{httpscheme, hosturl, rooturl}()Lukas Fleischer2013-04-083-9/+9
The return values of these functions are essentially constant and should never be modified. Note that this will introduce a compiler warning when we try to free the return value of any of these functions. However, given that all of these currently return statically allocated strings in some cases, they need to be refactored before this can be done anyway. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Convert pager navigation into a unordered listLukas Fleischer2013-03-203-9/+20
It is common practice and semantically appropriate to use unordered lists for long navigation lists. This also fixes the layout of very long pager navigations in Webkit-based browsers. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-summary.c: Move urls variable into print_urls()Lukas Fleischer2013-03-201-6/+14
| | | | | | | | | | | There's no need for this variable to be global. Printing the header in print_urls() instead of print_url() allows for moving this variable into print_urls() without having to pass any status to print_url(). Note that this only works as long as we don't call print_urls() more than once. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Fix colspan valuesLukas Fleischer2013-03-203-14/+28
This fixes a couple of minor oversights in previous commits and adjusts all cells using colspan to use the correct width. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* cgit_print_snapshot_links(): Free prefix variableLukas Fleischer2013-03-041-0/+1
| | | | | | | | | | | | | | | | | Fixes following memory leak seen with "PATH_INFO=/cgit/commit/": ==16894== 12 bytes in 1 blocks are definitely lost in loss record 9 of 92 ==16894== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16894== by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so) ==16894== by 0x46CAC8: xstrdup (wrapper.c:35) ==16894== by 0x414E34: cgit_print_snapshot_links (ui-shared.c:926) ==16894== by 0x40CFA1: cgit_print_commit (ui-commit.c:102) ==16894== by 0x407B06: commit_fn (cmd.c:54) ==16894== by 0x405E16: process_request (cgit.c:574) ==16894== by 0x4074C8: cache_process (cache.c:322) ==16894== by 0x406C4F: main (cgit.c:872) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* cgit_print_commit(): Free tmp variableLukas Fleischer2013-03-041-0/+1
| | | | | | | | | | | | | | | | Fixes following memory leak seen with "PATH_INFO=/cgit/commit/": ==16894== 7 bytes in 1 blocks are definitely lost in loss record 4 of 92 ==16894== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16894== by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so) ==16894== by 0x46CAC8: xstrdup (wrapper.c:35) ==16894== by 0x40CD6F: cgit_print_commit (ui-commit.c:70) ==16894== by 0x407B06: commit_fn (cmd.c:54) ==16894== by 0x405E16: process_request (cgit.c:574) ==16894== by 0x4074C8: cache_process (cache.c:322) ==16894== by 0x406C4F: main (cgit.c:872) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* cgit_print_tree(): Free curr_rev after usageLukas Fleischer2013-03-041-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>
* find_default_branch(): Free refmatch after usageLukas Fleischer2013-03-041-0/+8
| | | | | | | | | | | | | | | | | | | | Fixes following memory leak seen with "PATH_INFO=/cgit/refs/": ==13408== 7 bytes in 1 blocks are definitely lost in loss record 4 of 52 ==13408== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==13408== by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so) ==13408== by 0x46CA78: xstrdup (wrapper.c:35) ==13408== by 0x405840: find_current_ref (cgit.c:426) ==13408== by 0x44BE5A: do_one_ref (refs.c:527) ==13408== by 0x44D3E0: do_for_each_ref_in_dir (refs.c:553) ==13408== by 0x44D85A: do_for_each_ref (refs.c:1298) ==13408== by 0x405889: find_default_branch (cgit.c:438) ==13408== by 0x405AC4: prepare_repo_cmd (cgit.c:490) ==13408== by 0x405D97: process_request (cgit.c:557) ==13408== by 0x407490: cache_process (cache.c:322) ==13408== by 0x406C18: main (cgit.c:864) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* print_tag_downloads(): Free ref variableLukas Fleischer2013-03-041-1/+7
| | | | | | | | | | | | | | | | | | | | | | Make sure the ref variable is freed if we build a "$basename-$version"-style ref. This fixes following memory leak seen with "PATH_INFO=/cgit/refs/": ==8784== 323 bytes in 29 blocks are definitely lost in loss record 41 of 53 ==8784== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==8784== by 0x56F2DF1: strdup (in /usr/lib/libc-2.17.so) ==8784== by 0x46CA28: xstrdup (wrapper.c:35) ==8784== by 0x410DA6: print_tag_downloads (ui-refs.c:115) ==8784== by 0x410F02: print_tag (ui-refs.c:141) ==8784== by 0x41128B: cgit_print_tags (ui-refs.c:230) ==8784== by 0x41134D: cgit_print_refs (ui-refs.c:250) ==8784== by 0x407C85: refs_fn (cmd.c:105) ==8784== by 0x405DDF: process_request (cgit.c:566) ==8784== by 0x407490: cache_process (cache.c:322) ==8784== by 0x406C18: main (cgit.c:864) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Free reflists after usageLukas Fleischer2013-03-043-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Free reflists in cgit_print_branches() and in cgit_print_tags() before returning reflist structures to the stack. This fixes following memory leaks seen with "PATH_INFO=/cgit/refs/": ==5710== 1,312 (32 direct, 1,280 indirect) bytes in 1 blocks are definitely lost in loss record 63 of 71 ==5710== at 0x4C2C04B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5710== by 0x4C2C2FF: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5710== by 0x46CA9B: xrealloc (wrapper.c:100) ==5710== by 0x40AAA6: cgit_add_ref (shared.c:156) ==5710== by 0x40ABC4: cgit_refs_cb (shared.c:186) ==5710== by 0x44BCBA: do_one_ref (refs.c:527) ==5710== by 0x44D240: do_for_each_ref_in_dir (refs.c:553) ==5710== by 0x44D6BA: do_for_each_ref (refs.c:1298) ==5710== by 0x410FE2: cgit_print_branches (ui-refs.c:191) ==5710== by 0x4111E9: cgit_print_refs (ui-refs.c:244) ==5710== by 0x407C85: refs_fn (cmd.c:105) ==5710== by 0x405DDF: process_request (cgit.c:566) ==5710== ==5710== 6,846 (256 direct, 6,590 indirect) bytes in 1 blocks are definitely lost in loss record 68 of 71 ==5710== at 0x4C2C25E: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5710== by 0x46CA9B: xrealloc (wrapper.c:100) ==5710== by 0x40AAA6: cgit_add_ref (shared.c:156) ==5710== by 0x40ABC4: cgit_refs_cb (shared.c:186) ==5710== by 0x44BCBA: do_one_ref (refs.c:527) ==5710== by 0x44D240: do_for_each_ref_in_dir (refs.c:553) ==5710== by 0x44D6EC: do_for_each_ref (refs.c:1288) ==5710== by 0x4110D5: cgit_print_tags (ui-refs.c:218) ==5710== by 0x4111FD: cgit_print_refs (ui-refs.c:246) ==5710== by 0x407C85: refs_fn (cmd.c:105) ==5710== by 0x405DDF: process_request (cgit.c:566) ==5710== by 0x407490: cache_process (cache.c:322) Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-shared.c: Remove unused function print_archive_ref()Lukas Fleischer2013-03-041-39/+0
| | | | | | This is no longer used as of commit f135569b. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-shared.c: Remove unused function cgit_currurl()Lukas Fleischer2013-03-041-12/+0
| | | | | | This is no longer used as of commit 0c8e184e. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Mark several functions/variables staticLukas Fleischer2013-03-0414-60/+64
Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Makefile: Disable gettext in the Git submoduleLukas Fleischer2013-03-041-1/+1
Newer libgit versions depend on the libintl library. However, we currently do not link against libintl which breaks compilation under OpenBSD: git/libgit.a(commit.o)(.text+0x1d1b): In function `lookup_commit_or_die': git/gettext.h:47: undefined reference to `libintl_gettext' [...] Since we do not support i18n in cgit, just disable gettext in the Git submodule to fix this. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* cgit.c: Remove parameter from guess_defbranch()Lukas Fleischer2013-03-041-2/+2
| | | | | | We use resolve_ref() since commit 8d7c2ec2, so this is no longer needed. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-tree.c: Use a context structure in walk_tree()Lukas Fleischer2013-03-041-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>
* ui-tree.c: Drop the header variableLukas Fleischer2013-03-041-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>
* ui-tree.c: Declare the state variable globallyLukas Fleischer2013-03-041-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>
* ui-tree.c: Pass current revision to print_object()Lukas Fleischer2013-03-041-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>
* ui-plain.c: Use a context structure in walk_tree()Lukas Fleischer2013-03-041-13/+20
| | | | | | | | Do not misuse global variables to save the context. Instead, use the context pointer which was designed to share information between a read_tree_fn and the caller. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-plain.c: Do not access match variable in print_*()Lukas Fleischer2013-03-041-12/+14
| | | | | | | | | Move all code setting the match variable to walk_tree(). This allows for easily moving this variable into a context structure without having to pass the context to print_*(). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* ui-blob.c: Use a context structure in walk_tree()Lukas Fleischer2013-03-041-16/+26
Do not misuse global variables to save the context. Instead, use the context pointer which was designed to share information between a read_tree_fn and the caller. This also prevents from potential misuse of the global pointers match_path and matched_sha1 after the referenced values have been overwritten on the stack. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Fix several whitespace errorsLukas Fleischer2013-03-0414-99/+99
* 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>
* shared.c: Only setenv() if value is non-nullLukas Fleischer2012-01-032-2/+2
| | | | | | | | | | | | | | Some setenv() implementations (e.g. the one in OpenBSD's stdlib) segfault if we pass a NULL value. Only set environment variables if the corresponding settings are defined to avoid this. Note that this is a minor behaviour change as environment variables were supposed to be set to an empty string if a setting was undefined. Given that this feature isn't part of any official release yet, there's no need to worry about backwards compatibility, really. Change the documentation accordingly. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* shared.c: Remove unused "linux/limits.h" includeLukas Fleischer2012-01-031-1/+0
This isn't used anywhere and prevents the code from being compiled on other platforms, such as *BSD. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Fix potential XSS vulnerability in rename hintLukas Fleischer2011-07-221-4/+6
| | | | | | | | | The file name displayed in the rename hint should be escaped to avoid XSS. Note that this vulnerability is only applicable when an attacker has gained push access to the repository. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* Remove dead initialization in cgit_parse_commit()Lukas Fleischer2011-07-221-1/+1
The value stored to "t" during its initialization gets overwritten in any case, so just leave it uninitialized. Spotted by clang-analyzer. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* Properly escape ampersands inside HTML attributesLukas Fleischer2011-05-301-1/+3
Ampersands ("&") appearing inside HTML attributes need to be translated to "&amp;". Otherwise, invalid XHTML will be generated at various places, such as at tree views containing links to submodules. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* Avoid null pointer dereference in cgit_print_diff().Lukas Fleischer2011-05-231-2/+6
| | | | | | | | | | When calling cgit_print_diff() with a bad new_rev and a NULL old_rev, checking for new_rev's parent commit will result in a null pointer dereference. Returning on an invalid commit before dereferencing fixes this. Spotted with clang-analyzer. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* Avoid null pointer dereference in reencode().Lukas Fleischer2011-05-231-1/+4
| | | | | | | | Returning "*txt" if "txt" is a null pointer is a bad thing. Spotted with clang-analyzer. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>