-rw-r--r-- | Makefile | 66 | ||||
-rw-r--r-- | cgit.css | 16 | ||||
-rw-r--r-- | cgitrc.5.txt | 10 | ||||
m--------- | git | 0 | ||||
-rw-r--r-- | ui-stats.c | 2 |
5 files changed, 78 insertions, 16 deletions
@@ -1,194 +1,244 @@ CGIT_VERSION = v0.8.3.4 CGIT_SCRIPT_NAME = cgit.cgi CGIT_SCRIPT_PATH = /var/www/htdocs/cgit CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH) CGIT_CONFIG = /etc/cgitrc CACHE_ROOT = /var/cache/cgit +prefix = /usr +libdir = $(prefix)/lib +filterdir = $(libdir)/cgit/filters +docdir = $(prefix)/share/doc/cgit +htmldir = $(docdir) +pdfdir = $(docdir) +mandir = $(prefix)/share/man SHA1_HEADER = <openssl/sha.h> -GIT_VER = 1.7.3 +GIT_VER = 1.7.4 GIT_URL = http://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.bz2 INSTALL = install +MAN5_TXT = $(wildcard *.5.txt) +MAN_TXT = $(MAN5_TXT) +DOC_MAN5 = $(patsubst %.txt,%,$(MAN5_TXT)) +DOC_HTML = $(patsubst %.txt,%.html,$(MAN_TXT)) +DOC_PDF = $(patsubst %.txt,%.pdf,$(MAN_TXT)) # Define NO_STRCASESTR if you don't have strcasestr. # # Define NO_OPENSSL to disable linking with OpenSSL and use bundled SHA1 # implementation (slower). # # Define NEEDS_LIBICONV if linking with libc is not enough (eg. Darwin). # # Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.) # do not support the 'size specifiers' introduced by C99, namely ll, hh, # j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t). # some C compilers supported these specifiers prior to C99 as an extension. # #-include config.mak # # Platform specific tweaks # uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not') uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not') ifeq ($(uname_O),Cygwin) NO_STRCASESTR = YesPlease NEEDS_LIBICONV = YesPlease endif # # Let the user override the above settings. # -include cgit.conf # # Define a way to invoke make in subdirs quietly, shamelessly ripped # from git.git # QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir QUIET_SUBDIR1 = ifneq ($(findstring $(MAKEFLAGS),w),w) PRINT_DIR = --no-print-directory else # "make -w" NO_SUBDIR = : endif ifndef V QUIET_CC = @echo ' ' CC $@; QUIET_MM = @echo ' ' MM $@; QUIET_SUBDIR0 = +@subdir= QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ $(MAKE) $(PRINT_DIR) -C $$subdir endif # # Define a pattern rule for automatic dependency building # %.d: %.c $(QUIET_MM)$(CC) $(CFLAGS) -MM -MP $< | sed -e 's/\($*\)\.o:/\1.o $@:/g' >$@ # # Define a pattern rule for silent object building # %.o: %.c $(QUIET_CC)$(CC) -o $*.o -c $(CFLAGS) $< EXTLIBS = git/libgit.a git/xdiff/lib.a -lz -lpthread OBJECTS = OBJECTS += cache.o OBJECTS += cgit.o OBJECTS += cmd.o OBJECTS += configfile.o OBJECTS += html.o OBJECTS += parsing.o OBJECTS += scan-tree.o OBJECTS += shared.o OBJECTS += ui-atom.o OBJECTS += ui-blob.o OBJECTS += ui-clone.o OBJECTS += ui-commit.o OBJECTS += ui-diff.o OBJECTS += ui-log.o OBJECTS += ui-patch.o OBJECTS += ui-plain.o OBJECTS += ui-refs.o OBJECTS += ui-repolist.o OBJECTS += ui-shared.o OBJECTS += ui-snapshot.o OBJECTS += ui-ssdiff.o OBJECTS += ui-stats.o OBJECTS += ui-summary.o OBJECTS += ui-tag.o OBJECTS += ui-tree.o OBJECTS += vector.o ifdef NEEDS_LIBICONV EXTLIBS += -liconv endif .PHONY: all libgit test install uninstall clean force-version get-git \ - doc man-doc html-doc clean-doc + doc clean-doc install-doc install-man install-html install-pdf \ + uninstall-doc uninstall-man uninstall-html uninstall-pdf all: cgit VERSION: force-version @./gen-version.sh "$(CGIT_VERSION)" -include VERSION CFLAGS += -g -Wall -Igit CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER)' CFLAGS += -DCGIT_VERSION='"$(CGIT_VERSION)"' CFLAGS += -DCGIT_CONFIG='"$(CGIT_CONFIG)"' CFLAGS += -DCGIT_SCRIPT_NAME='"$(CGIT_SCRIPT_NAME)"' CFLAGS += -DCGIT_CACHE_ROOT='"$(CACHE_ROOT)"' GIT_OPTIONS = prefix=/usr ifdef NO_ICONV CFLAGS += -DNO_ICONV endif ifdef NO_STRCASESTR CFLAGS += -DNO_STRCASESTR endif ifdef NO_C99_FORMAT CFLAGS += -DNO_C99_FORMAT endif ifdef NO_OPENSSL CFLAGS += -DNO_OPENSSL GIT_OPTIONS += NO_OPENSSL=1 else EXTLIBS += -lcrypto endif cgit: $(OBJECTS) libgit $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o cgit $(OBJECTS) $(EXTLIBS) cgit.o: VERSION ifneq "$(MAKECMDGOALS)" "clean" -include $(OBJECTS:.o=.d) endif libgit: $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) libgit.a $(QUIET_SUBDIR0)git $(QUIET_SUBDIR1) NO_CURL=1 $(GIT_OPTIONS) xdiff/lib.a test: all $(QUIET_SUBDIR0)tests $(QUIET_SUBDIR1) all install: all $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH) $(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH) $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png + $(INSTALL) -m 0755 -d $(DESTDIR)$(filterdir) + $(INSTALL) -m 0755 filters/* $(DESTDIR)$(filterdir) + +install-doc: install-man install-html install-pdf + +install-man: doc-man + $(INSTALL) -m 0755 -d $(DESTDIR)$(mandir)/man5 + $(INSTALL) -m 0644 $(DOC_MAN5) $(DESTDIR)$(mandir)/man5 + +install-html: doc-html + $(INSTALL) -m 0755 -d $(DESTDIR)$(htmldir) + $(INSTALL) -m 0644 $(DOC_HTML) $(DESTDIR)$(htmldir) + +install-pdf: doc-pdf + $(INSTALL) -m 0755 -d $(DESTDIR)$(pdfdir) + $(INSTALL) -m 0644 $(DOC_PDF) $(DESTDIR)$(pdfdir) uninstall: rm -f $(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME) rm -f $(CGIT_DATA_PATH)/cgit.css rm -f $(CGIT_DATA_PATH)/cgit.png -doc: man-doc html-doc pdf-doc +uninstall-doc: uninstall-man uninstall-html uninstall-pdf + +uninstall-man: + @for i in $(DOC_MAN5); do \ + rm -fv $(DESTDIR)$(mandir)/man5/$$i; \ + done + +uninstall-html: + @for i in $(DOC_HTML); do \ + rm -fv $(DESTDIR)$(htmldir)/$$i; \ + done + +uninstall-pdf: + @for i in $(DOC_PDF); do \ + rm -fv $(DESTDIR)$(pdfdir)/$$i; \ + done + +doc: doc-man doc-html doc-pdf +doc-man: doc-man5 +doc-man5: $(DOC_MAN5) +doc-html: $(DOC_HTML) +doc-pdf: $(DOC_PDF) -man-doc: cgitrc.5.txt - a2x -f manpage cgitrc.5.txt +%.5 : %.5.txt + a2x -f manpage $< -html-doc: cgitrc.5.txt - a2x -f xhtml --stylesheet=cgit-doc.css cgitrc.5.txt +$(DOC_HTML): %.html : %.txt + a2x -f xhtml --stylesheet=cgit-doc.css $< -pdf-doc: cgitrc.5.txt +$(DOC_PDF): %.pdf : %.txt a2x -f pdf cgitrc.5.txt clean: clean-doc rm -f cgit VERSION *.o *.d clean-doc: rm -f cgitrc.5 cgitrc.5.html cgitrc.5.pdf cgitrc.5.xml cgitrc.5.fo get-git: curl $(GIT_URL) | tar -xj && rm -rf git && mv git-$(GIT_VER) git @@ -553,193 +553,207 @@ a.remote-deco { background-color: #ccccff; border: solid 1px #000077; } a.deco { margin: 0px 0.5em; padding: 0px 0.25em; background-color: #ff8888; border: solid 1px #770000; } div.commit-subject a.branch-deco, div.commit-subject a.tag-deco, div.commit-subject a.remote-deco, div.commit-subject a.deco { margin-left: 1em; font-size: 75%; } table.stats { border: solid 1px black; border-collapse: collapse; } table.stats th { text-align: left; padding: 1px 0.5em; background-color: #eee; border: solid 1px black; } table.stats td { text-align: right; padding: 1px 0.5em; border: solid 1px black; } table.stats td.total { font-weight: bold; text-align: left; } table.stats td.sum { color: #c00; font-weight: bold; /* background-color: #eee; */ } table.stats td.left { text-align: left; } table.vgraph { border-collapse: separate; border: solid 1px black; height: 200px; } table.vgraph th { background-color: #eee; font-weight: bold; border: solid 1px white; padding: 1px 0.5em; } table.vgraph td { vertical-align: bottom; padding: 0px 10px; } table.vgraph div.bar { background-color: #eee; } table.hgraph { border: solid 1px black; width: 800px; } table.hgraph th { background-color: #eee; font-weight: bold; border: solid 1px black; padding: 1px 0.5em; } table.hgraph td { vertical-align: center; padding: 2px 2px; } table.hgraph div.bar { background-color: #eee; height: 1em; } table.ssdiff { width: 100%; } table.ssdiff td { font-size: 75%; font-family: monospace; white-space: pre; padding: 1px 4px 1px 4px; border-left: solid 1px #aaa; border-right: solid 1px #aaa; } table.ssdiff td.add { color: black; background: #cfc; min-width: 50%; } table.ssdiff td.add_dark { color: black; background: #aca; min-width: 50%; } table.ssdiff span.add { background: #cfc; font-weight: bold; } table.ssdiff td.del { color: black; background: #fcc; min-width: 50%; } table.ssdiff td.del_dark { color: black; background: #caa; min-width: 50%; } table.ssdiff span.del { background: #fcc; font-weight: bold; } table.ssdiff td.changed { color: black; background: #ffc; min-width: 50%; } table.ssdiff td.changed_dark { color: black; background: #cca; min-width: 50%; } table.ssdiff td.lineno { color: black; background: #eee; text-align: right; width: 3em; min-width: 3em; } table.ssdiff td.hunk { color: #black; background: #ccf; border-top: solid 1px #aaa; border-bottom: solid 1px #aaa; } table.ssdiff td.head { border-top: solid 1px #aaa; border-bottom: solid 1px #aaa; } table.ssdiff td.head div.head { font-weight: bold; color: black; } table.ssdiff td.foot { border-top: solid 1px #aaa; border-left: none; border-right: none; border-bottom: none; } table.ssdiff td.space { border: none; } table.ssdiff td.space div { min-height: 3em; -}
\ No newline at end of file +} + +/* Syntax highlighting */ +table.blob .num { color:#2928ff; } +table.blob .esc { color:#ff00ff; } +table.blob .str { color:#ff0000; } +table.blob .dstr { color:#818100; } +table.blob .slc { color:#838183; font-style:italic; } +table.blob .com { color:#838183; font-style:italic; } +table.blob .dir { color:#008200; } +table.blob .sym { color:#000000; } +table.blob .kwa { color:#000000; font-weight:bold; } +table.blob .kwb { color:#830000; } +table.blob .kwc { color:#000000; font-weight:bold; } +table.blob .kwd { color:#010181; } diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 75b6584..8e51ca5 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -242,329 +242,329 @@ remove-suffix:: If set to "1" and scan-path is enabled, if any repositories are found with a suffix of ".git", this suffix will be removed for the url and name. Default value: "0". See also: scan-path. renamelimit:: Maximum number of files to consider when detecting renames. The value "-1" uses the compiletime value in git (for further info, look at `man git-diff`). Default value: "-1". repo.group:: Legacy alias for "section". This option is deprecated and will not be supported in cgit-1.0. robots:: Text used as content for the "robots" meta-tag. Default value: "index, nofollow". root-desc:: Text printed below the heading on the repository index page. Default value: "a fast webinterface for the git dscm". root-readme:: The content of the file specified with this option will be included verbatim below the "about" link on the repository index page. Default value: none. root-title:: Text printed as heading on the repository index page. Default value: "Git Repository Browser". scan-path:: A path which will be scanned for repositories. If caching is enabled, the result will be cached as a cgitrc include-file in the cache directory. If project-list has been defined prior to scan-path, scan-path loads only the directories listed in the file pointed to by project-list. Default value: none. See also: cache-scanrc-ttl, project-list. section:: The name of the current repository section - all repositories defined after this option will inherit the current section name. Default value: none. section-from-path:: A number which, if specified before scan-path, specifies how many path elements from each repo path to use as a default section name. If negative, cgit will discard the specified number of path elements above the repo directory. Default value: 0. side-by-side-diffs:: If set to "1" shows side-by-side diffs instead of unidiffs per default. Default value: "0". snapshots:: Text which specifies the default set of snapshot formats generated by cgit. The value is a space-separated list of zero or more of the values "tar", "tar.gz", "tar.bz2" and "zip". Default value: none. source-filter:: Specifies a command which will be invoked to format plaintext blobs in the tree view. The command will get the blob content on its STDIN and the name of the blob as its only command line argument. The STDOUT from the command will be included verbatim as the blob contents, i.e. this can be used to implement e.g. syntax highlighting. Default value: none. summary-branches:: Specifies the number of branches to display in the repository "summary" view. Default value: "10". summary-log:: Specifies the number of log entries to display in the repository "summary" view. Default value: "10". summary-tags:: Specifies the number of tags to display in the repository "summary" view. Default value: "10". strict-export:: Filename which, if specified, needs to be present within the repository for cgit to allow access to that repository. This can be used to emulate gitweb's EXPORT_OK and STRICT_EXPORT functionality and limit cgit's repositories to match those exported by git-daemon. This option MUST come before 'scan-path'. virtual-root:: Url which, if specified, will be used as root for all cgit links. It will also cause cgit to generate 'virtual urls', i.e. urls like '/cgit/tree/README' as opposed to '?r=cgit&p=tree&path=README'. Default value: none. NOTE: cgit has recently learned how to use PATH_INFO to achieve the same kind of virtual urls, so this option will probably be deprecated. REPOSITORY SETTINGS ------------------- repo.about-filter:: Override the default about-filter. Default value: none. See also: "enable-filter-overrides". repo.clone-url:: A list of space-separated urls which can be used to clone this repo. Default value: none. repo.commit-filter:: Override the default commit-filter. Default value: none. See also: "enable-filter-overrides". repo.defbranch:: The name of the default branch for this repository. If no such branch exists in the repository, the first branch name (when sorted) is used as default instead. Default value: "master". repo.desc:: The value to show as repository description. Default value: none. repo.enable-log-filecount:: A flag which can be used to disable the global setting `enable-log-filecount'. Default value: none. repo.enable-log-linecount:: A flag which can be used to disable the global setting `enable-log-linecount'. Default value: none. repo.enable-remote-branches:: Flag which, when set to "1", will make cgit display remote branches in the summary and refs views. Default value: <enable-remote-branches>. repo.enable-subject-links:: A flag which can be used to override the global setting `enable-subject-links'. Default value: none. repo.max-stats:: Override the default maximum statistics period. Valid values are equal to the values specified for the global "max-stats" setting. Default value: none. repo.name:: The value to show as repository name. Default value: <repo.url>. repo.owner:: A value used to identify the owner of the repository. Default value: none. repo.path:: An absolute path to the repository directory. For non-bare repositories this is the .git-directory. Default value: none. repo.readme:: A path (relative to <repo.path>) which specifies a file to include verbatim as the "About" page for this repo. You may also specify a git refspec by head or by hash by prepending the refspec followed by a colon. For example, "master:docs/readme.mkd" Default value: <readme>. repo.snapshots:: A mask of allowed snapshot-formats for this repo, restricted by the "snapshots" global setting. Default value: <snapshots>. repo.section:: Override the current section name for this repository. Default value: none. repo.source-filter:: Override the default source-filter. Default value: none. See also: "enable-filter-overrides". repo.url:: The relative url used to access the repository. This must be the first setting specified for each repo. Default value: none. REPOSITORY-SPECIFIC CGITRC FILE ------------------------------- When the option "scan-path" is used to auto-discover git repositories, cgit will try to parse the file "cgitrc" within any found repository. Such a repo-specific config file may contain any of the repo-specific options described above, except "repo.url" and "repo.path". Additionally, the "filter" options are only acknowledged in repo-specific config files when "enable-filter-overrides" is set to "1". Note: the "repo." prefix is dropped from the option names in repo-specific config files, e.g. "repo.desc" becomes "desc". EXAMPLE CGITRC FILE ------------------- .... # Enable caching of up to 1000 output entriess cache-size=1000 # Specify some default clone prefixes -clone-prefix=git://foobar.com ssh://foobar.com/pub/git http://foobar.com/git +clone-prefix=git://example.com ssh://example.com/pub/git http://example.com/git # Specify the css url css=/css/cgit.css # Show extra links for each repository on the index page enable-index-links=1 # Show number of affected files per commit on the log pages enable-log-filecount=1 # Show number of added/removed lines per commit on the log pages enable-log-linecount=1 # Add a cgit favicon favicon=/favicon.ico # Use a custom logo logo=/img/mylogo.png # Enable statistics per week, month and quarter max-stats=quarter # Set the title and heading of the repository index page -root-title=foobar.com git repositories +root-title=example.com git repositories # Set a subheading for the repository index page root-desc=tracking the foobar development -# Include some more info about foobar.com on the index page +# Include some more info about example.com on the index page root-readme=/var/www/htdocs/about.html # Allow download of tar.gz, tar.bz2 and zip-files snapshots=tar.gz tar.bz2 zip ## ## List of common mimetypes ## mimetype.gif=image/gif mimetype.html=text/html mimetype.jpg=image/jpeg mimetype.jpeg=image/jpeg mimetype.pdf=application/pdf mimetype.png=image/png mimetype.svg=image/svg+xml ## ## List of repositories. ## PS: Any repositories listed when section is unset will not be ## displayed under a section heading ## PPS: This list could be kept in a different file (e.g. '/etc/cgitrepos') ## and included like this: ## include=/etc/cgitrepos ## repo.url=foo repo.path=/pub/git/foo.git repo.desc=the master foo repository -repo.owner=fooman@foobar.com +repo.owner=fooman@example.com repo.readme=info/web/about.html repo.url=bar repo.path=/pub/git/bar.git repo.desc=the bars for your foo -repo.owner=barman@foobar.com +repo.owner=barman@example.com repo.readme=info/web/about.html # The next repositories will be displayed under the 'extras' heading section=extras repo.url=baz repo.path=/pub/git/baz.git repo.desc=a set of extensions for bar users repo.url=wiz repo.path=/pub/git/wiz.git repo.desc=the wizard of foo # Add some mirrored repositories section=mirrors repo.url=git repo.path=/pub/git/git.git repo.desc=the dscm repo.url=linux repo.path=/pub/git/linux.git repo.desc=the kernel # Disable adhoc downloads of this repo repo.snapshots=0 # Disable line-counts for this repo repo.enable-log-linecount=0 # Restrict the max statistics period for this repo repo.max-stats=month .... BUGS ---- Comments currently cannot appear on the same line as a setting; the comment will be included as part of the value. E.g. this line: robots=index # allow indexing will generate the following html element: <meta name='robots' content='index # allow indexing'/> AUTHOR ------ Lars Hjemli <hjemli@gmail.com> Jason A. Donenfeld <Jason@zx2c4.com> diff --git a/git b/git -Subproject 87b50542a08ac6caa083ddc376e674424e37940 +Subproject 7ed863a85a6ce2c4ac4476848310b8f917ab41f @@ -1,194 +1,192 @@ -#include <string-list.h> - #include "cgit.h" #include "html.h" #include "ui-shared.h" #include "ui-stats.h" #ifdef NO_C99_FORMAT #define SZ_FMT "%u" #else #define SZ_FMT "%zu" #endif #define MONTHS 6 struct authorstat { long total; struct string_list list; }; #define DAY_SECS (60 * 60 * 24) #define WEEK_SECS (DAY_SECS * 7) static void trunc_week(struct tm *tm) { time_t t = timegm(tm); t -= ((tm->tm_wday + 6) % 7) * DAY_SECS; gmtime_r(&t, tm); } static void dec_week(struct tm *tm) { time_t t = timegm(tm); t -= WEEK_SECS; gmtime_r(&t, tm); } static void inc_week(struct tm *tm) { time_t t = timegm(tm); t += WEEK_SECS; gmtime_r(&t, tm); } static char *pretty_week(struct tm *tm) { static char buf[10]; strftime(buf, sizeof(buf), "W%V %G", tm); return buf; } static void trunc_month(struct tm *tm) { tm->tm_mday = 1; } static void dec_month(struct tm *tm) { tm->tm_mon--; if (tm->tm_mon < 0) { tm->tm_year--; tm->tm_mon = 11; } } static void inc_month(struct tm *tm) { tm->tm_mon++; if (tm->tm_mon > 11) { tm->tm_year++; tm->tm_mon = 0; } } static char *pretty_month(struct tm *tm) { static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; return fmt("%s %d", months[tm->tm_mon], tm->tm_year + 1900); } static void trunc_quarter(struct tm *tm) { trunc_month(tm); while(tm->tm_mon % 3 != 0) dec_month(tm); } static void dec_quarter(struct tm *tm) { dec_month(tm); dec_month(tm); dec_month(tm); } static void inc_quarter(struct tm *tm) { inc_month(tm); inc_month(tm); inc_month(tm); } static char *pretty_quarter(struct tm *tm) { return fmt("Q%d %d", tm->tm_mon / 3 + 1, tm->tm_year + 1900); } static void trunc_year(struct tm *tm) { trunc_month(tm); tm->tm_mon = 0; } static void dec_year(struct tm *tm) { tm->tm_year--; } static void inc_year(struct tm *tm) { tm->tm_year++; } static char *pretty_year(struct tm *tm) { return fmt("%d", tm->tm_year + 1900); } struct cgit_period periods[] = { {'w', "week", 12, 4, trunc_week, dec_week, inc_week, pretty_week}, {'m', "month", 12, 4, trunc_month, dec_month, inc_month, pretty_month}, {'q', "quarter", 12, 4, trunc_quarter, dec_quarter, inc_quarter, pretty_quarter}, {'y', "year", 12, 4, trunc_year, dec_year, inc_year, pretty_year}, }; /* Given a period code or name, return a period index (1, 2, 3 or 4) * and update the period pointer to the correcsponding struct. * If no matching code is found, return 0. */ int cgit_find_stats_period(const char *expr, struct cgit_period **period) { int i; char code = '\0'; if (!expr) return 0; if (strlen(expr) == 1) code = expr[0]; for (i = 0; i < sizeof(periods) / sizeof(periods[0]); i++) if (periods[i].code == code || !strcmp(periods[i].name, expr)) { if (period) *period = &periods[i]; return i+1; } return 0; } const char *cgit_find_stats_periodname(int idx) { if (idx > 0 && idx < 4) return periods[idx - 1].name; else return ""; } static void add_commit(struct string_list *authors, struct commit *commit, struct cgit_period *period) { struct commitinfo *info; struct string_list_item *author, *item; struct authorstat *authorstat; struct string_list *items; char *tmp; struct tm *date; time_t t; info = cgit_parse_commit(commit); tmp = xstrdup(info->author); author = string_list_insert(authors, tmp); if (!author->util) author->util = xcalloc(1, sizeof(struct authorstat)); else free(tmp); authorstat = author->util; items = &authorstat->list; t = info->committer_date; date = gmtime(&t); period->trunc(date); tmp = xstrdup(period->pretty(date)); |