summary refs log tree commit diff
path: root/ui-patch.c
AgeCommit message (Collapse)Author
2020-10-20global: replace hard coded hash lengthChristian Hesse
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>
2018-10-12git: update to v2.19.1Christian Hesse
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>
2018-09-11ui-patch: ban sprintf()Christian Hesse
Git upstream bans sprintf() with commit: banned.h: mark sprintf() as banned cc8fdaee1eeaf05d8dd55ff11f111b815f673c58 Signed-off-by: Christian Hesse <mail@eworm.de>
2017-10-03cache: flush stdio before restoring FDsJohn Keeping
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>
2017-08-10git: update to v2.14Jeff Smith
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>
2017-01-23ui-patch: fix crash when using path limitLukas Fleischer
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>
2016-10-12patch: reapply path limitJohn Keeping
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>
2016-10-04ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid'Christian Hesse
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...
2016-01-13git: update to v2.7.0Christian Hesse
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>
2015-08-14patch: use cgit_print_error_page() for HTTP status codesJohn Keeping
Signed-off-by: John Keeping <john@keeping.me.uk>
2015-08-14ui-patch: make sure to send http headersChristian Hesse
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>
2014-12-28ui-patch: match git-format-patch(1) outputJohn Keeping
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>
2014-06-28ui-patch: Flush stdout after outputting dataJohn Keeping
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>
2014-01-17Switch to exclusively using global ctxLukas Fleischer
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>
2014-01-08Update copyright informationLukas Fleischer
* Name "cgit Development Team" as copyright holder to avoid listing every single developer. * Update copyright ranges. Signed-off-by: Lukas Fleischer <cgit@crytocrack.de>
2013-08-26ui-patch.c: Add additional newline after each patchLukas Fleischer
For consistency with git-format-patch(1). Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-08-26ui-patch.c: Fix signature delimiterLukas Fleischer
Add a missing space after the "--" marker that introduces the patch signature. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
2013-08-22ui-patch.c: Fix formatting for merge commitsLukas Fleischer
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>
2013-08-20ui-patch: Rename variablesLukas Fleischer
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>
2013-08-20Allow for creating patch seriesLukas Fleischer
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>
2013-08-20ui-patch.c: Use log_tree_commit() to generate diffsLukas Fleischer
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>
2013-08-16Extract filepair_cb from ui-patch.cLukas Fleischer
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>
2013-04-08Convert cgit_print_error to a variadic functionJohn Keeping
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>
2013-04-08Always #include corresponding .h in .c filesJohn Keeping
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>
2013-03-20ui-patch: use cgit_version not CGIT_VERSIONJohn Keeping
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>
2012-11-15Format git diff headers correctly when adding or removing files.Michael Halstead
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.
2010-07-18Add URL parameter 'ignorews' for optionally ignoring whitespace in diffsJohan Herland
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>
2010-06-19Add URL parameter 'context' for changing the number of context lines in diffsJohan Herland
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>
2010-06-19ui-patch: Apply path limit to generated patchJohan Herland
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>
2009-08-08Introduce noplainemail option to hide email adresses from spambotsMartin Szulecki
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
2009-01-31Handle binary files in diffsLars Hjemli
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>
2008-12-30ui-patch: whitespace changes in the patch generation codeTomas Carnecky
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>
2008-08-01Added `local-time` option to cgitrcStefan Naewe
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>
2008-04-08Merge branch 'lh/cleanup'Lars Hjemli
* 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 ...
2008-03-24Add ui-shared.hLars Hjemli
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>
2008-03-24Remove obsolete cacheitem parameter to ui-functionsLars Hjemli
This parameter hasn't been used for a very long time... Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2008-03-24Add struct cgit_page to cgit_contextLars Hjemli
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>
2008-03-18Introduce html.hLars Hjemli
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>
2008-03-17Fix segfault in patch view for root commitLars Hjemli
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>
2008-02-16Introduce struct cgit_contextLars Hjemli
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>
2008-01-10Check for NULL-subject in patch viewLars Hjemli
While at it, make sure the commit message ends with a '\n'. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2007-12-11Add plain patch viewLars Hjemli
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>