summaryrefslogtreecommitdiffstatshomepage
path: root/shared.c (follow)
Commit message (Collapse)AuthorAgeLines
* shared: make some variables 'static'John Keeping2015-03-09-2/+2
| | | | | | These are not used outside this file and are not declared. Signed-off-by: John Keeping <john@keeping.me.uk>
* Add repo.hide and repo.ignoreLukas Fleischer2015-01-29-0/+3
| | | | | | | | These options can be used to hide a repository from the index or completely ignore a repository, respectively. They are particularly useful when used in combination with scan-path. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* repolist: add owner-filterChris Burroughs2014-12-23-0/+1
| | | | | | This allows custom links to be used for repository owners by configuring a filter to be applied in the "Owner" column in the repository list.
* diffstat: do not rely on uninitialized dataJason A. Donenfeld2014-02-20-0/+1
| | | | | | | | | | | Right now if you visit: <http://git.zx2c4.com/systemd/diff/src/udev/udev-builtin-input_id.c?id=bcfce235> you'll see that if you reload the page a few times, a bunch of times the diffstat comes out with no lines being shown or changed. I'm not currently sure what the cause of this is, but I suspect it might have to do with this uninitialized data. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* filter: add support for email filterJason A. Donenfeld2014-01-14-0/+1
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* filter: split filter functions into their own fileJason A. Donenfeld2014-01-10-35/+0
| | | | | | A first step for more interesting things. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* filter: make exit status localJason A. Donenfeld2014-01-10-3/+4
| | | | | | | | It's only used in one place, and not useful to have around since close_filter will die() if exit_status isn't what it expects, anyway. So this is best as just a local variable instead of as part of the struct. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* Refactor cgit_parse_snapshots_mask()Lukas Fleischer2014-01-10-11/+12
| | | | | | | Use Git string lists instead of str{spn,cspn,ncmp}() magic. This significantly improves readability. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Disallow use of undocumented snapshot delimitersLukas Fleischer2014-01-10-1/+1
| | | | | | | | | | | | | | | Since the introduction of selective snapshot format configuration in dc3c9b5 (allow selective enabling of snapshots, 2007-07-21), we allowed seven different delimiters for snapshot formats, while the documentation has always been clear about spaces being the only valid delimiter: The value is a space-separated list of zero or more of the values "tar", "tar.gz", "tar.bz2", "tar.xz" and "zip". Supporting the undocumented delimiters makes the code unnecessarily complex. Remove them. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* Update copyright informationLukas Fleischer2014-01-08-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>
* shared.c: use die_errno() where appropriateJohn Keeping2013-05-22-5/+4
| | | | | | | This replaces some code that is re-implementing die_errno by just calling the function. Signed-off-by: John Keeping <john@keeping.me.uk>
* Add branch-sort and repo.branch-sort options.Jason A. Donenfeld2013-04-10-0/+1
| | | | | | | | | | | 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>
* shared.c: add strbuf_ensure_endJohn Keeping2013-04-08-0/+6
| | | | | | | 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>
* Fix out-of-bounds memory accesses with virtual_root=""John Keeping2013-04-08-0/+15
| | | | | | | | | | | | | | | | 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>
* Free reflists after usageLukas Fleischer2013-03-04-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Mark several functions/variables staticLukas Fleischer2013-03-04-6/+6
| | | | | | Spotted by parsing the output of `gcc -Wmissing-prototypes [...]`. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
* White space around control verbs.Jason A. Donenfeld2013-03-04-4/+4
| | | | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* Fix several whitespace errorsLukas Fleischer2013-03-04-7/+7
| | | | | | | | | | * 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>
* Update git to v1.7.5.4John Keeping2013-03-02-5/+5
| | | | | | | | | Some changes to diff options: - no_merges has become the more general max_parents - path restriction now uses struct pathspec Signed-off-by: John Keeping <john@keeping.me.uk>
* ui-log: Add "commit-sort" option for controlling commit orderingTobias Bieniek2012-10-17-0/+1
| | | | | | | This makes it possible to use strict commit date ordering or strict topological ordering by passing the corresponding flags to "git log". Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
* scan-tree: Unify gitweb.* and cgit.* settings into one config option.Jason A. Donenfeld2012-10-17-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | After some back and forth with Jamie and René, it looks like the git config semantics are going to be like this: - gitweb.category maps to the cgit repo config key "section" - gitweb.description maps to the cgit repo config key "desc" - gitweb.owner maps to the cgit repo config key "owner" - cgit.* maps to all cgit repo config keys This option can be enabled with "enable-git-config=1", and replaces all previous "enable-gitweb-*" config keys. The order of operations is as follows: - git config settings are applied in the order that they exist in the git config file - if the owner is not set from git config, get the owner using the usual getpwuid call - if the description is not set from git config, look inside the static $path/description file - if section-from-path=1, override whatever previous settings were inside of git config using the section-from-path logic - parse $path/cgitrc for local repo.* settings, that override all previous settings
* Merge branch 'jp/defbranch'Lars Hjemli2012-03-18-1/+0
|\
| * Only guess default branch when a repo page is requestedLars Hjemli2011-06-20-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no need to invoke guess_defbranch() for each repo during scan-path, since repo.defbranch is only used when repo content is being displayed. Also, some users prefer to register their projects manually in cgitrc but they got no benefit from the new repo.defbranch handling. This patch tries to rectify these issues by only invoking guess_defbranch() when needed, regardless of how the repo was registered. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* | Merge branch 'lh/module-links'Lars Hjemli2012-03-18-0/+1
|\ \
| * | ui-tree.c: add support for path-selected submodule linksLars Hjemli2011-06-15-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | 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>
* | shared.c: Only setenv() if value is non-nullLukas Fleischer2012-01-03-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-03-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>
* cgit.c: add 'clone-url' setting with support for macro expansionLars Hjemli2011-06-13-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current 'clone-prefix' setting has some known issues: * All repos get the same 'clone-prefix' value since the setting is not adopted during repo registration (in cgitrc, or during scan-path traversal), but only when the setting is used. * The generated clone-urls for a repo is a combination of 'clone-prefix', a slash and the repo url. This doesn't work well with e.g. ssh-style urls like 'git@example.org:repo.git', since the inserted slash will make the repo relative to the filesystem root. * If 'remove-suffix' is enabled, the generated clone-urls will not work for cloning (except for http-urls to cgit itself) since they miss the '.git' suffix. The new 'clone-url' setting is designed to avoid the mentioned issues: * Each repo adopts the default 'clone-url' when the repo is defined. This allows different groups of repos to adopt different values. * The clone-urls for a repo is generated by expanding environment variables in a string template without inserting arbitrary characters, hence any kind of clone-url can be generated. * Macro expansion also eases the 'remove-suffix' pain since it's now possible to define e.g. 'clone-url=git://foo.org/$CGIT_REPO_URL.git' for a set of repos. A furter improvement would be to define e.g. $CGIT_REPO_SUFFIX to '.git' for all repos which had their url prettified, or to store the original $CGIT_REPO_URL in e.g. $CGIT_REPO_REAL_URL before suffix removal. Reviewed-by: Ferry Huberts <mailings@hupie.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* cgit.c: always setup cgit repo environment variablesLars Hjemli2011-06-13-4/+3
| | | | | | | | | | | | 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>
* Merge branch 'fh/filter-api'Lars Hjemli2011-05-23-1/+31
|\ | | | | | | | | Conflicts: cgit.c
| * shared.c: use execvp() to execute filter commandsLars Hjemli2011-03-26-57/+11
| | | | | | | | | | | | | | This reintroduces the use of execvp(), since the filter commands doesn't always contain an absolute path (i.e. snapshot compression filters). Signed-off-by: Lars Hjemli <hjemli@gmail.com>
| * cgit_open_filter: hand down repo configuration to scriptFerry Huberts2011-03-26-1/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The environment variables can be used to (for example) resolve the following situation: Suppose a server setup in which each repository has a trac instance; the commit filter needs to know with which repository it's dealing in order to be able to resolve the #123 ticket numbers in the commit messages into hyperlinks into the correct trac instance. Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
| * cgit_open_filter: also take the repo as a parameterFerry Huberts2011-03-26-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>
* | Remove unused variable from cgit_diff_tree().Lukas Fleischer2011-05-23-3/+2
| | | | | | | | | | | | | | Seen with "-Wunused-but-set-variable". Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* | shared.c: do not modify const memoryLars Hjemli2011-05-23-11/+3
|/ | | | | Noticed-by: zhongjj <zhongjj@lemote.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* ui-log: Implement support for commit graphsJohan Herland2010-11-16-0/+1
| | | | | | | | | | | | | | | | Teach CGit to print an ASCII art commit graph to the left of the commit message, similar to 'git log --graph'. The graph adds extra lines (table rows) to the log when needed to add/remove/shuffle edges in the graph. When 'showmsg' is enabled, the graph is automatically padded to account for the extra lines added by the commit message/notes. This feature is controlled by a new config variable: "enable-commit-graph" (disabled by default), and individual repos can control it by setting "repo.enable-commit-graph". Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* ui-log: Fix filecount/linecount when path limit is in effectJohan Herland2010-11-09-2/+2
| | | | | | | | | | | | | | | | | | | | | | | When using ui-log with path limits, the listing of commits enables parent rewriting in Git's internal log machinery. This did not work well together with cgit_diff_commit() which is used to generate the filecount and linecount numbers for each commit in the log view. cgit_diff_commit() would operate without any path limits, and would therefore process the full diff between the commits shown (which, because of parent rewriting, is not the same as processing the diff for the commit itself). Additionally, the bottom commit in the log view would (again, because of parent rewriting) have zero parents, causing us to process the entire diff between the empty tree and that commit. Since path limits were not in effect, this would (in large projects) reports thousands of files and millions of lines changed in that bottom commit. This patch fixes the issue by applying the same path limit to cgit_diff_commit() as is applied to the rest of the log view. The result is that the filecount/linecount now only reflects the diff as it pertains to the given path limit. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* Add support for "readme" optionLars Hjemli2010-08-22-1/+1
| | | | | | The value of this option is used as the default value for repo.readme. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* Merge branch 'jh/ignorews'Lars Hjemli2010-07-18-3/+8
|\
| * Add URL parameter 'ignorews' for optionally ignoring whitespace in diffsJohan Herland2010-07-18-3/+8
| | | | | | | | | | | | | | | | The new ctx.qry.ignorews variable is passed via cgit_diff_files() and cgit_diff_tree() to Git's diff machinery. This is equivalent to passing --ignore-all-space to 'git diff'. Signed-off-by: Johan Herland <johan@herland.net>
* | Merge branch 'lh/macros'Lars Hjemli2010-07-18-0/+71
|\ \
| * | Add support for environment variable expansionLars Hjemli2010-03-22-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch teaches cgit to expand environment variables in certain cgitrc option values (cache_root, scan-path, include) plus when finding the location of cgitrc itself. One use case for this feature is virtual hosting - e.g. by setting $CGIT_CONFIG='/etc/cgitrc/$HTTP_HOST' in httpd.conf, all virtual hosts automatically gets their own cgitrc. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* | | Merge branch 'jh/context-lines'Lars Hjemli2010-06-22-2/+3
|\ \ \ | | |/ | |/| | | | | | | | | | Conflicts: cgit.c cgit.h
| * | Add URL parameter 'context' for changing the number of context lines in diffsJohan Herland2010-06-19-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | The new ctx.qry.context variable is picked up by cgit_print_diff(), and passed via cgit_diff_files() to Git's diff machinery. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* | | Merge branch 'jh/path-limit'Lars Hjemli2010-06-22-1/+0
|\| | | | | | | | | | | | | | | | | Conflicts: cgit.h ui-commit.c
| * | Remove unused variable in shared.cJohan Herland2010-06-19-1/+0
| |/ | | | | | | | | Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* | Merge branch 'sn/subject-link'Lars Hjemli2010-06-19-0/+1
|\ \
| * | Optionally generate verbose parent linksLars Hjemli2010-02-27-0/+1
| |/ | | | | | | | | | | | | The new option 'enable-subject-links' must be used to enable the verbose parent-links in commit view. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
* | Merge branch 'stable'Lars Hjemli2010-04-08-0/+8
|\ \ | |/ |/|
| * shared.c: avoid memory leak during diffLars Hjemli2010-04-08-0/+8
| | | | | | | | Signed-off-by: Lars Hjemli <hjemli@gmail.com>