aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* t0001: ignore ".dirty" suffix on Git versionJohn Keeping2013-04-151-1/+1
| | | | | | | | | | | | | | When testing modifications in Git that affect CGit, it is annoying to have t0001 failing simply because the Git version has a ".dirty" suffix when the version of Git there does indeed match that specified in the CGit makefile. Stop this by stripping the ".dirty" suffix from the GIT_VERSION variable. Note that this brings the "Git version" behaviour in line with the "submodule version" case which does not check if the working tree in git/ is modified. Signed-off-by: John Keeping <john@keeping.me.uk>
* tests: set TEST_OUTPUT_DIRECTORY to the CGit test directoryJohn Keeping2013-04-151-0/+1
| | | | | | | | | | | | | | | By default, Git's test suite puts the trash directories and test-results directory into its own directory, not that containing the tests being run. This is less convenient for inspecting test failures, so set the output directory to CGit's tests/ directory instead. Note that there is currently a bug in Git whereby it will create the trash directories in our tests/ directory regardless of the value of TEST_OUTPUT_DIRECTORY, and then fail to remove them once the tests are done. This change does currently affect the location of the test-results/ directory though. Signed-off-by: John Keeping <john@keeping.me.uk>
* t0109: test more URLsJohn Keeping2013-04-151-4/+20
| | | | | | | | | | | In order to ensure that we don't access $HOME at some point after initial startup when rendering a specific view, run the strace test on a range of different pages. This ensures that we don't end up reading a configuration later for some specific view. Signed-off-by: John Keeping <john@keeping.me.uk>
* cgitrc.5.txt: Specify when scan-path must be defined before.Jason A. Donenfeld2013-04-101-9/+11
| | | | | | | | Several options must be specified prior to scan-path. This is consistant source of user confusion. Document these facts. Suggested-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* 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>
* Add branch-sort and repo.branch-sort options.Jason A. Donenfeld2013-04-105-22/+46
| | | | | | | | | | | When set to "name", branches are sorted by name, which is the current default. When set to "age", branches are sorted by the age of the repository. This feature was requested by Konstantin Ryabitsev for use on kernel.org. Proposed-by: Konstantin Ryabitsev <mricon@kernel.org>
* t0109: chain operations with &&John Keeping2013-04-101-1/+1
| | | | | | | | Without '&&' between operations, we will not detect if strace or cgit exit with an error status, which would cause a false positive test status in this case. Signed-off-by: John Keeping <john@keeping.me.uk>
* 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>
* tests: Make sure that git does not access $HOMEJason A. Donenfeld2013-04-081-0/+25
| | | | | | | | | | | With the latest changes to prevent git from accessing configuration files that it should not, it's important to be sure that we won't have further breakage in the future. Use strace to implement a test to make sure cgit does not access() anything built from $HOME. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* tests/.gitignore: update for using Git's test infrastructureJohn Keeping2013-04-082-3/+3
| | | | Signed-off-by: John Keeping <john@keeping.me.uk>
* tests: use Git's test frameworkJohn Keeping2013-04-0813-291/+239
| | | | | | | | | | | | This allows tests to run in parallel as well as letting us use "prove" or another TAP harness to run the tests. Git's test framework requires Git to be fully built before letting any tests run, so add a new target to the top-level Makefile which builds all of Git instead of just libgit.a and make the "test" target depend on that. Signed-off-by: John Keeping <john@keeping.me.uk>
* Do not load user or system gitconfig and gitattributesJason A. Donenfeld2013-04-083-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While doing any kind of git loading, unset HOME variables and set NOSYSTEM variables so that cgit does not load any settings that a user may have set for his own /usr/bin/git usage. This fixes a fatal error introduced with git 1.8, whereupon git would fatally exit when failing to access particular files. The result of this is that only repo-local configuration files are accessed: zx2c4@thinkpad ~/Projects/cgit $ HOME=/root QUERY_STRING="url=foo/log" CGIT_CONFIG=tests/trash/cgitrc strace -e access ./cgit >/dev/null access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) access("repos/foo/.git/objects", X_OK) = 0 access("repos/foo/.git/refs", X_OK) = 0 access("repos/foo/.git/config", R_OK) = 0 access("repos/foo/.git/config", R_OK) = 0 access("repos/foo/.git/objects/b3/bafdbf0183f4897ef8b1319cb8c490ed54717e", F_OK) = 0 access("repos/foo/.git/objects/b3/bafdbf0183f4897ef8b1319cb8c490ed54717e", F_OK) = 0 access("repos/foo/.git/objects/b3/bafdbf0183f4897ef8b1319cb8c490ed54717e", F_OK) = 0 access("repos/foo/.git/objects/b3/bafdbf0183f4897ef8b1319cb8c490ed54717e", F_OK) = 0 +++ exited with 0 +++ Reported-by: Ferry Huberts <ferry.huberts@pelagic.nl> Tested-by: Jason A. Donenfeld <Jason@zx2c4.com> Tested-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* use struct strbuf instead of static buffersJohn Keeping2013-04-0812-243/+305
| | | | | | | | | | | | | | | | | | | 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>
* Remove redundant calls to fmt("%s", ...)John Keeping2013-04-082-3/+3
| | | | | | | | After this change there is one remaining call 'fmt("%s", delim)' in ui-shared.c but is needed as delim is stack allocated and so cannot be returned from the function. Signed-off-by: John Keeping <john@keeping.me.uk>
* Convert cgit_print_error to a variadic functionJohn Keeping2013-04-0811-45/+57
| | | | | | | | | 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>
* shared.c: add strbuf_ensure_endJohn Keeping2013-04-082-0/+8
| | | | | | | This is a small helper so that we can easily ensure that a strbuf ends with the specified character. Signed-off-by: John Keeping <john@keeping.me.uk>
* html.c: add various strbuf and varadic helpersJohn Keeping2013-04-083-4/+63
| | | | | | | | | | This adds the fmtalloc helper, html_txtf, html_vtxtf, and html_attrf. These takes a printf style format string like htmlf but escapes the resulting string. The html_vtxtf variant takes a va_list whereas html_txtf is variadic. Signed-off-by: John Keeping <john@keeping.me.uk>
* Mark char* fields in struct cgit_page as constJohn Keeping2013-04-082-7/+8
| | | | Signed-off-by: John Keeping <john@keeping.me.uk>
* Fix out-of-bounds memory accesses with virtual_root=""John Keeping2013-04-084-18/+25
| | | | | | | | | | | | | | | | The CGit configuration variable virtual_root is normalized so that it does not have a trailing '/' character, but it is allowed to be empty (the empty string and NULL have different meanings here) and there is code that is insufficiently cautious when checking if it ends in a '/': if (virtual_root[strlen(virtual_root) - 1] != '/') Clearly this check is redundant, but rather than simply removing it we get a slight efficiency improvement by switching the normalization so that the virtual_root variable always ends in '/'. Do this with a new "ensure_end" helper. Signed-off-by: John Keeping <john@keeping.me.uk>
* 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>
* Always #include corresponding .h in .c filesJohn Keeping2013-04-0822-8/+20
| | | | | | | | | | | | 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>
* cgit.mk: fix dependency handlingJohn Keeping2013-04-081-0/+8
| | | | | | | | | | | Git calculates the dependency files to be included using a simply expanded Makefile variable, so it does not include the CGit objects that are added after that Makefile has been processed. We therefore need to include the dependency files ourselves in order to get the dependency calculations right. Do this. Signed-off-by: John Keeping <john@keeping.me.uk>
* Makefile: re-include cgit.conf in cgit.mkJohn Keeping2013-04-081-0/+2
| | | | | | | This avoids needed to export every variable that might be used in cgit.mk from the top-level Makefile. Signed-off-by: John Keeping <john@keeping.me.uk>
* 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>
* Update git to v1.8.2.1John Keeping2013-04-084-5/+6
| | | | | | | | | | | This requires a small change to how we handle notes, but otherwise just works. Note that we can't use anything from v1.8.0 until v1.8.2.1 because some of the symbols that we need for graph drawing were made private in v1.8.0 and this was not reverted until v1.8.2.1. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-blob: don't segfault when no path is givenJohn Keeping2013-04-071-1/+1
| | | | | | | | | | | | It it possible to inspect blobs by specifying only the SHA-1, and CGit provides links to do so, for example if a tag points directly at a blob. In this case the path_items structure is never used, but creating it still causes strlen to be run on a null pointer. Fix this. This error was introduced by commit c1633c6 (Update git to v1.7.6.5 - 2013-03-02). Signed-off-by: John Keeping <john@keeping.me.uk>
* 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>
* Makefile: remove CGIT-CFLAGS files in clean stageJason A. Donenfeld2013-03-201-1/+1
|
* 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>
* html: check return value of writeJason A. Donenfeld2013-03-201-2/+3
| | | | | | | This squelches a gcc warning. It's also correct that we check to see if there are any partial or failed writes. For now, we just print a warning to stderr. In the future, perhaps it will prove wise to exit(1) on partial writes.
* ui-shared: squelch compiler warning.Jason A. Donenfeld2013-03-201-0/+1
| | | | | | Since tail is initialized to 0, we will never get a warning on the last if statement, but recent gcc complains anyway. So, we initialize len as well. Future gcc versions should be able to optimize this out anyway.
* cgit.mk: Use SHELL_PATH_SQ to run gen-version.shJohn Keeping2013-03-201-1/+1
| | | | | | | | On some platforms (notably Solaris) /bin/sh doesn't support enough of POSIX for gen-version.sh to run. Git's Makefile provides SHELL_PATH_SQ to address this issue so we just have to use it. Signed-off-by: John Keeping <john@keeping.me.uk>
* cgit.mk: don't rebuild everything if CGIT_VERSION changesJohn Keeping2013-03-201-1/+8
| | | | | | | | | If CGIT_VERSION is in CGIT_CFLAGS then a change in version (for example because you have committed your changes) causes all of the CGit objects to be rebuilt. Avoid this by using EXTRA_CPPFLAGS to add the version for only those files that are affected and make them depend on VERSION. Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-patch: use cgit_version not CGIT_VERSIONJohn Keeping2013-03-201-1/+1
| | | | | | | | We already have a global cgit_version which is set from the #define'd CGIT_VERSION in cgit.c. Change ui-patch.c to use this so that we only need to rebuild cgit.o when the version changes. Signed-off-by: John Keeping <john@keeping.me.uk>
* Makefile: re-use Git's Makefile where possibleJohn Keeping2013-03-203-119/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Git does quite a lot of platform-specific detection in its Makefile, which can result in it defining preprocessor variables that are used in its header files. If CGit does not define the same variables it can result in different sizes of some structures in different places in the same application. For example, on Solaris Git uses it's "compat" regex library which has a different sized regex_t structure than that available in the platform regex.h. This has a knock-on effect on the size of "struct rev_info" and leads to hard to diagnose runtime issues. In order to avoid all of this, introduce a "cgit.mk" file that includes Git's Makefile and make all of the existing logic apply to CGit's objects as well. This is slightly complicated because Git's Makefile must run in Git's directory, so all references to CGit files need to be prefixed with "../". In addition, OBJECTS is a simply expanded variable in Git's Makefile so we cannot just add our objects to it. Instead we must copy the two applicable rules into "cgit.mk". This has the advantage that we can split CGit-specific CFLAGS from Git's CFLAGS and hence avoid rebuilding all of Git whenever a CGit-specific value changes. Signed-off-by: John Keeping <john@keeping.me.uk> Acked-by: Jamie Couture <jamie.couture@gmail.com>
* tests: check that Git version are in syncJohn Keeping2013-03-201-0/+36
| | | | | | | | This ensures that the Git version pointed at by the submodule is the same as the one that will be fetched using "make get-git". Suggested-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: John Keeping <john@keeping.me.uk>
* Merge branch 'wip'Jason A. Donenfeld2013-03-2018-111/+125
|\
| * 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>