Commit Graph

121 Commits (lh/grep)

Author SHA1 Message Date
Lars Hjemli 181b6e789b Merge branch 'jp/defbranch' 12 years ago
Lars Hjemli 2b9fab8d30 Merge branch 'lh/module-links' 12 years ago
Lukas Fleischer d96d2c98eb shared.c: Only setenv() if value is non-null
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>
13 years ago
Lukas Fleischer 8185169e5e shared.c: Remove unused "linux/limits.h" include
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>
13 years ago
Lars Hjemli e95c70d4ea Only guess default branch when a repo page is requested
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>
13 years ago
Lars Hjemli 6857bec50a ui-tree.c: add support for path-selected submodule links
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>
13 years ago
Lars Hjemli a1429dbc89 cgit.c: add 'clone-url' setting with support for macro expansion
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>
13 years ago
Lars Hjemli 3ec6b30950 cgit.c: always setup cgit repo environment variables
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>
13 years ago
Lars Hjemli ab350a77b1 Merge branch 'fh/filter-api'
Conflicts:
	cgit.c
13 years ago
Lukas Fleischer c9059710e7 Remove unused variable from cgit_diff_tree().
Seen with "-Wunused-but-set-variable".

Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Lars Hjemli dc1a8eadd4 shared.c: do not modify const memory
Noticed-by: zhongjj <zhongjj@lemote.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
13 years ago
Lars Hjemli c2b58ed853 shared.c: use execvp() to execute filter commands
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>
13 years ago
Ferry Huberts 14f28923a2 cgit_open_filter: hand down repo configuration to script
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>
13 years ago
Ferry Huberts d87bba846d cgit_open_filter: also take the repo as a parameter
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>
13 years ago
Johan Herland 9a8d39c668 ui-log: Implement support for commit graphs
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>
14 years ago
Johan Herland 1415f3f3e0 ui-log: Fix filecount/linecount when path limit is in effect
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>
14 years ago
Lars Hjemli 515edb0da3 Add support for "readme" option
The value of this option is used as the default value for repo.readme.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Lars Hjemli 6821d8ea4a Merge branch 'jh/ignorews' 14 years ago
Lars Hjemli 5c5d189635 Merge branch 'lh/macros' 14 years ago
Johan Herland 2cc8b99f08 Add URL parameter 'ignorews' for optionally ignoring whitespace in diffs
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>
14 years ago
Lars Hjemli 6f92f332e6 Merge branch 'jh/context-lines'
Conflicts:
	cgit.c
	cgit.h
14 years ago
Lars Hjemli 37a24e4e39 Merge branch 'jh/path-limit'
Conflicts:
	cgit.h
	ui-commit.c
14 years ago
Johan Herland 6180e6169d Add URL parameter 'context' for changing the number of context lines in diffs
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>
14 years ago
Lars Hjemli 9af580d8f6 Merge branch 'sn/subject-link' 14 years ago
Johan Herland 026980c270 Remove unused variable in shared.c
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Lars Hjemli 023d933121 Merge branch 'stable' 14 years ago
Lars Hjemli ce761fde07 shared.c: avoid memory leak during diff
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
14 years ago
Lars Hjemli ba56a37e86 Add support for environment variable expansion
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>
14 years ago
Lars Hjemli 581a0c2a54 Optionally generate verbose parent links
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>
14 years ago
Lars Hjemli 41934a3222 Add support for remote branches
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 21f67e7d82 shared.c: return original errno
Noticed-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Rys Sommefeldt 8cfe4897f0 Close fd on error in readfile()
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 42e7a169e8 shared.c: initialize cgit_repo structs properly
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli e7af002d5c Introduce 'section' as canonical spelling for 'repo.group'
The 'repo.' prefix should be reserved for repo-specific options, but
the option 'repo.group' must still be honored to stay backwards
compatible.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli e16f178334 Add and use a common readfile() function
This function is used to read the full content of a textfile into a
newly allocated buffer (with zerotermination).

It replaces the earlier readfile() in scan-tree.c (which was rather
error-prone[1]), and is reused by read_agefile() in ui-repolist.c.

1: No checks for EINTR and EAGAIN, fixed-size buffer

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 537c05f138 Add 'about-filter' and 'repo.about-filter' options
These options can be used to execute a filter command on each about-page,
both top-level and for each repository (repo.about-filter can be used
to override the current about-filter).

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli e976df2795 Add support for repo.commit-filter and repo.source-filter
These options can be used to override the default commit- and source-
filter settings per repository.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli d6f6072560 Add generic filter/plugin infrastructure
The functions cgit_open_filter() and cgit_close_filter() can be used to
execute filters on the output stream from cgit.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
15 years ago
Lars Hjemli 481ce5e298 shared.c: avoid SEGFAULT when checking for binary buffers
Before calling buffer_is_binary() we need to verify that the buffer
is valid.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli c495cf02ba Handle binary files in diffs
This teaches all diff-related operations (i.e. ui-log, ui-diff and ui-patch)
how to handle binary files.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 7710178e45 Merge branch 'lh/stats'
Conflicts:
	cgit.c
	cgit.css
	cgit.h
	ui-tree.c

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 0edf76078e shared.c: future-proof usage of git diff-structures
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli fb2f3f6c29 ui-stats: replace 'enable-stats' setting with 'max-stats'
The new 'max-stats' and 'repo.max-stats' settings makes it possible to
define the maximum statistics period, both globally and per repo. Hence,
it is now feasible to allow statistics on repositories with a high commit
frequency, like linux-2.6, by setting repo.max-stats to e.g. 'month'.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli f86a23ff53 Add a 'stats' page to each repo
This new page, which is disabled by default, can be used to print some
statistics about the number of commits per period in the repository,
where period can be either weeks, months, quarters or years.

The function can be activated globally by setting 'enable-stats=1' in
cgitrc and disabled for individual repos by setting 'repo.enable-stats=0'.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 8813170390 ui-repolist: implement lazy caching of repo->mtime
When sorting the list of repositories by their last modification time,
cgit would (in the worst case) invoke fstat(3) four times and open(3)
twice for each callback from qsort(3). This obviously scales very badly.

Now, the calculated modtime for each repo is saved in repo->mtime, thus
keeping the number of stat/open invocations identical for sorted and
unsorted repo-listings.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli e87e896333 Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring()
This is a generic http-function.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 92908af455 Move cgit_version from shared.c to cgit.c
With the matching Makefile change, this makes sure that only cgit.o and cgit
proper needs to be rebuildt when VERSION has been modified.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli 163037e79c Move non-generic functions from shared.c to cgit.c
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago
Lars Hjemli f34478cbe0 Refactor snapshot support
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>
16 years ago
Lars Hjemli e0e4478e7b Add command dispatcher
This simplifies the code in cgit.c and makes it easier to extend cgit with
new pages/commands.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
16 years ago