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>
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>
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>
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>
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>
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>
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 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>
* 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>
When a ref refers to something other then a commit or tag object, cgit
could segfault when trying to display the tag info.
Noticed-by: Eugene Sajine <euguess@gmail.com>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This includes adding a path argument to cgit_commit_link() and updating all
its callers. The callers from within the commit page (i.e. the "commit",
"unidiff"/"side-by-side diff" and "parent" links) all preserve the path
limit of the current commit page. All other callers pass NULL (i.e. no path
limit).
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
A new config option side-by-side-diffs added, defaulting to 0,
meaning unidiff. Also a query option (ss) is used toggle this.
In the commit page you can switch between the two diff formats by
clicking on the link on the "commit"-row, to the right of (patch).
In the diff page you can switch by using the link at the start
of the page.
All commit-links and diff-links will remember the choice.
Signed-off-by: Ragnar Ouchterlony <ragnar@lysator.liu.se>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
When a lightweight tag is referencing a commit object, cgit now uses
the commit date when comparing tag age. Also, the commitdate and author
info is printed in the refs view, making lightweight tags appear similar
to annotated tags.
Signed-off-by: Stefan Bühler <lighttpd@stbuehler.de>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
The snapshot function has only been linked to from the commit page while
users often would want to download a certain release. With this patch,
direct download links will now be printed for each tagged release on the
repo summary page.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Some users prefer to see the full message, so to make these users happy
the new querystring parameter "showmsg" can be used to print the full
commit message per log entry.
A link is provided in the log heading to make this function accessible,
and all links and forms tries to preserve the users preference.
Note: the new link is not displayed on the summary page since the point
of the summary page is to be a summary, but it is still obeyed if specified
manually.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
All html-functions can be quite easily separated from the rest of cgit, so
lets do it; the only issue was html_filemode which uses some git-defined
macros so the function is moved into ui-shared.c::cgit_print_filemode().
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This struct will hold all the cgit runtime information currently found in
a multitude of global variables.
The first cleanup removes all querystring-related variables.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
This enables the new urls $repo/refs, $repo/refs/heads and $repo/refs/tags,
which can be used to print _all_ branches and/or tags.
Signed-off-by: Lars Hjemli <hjemli@gmail.com>