aboutsummaryrefslogtreecommitdiffstats
path: root/ui-patch.c
Commit message (Expand)AuthorAgeFilesLines
* global: replace hard coded hash length•••With sha1 we had a guaranteed length of 40 hex chars. This changes now that we have to support sha256 with 64 hex chars... Support both. Signed-off-by: Christian Hesse <mail@eworm.de> Christian Hesse2020-10-201-1/+1
* git: update to v2.19.1•••Update to git version v2.19.1. Required changes follow upstream commits: * commit: add repository argument to get_cached_commit_buffer (3ce85f7e5a41116145179f0fae2ce6d86558d099) * commit: add repository argument to lookup_commit_reference (2122f6754c93be8f02bfb5704ed96c88fc9837a8) * object: add repository argument to parse_object (109cd76dd3467bd05f8d2145b857006649741d5c) * tag: add repository argument to deref_tag (a74093da5ed601a09fa158e5ba6f6f14c1142a3e) * tag: add repository argument to lookup_tag (ce71efb713f97f476a2d2ab541a0c73f684a5db3) * tree: add repository argument to lookup_tree (f86bcc7b2ce6cad68ba1a48a528e380c6126705e) * archive.c: avoid access to the_index (b612ee202a48f129f81f8f6a5af6cf71d1a9caef) * for_each_*_object: move declarations to object-store.h (0889aae1cd18c1804ba01c1a4229e516dfb9fe9b) Signed-off-by: Christian Hesse <mail@eworm.de> Christian Hesse2018-10-121-2/+2
* ui-patch: ban sprintf()•••Git upstream bans sprintf() with commit: banned.h: mark sprintf() as banned cc8fdaee1eeaf05d8dd55ff11f111b815f673c58 Signed-off-by: Christian Hesse <mail@eworm.de> Christian Hesse2018-09-111-2/+5
* cache: flush stdio before restoring FDs•••As described in commit 2efb59e (ui-patch: Flush stdout after outputting data, 2014-06-11), we need to ensure that stdout is flushed before restoring the file descriptor when writing to the cache. It turns out that it's not just ui-patch that is affected by this but also raw diff which writes to stdout internally. Let's avoid risking more places doing this by ensuring that stdout is flushed after writing in fill_slot(). Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2017-10-031-2/+0
* git: update to v2.14•••Numerous changes were made to git functions to use an object_id structure rather than sending sha1 hashes as raw unsigned character arrays. The functions that affect cgit are: parse_object, lookup_commit_reference, lookup_tag, lookup_tree, parse_tree_indirect, diff_root_tree_sha1, diff_tree_sha1, and format_display_notes. Commit b2141fc (config: don't include config.h by default) made it necessary to that config.h be explicitly included when needed. Commit 07a3d41 (grep: remove regflags from the public grep_opt API) removed one way of specifying the ignore-case grep option. Signed-off-by: Jeff Smith <whydoubt@gmail.com> Jeff Smith2017-08-101-2/+2
* ui-patch: fix crash when using path limit•••The array passed to setup_revisions() must be NULL-terminated. Fixes a regression introduced in 455b598 (ui-patch.c: Use log_tree_commit() to generate diffs, 2013-08-20). Reported-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Lukas Fleischer <lfleischer@lfos.de> Lukas Fleischer2017-01-231-4/+3
* patch: reapply path limit•••This was originally applied added in commit eac1b67 (ui-patch: Apply path limit to generated patch, 2010-06-10) but the ability to limit patches to particular paths was lost in commit 455b598 (ui-patch.c: Use log_tree_commit() to generate diffs, 2013-08-20). The new output is slightly different from the original because Git's diff infrastructure doesn't give us a way to insert an annotation immediately after the "---" separator, so the commit has moved below the diff stat. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2016-10-121-2/+8
* ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid'•••Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id oid'. We have some code that can be changed independent from upstream. So here we go... Christian Hesse2016-10-041-11/+11
* git: update to v2.7.0•••Update to git version v2.7.0. * Upstream commit ed1c9977cb1b63e4270ad8bdf967a2d02580aa08 (Remove get_object_hash.) changed API: Convert all instances of get_object_hash to use an appropriate reference to the hash member of the oid member of struct object. This provides no functional change, as it is essentially a macro substitution. Signed-off-by: Christian Hesse <mail@eworm.de> Christian Hesse2016-01-131-1/+1
* patch: use cgit_print_error_page() for HTTP status codes•••Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2015-08-141-8/+8
* ui-patch: make sure to send http headers•••Requesting a text/plain patch with bad commit id made cgit send text without proper http headers. This results in "500 Internal Server Error" with "Premature end of script headers" in server logs. So print http headers before error message and return. Signed-off-by: Christian Hesse <mail@eworm.de> Reviewed-by: John Keeping <john@keeping.me.uk> Christian Hesse2015-08-141-0/+4
* ui-patch: match git-format-patch(1) output•••Using (DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH) causes Git to emit a "---" line between the commit message and the body of the patch, which fixes a regression introduced in commit 455b598 (ui-patch.c: Use log_tree_commit() to generate diffs, 2013-08-20), prior to which we inserted the "---" line ourselves. DIFF_FORMAT_SUMMARY is added so that we match the output of git-format-patch(1) without the "-p" option. Signed-off-by: John Keeping <john@keeping.me.uk> John Keeping2014-12-281-1/+2
* ui-patch: Flush stdout after outputting data•••It looks like cached patches are truncated to the nearest 1024-byte boundary in the patch body. E.g.: > mricon@nikko:[/tmp]$ wget -O no-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=6e1b4fdad5157bb9e88777d525704aba24389bee" ... > 2014-06-11 15:34:51 (80.4 MB/s) - ‘no-cache’ saved [4767] Patch is complete, without truncation. Next hit, with cache in place: > mricon@nikko:[/tmp]$ wget -O yes-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=6e1b4 > fdad5157bb9e88777d525704aba24389bee" ... > 2014-06-11 15:35:01 (17.0 MB/s) - ‘yes-cache’ saved [4096/4096] Length truncated to 4096. The cache on disk looks truncated as well, so the bug must me during the process of saving cache. The same is true for larger patches: > mricon@nikko:[/tmp]$ wget -O no-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=2840c566e95599cd60c7143762ca8b49d9395050" ... > 2014-06-11 15:41:33 (1.07 MB/s) - ‘no-cache’ saved [979644] 979644 bytes with a cache-miss > mricon@nikko:[/tmp]$ wget -O yes-cache > "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=2840c > 566e95599cd60c7143762ca8b49d9395050" ... > 2014-06-11 15:41:46 (1.05 MB/s) - ‘yes-cache’ saved [978944] 978944 (956KB exactly) with a cache-hit Since the "html" functions use raw write(2) to STDIO_FILENO, we don't notice problems with most pages, but raw patches write using printf(3). This is fine if we're outputting straight to stdout since the buffers are flushed on exit, but we close the cache output before this, so the cached output ends up being truncated. Make sure the buffers are flushed when we finish outputting a patch so that we avoid this. No other UIs use printf(3) so we do not need to worry about them. Actually, it's slightly more interesting than this... since we don't set GIT_FLUSH, Git decides whether or not it will flush stdout after writing each commit based on whether or not stdout points to a regular file (in maybe_flush_or_die()). Which means that when writing directly to the webserver, Git flushes stdout for us, but when we redirect stdout to the cache it points to a regular file so Git no longer flushes the output for us. The patch is still correct, but perhaps the full explanation is interesting! Reported-by: Konstantin Ryabitsev <mricon@kernel.org> John Keeping2014-06-281-0/+2
* Switch to exclusively using global ctx•••Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2014-01-171-1/+1
* Update copyright information•••* Name "cgit Development Team" as copyright holder to avoid listing every single developer. * Update copyright ranges. Signed-off-by: Lukas Fleischer <cgit@crytocrack.de> Lukas Fleischer2014-01-081-1/+1
* ui-patch.c: Add additional newline after each patch•••For consistency with git-format-patch(1). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-261-1/+1
* ui-patch.c: Fix signature delimiter•••Add a missing space after the "--" marker that introduces the patch signature. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-261-1/+1
* ui-patch.c: Fix formatting for merge commits•••Add max_parents = 1 to the revision walk in order to make sure we do not include the footer signature twice for merge commits. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-221-0/+1
* ui-patch: Rename variables•••Rename parameters and local variables to match those from ui-diff. Also, convert a "char *" to "const char *". Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-201-16/+17
* Allow for creating patch series•••This allows for specifying a revision range using the id2 parameter of /patch/. The output that is produced is similar to $ git format-patch --stdout id2..id Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-201-5/+18
* ui-patch.c: Use log_tree_commit() to generate diffs•••Instead of using our own formatting, use log_tree_commit() from Git to create patches. This removes unnecessary duplicate code and also fixes a bug with e-mail address formatting that existed in our own implementation. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-201-23/+28
* Extract filepair_cb from ui-patch.c•••Move filepair_cb() from ui-patch.c to ui-shared.c and rename it to filepair_cb_raw(). This callback will be used in ui-diff.c in a follow-up patch. Note that it is not straightforward to extract filepair_cb() from ui-diff.c which is why it is not done here as well. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> Lukas Fleischer2013-08-161-73/+1
* Convert cgit_print_error to a variadic function•••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> John Keeping2013-04-081-2/+2
* Always #include corresponding .h in .c files•••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> John Keeping2013-04-081-0/+1
* ui-patch: use cgit_version not CGIT_VERSION•••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> John Keeping2013-03-201-1/+1
* Format git diff headers correctly when adding or removing files.•••Copying the output of cgit and using it in patches now works when adding files to or removing files from the repository. This is helpful for people who use cgit in their patch workflow. Michael Halstead2012-11-151-7/+12
* 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> Johan Herland2010-07-181-2/+2
* 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> Johan Herland2010-06-191-1/+1
* ui-patch: Apply path limit to generated patch•••Also indicate in the comment section of the patch that a path limit was applied, too easily see when a generated patch is only partial. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Johan Herland2010-06-191-2/+4
* Introduce noplainemail option to hide email adresses from spambots•••Signed-off-by: Martin Szulecki <opensuse@sukimashita.com> Martin Szulecki2009-08-081-1/+5
* 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> Lars Hjemli2009-01-311-1/+8
* ui-patch: whitespace changes in the patch generation code•••Add a space between the committer name and email, and remove superfluous spaces in the date header. This makes cgit-generated patches match the output from git-format-patch almost exactly, at least as far as the email headers go. Signed-off-by: Tomas Carnecky <tom@dbservice.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Tomas Carnecky2008-12-301-2/+2
* Added `local-time` option to cgitrc•••When `local-time` is set, commit, tag and patch timestamps will be printed in the servers timezone. Also, regardless of the value of `local-time`, these timestamps will now always show the timezone. Signed-off-by: Stefan Naewe <stefan.naewe@atlas-elektronik.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com> Stefan Naewe2008-08-011-1/+1
* Merge branch 'lh/cleanup'•••* lh/cleanup: (21 commits) Reset ctx.repo to NULL when the config parser is finished Move cgit_parse_query() from parsing.c to html.c as http_parse_querystring() Move function for configfile parsing into configfile.[ch] Add cache.h Remove global and obsolete cgit_cmd Makefile: copy the QUIET constructs from the Makefile in git.git Move cgit_version from shared.c to cgit.c Makefile: autobuild dependency rules Initial Makefile cleanup Move non-generic functions from shared.c to cgit.c Add ui-shared.h Add separate header-files for each page/view Refactor snapshot support Add command dispatcher Remove obsolete cacheitem parameter to ui-functions Add struct cgit_page to cgit_context Introduce html.h Improve initialization of git directory Move cgit_repo into cgit_context Add all config variables into struct cgit_context ... Lars Hjemli2008-04-081-3/+7
|\
| * Add ui-shared.h•••This is finally a proper headerfile for the shared ui-functions which used to reside in cgit.h Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2008-03-241-0/+1
| * Remove obsolete cacheitem parameter to ui-functions•••This parameter hasn't been used for a very long time... Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2008-03-241-1/+1
| * Add struct cgit_page to cgit_context•••This struct is used when generating http headers, and as such is another small step towards the goal of the whole cleanup series; to invoke each page/view function with a function pointer. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2008-03-241-1/+3
| * Introduce html.h•••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> Lars Hjemli2008-03-181-0/+1
| * Introduce struct cgit_context•••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> Lars Hjemli2008-02-161-1/+1
* | Fix segfault in patch view for root commit•••The code for patch view assumed the current commit would always have a parent, which made cgit segfault when that wasn't the case. This fixes the bug and adds a test-script for patch view which includes a test for the inital commit. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2008-03-171-1/+5
|/
* Check for NULL-subject in patch view•••While at it, make sure the commit message ends with a '\n'. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2008-01-101-1/+6
* Add plain patch view•••The new view mimics the output from `git format-patch`, making it possible to cherry-pick directly from cgit with something like `curl $url | git am`. Inspired by a patch to `git-apply` by Mike Hommey: http://thread.gmane.org/gmane.comp.version-control.git/67611/focus=67610 Signed-off-by: Lars Hjemli <hjemli@gmail.com> Lars Hjemli2007-12-111-0/+105