<feed xmlns='http://www.w3.org/2005/Atom'>
<title>cgit/ui-patch.c, branch v1.2</title>
<subtitle>A hyperfast web frontend for git repositories written in C.</subtitle>
<id>http://git.cetero.st/cgit/atom/ui-patch.c?h=v1.2</id>
<link rel='self' href='http://git.cetero.st/cgit/atom/ui-patch.c?h=v1.2'/>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/'/>
<updated>2017-10-03T18:19:34Z</updated>
<entry>
<title>cache: flush stdio before restoring FDs</title>
<updated>2017-10-03T18:19:34Z</updated>
<author>
<name>John Keeping</name>
<email>john@keeping.me.uk</email>
</author>
<published>2017-04-24T18:38:34Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=3b485cc5422f800d142c7023295e82c0a1c10b19'/>
<id>urn:sha1:3b485cc5422f800d142c7023295e82c0a1c10b19</id>
<content type='text'>
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 &lt;john@keeping.me.uk&gt;
</content>
</entry>
<entry>
<title>git: update to v2.14</title>
<updated>2017-08-10T13:58:24Z</updated>
<author>
<name>Jeff Smith</name>
<email>whydoubt@gmail.com</email>
</author>
<published>2017-08-10T00:02:56Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=86a6d358f7a6c2432fde86b9e3c5011a656f20e4'/>
<id>urn:sha1:86a6d358f7a6c2432fde86b9e3c5011a656f20e4</id>
<content type='text'>
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 &lt;whydoubt@gmail.com&gt;
</content>
</entry>
<entry>
<title>ui-patch: fix crash when using path limit</title>
<updated>2017-01-23T17:36:04Z</updated>
<author>
<name>Lukas Fleischer</name>
<email>lfleischer@lfos.de</email>
</author>
<published>2016-11-24T19:14:54Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=be39d22328f841536b8e44e8aaeed80a74ebb353'/>
<id>urn:sha1:be39d22328f841536b8e44e8aaeed80a74ebb353</id>
<content type='text'>
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 &lt;bluewind@xinu.at&gt;
Signed-off-by: Lukas Fleischer &lt;lfleischer@lfos.de&gt;
</content>
</entry>
<entry>
<title>patch: reapply path limit</title>
<updated>2016-10-12T11:28:15Z</updated>
<author>
<name>John Keeping</name>
<email>john@keeping.me.uk</email>
</author>
<published>2016-03-14T22:41:14Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=5fe88a9c81517b1a8a93d930c738cbb6f71dec2a'/>
<id>urn:sha1:5fe88a9c81517b1a8a93d930c738cbb6f71dec2a</id>
<content type='text'>
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 &lt;john@keeping.me.uk&gt;
</content>
</entry>
<entry>
<title>ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid'</title>
<updated>2016-10-04T07:47:18Z</updated>
<author>
<name>Christian Hesse</name>
<email>mail@eworm.de</email>
</author>
<published>2016-09-29T19:51:41Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=85793b8181aa93ef6070f137fcb3caee624849b6'/>
<id>urn:sha1:85793b8181aa93ef6070f137fcb3caee624849b6</id>
<content type='text'>
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...
</content>
</entry>
<entry>
<title>git: update to v2.7.0</title>
<updated>2016-01-13T16:12:17Z</updated>
<author>
<name>Christian Hesse</name>
<email>mail@eworm.de</email>
</author>
<published>2016-01-05T06:38:53Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=559ab5ecc4445c8477ecf62c9fc97efa412dd562'/>
<id>urn:sha1:559ab5ecc4445c8477ecf62c9fc97efa412dd562</id>
<content type='text'>
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 &lt;mail@eworm.de&gt;
</content>
</entry>
<entry>
<title>patch: use cgit_print_error_page() for HTTP status codes</title>
<updated>2015-08-14T13:46:51Z</updated>
<author>
<name>John Keeping</name>
<email>john@keeping.me.uk</email>
</author>
<published>2015-08-14T11:47:07Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=e3e41e5125b1ce270b5afb42beb83e14c0f350cb'/>
<id>urn:sha1:e3e41e5125b1ce270b5afb42beb83e14c0f350cb</id>
<content type='text'>
Signed-off-by: John Keeping &lt;john@keeping.me.uk&gt;
</content>
</entry>
<entry>
<title>ui-patch: make sure to send http headers</title>
<updated>2015-08-14T10:35:25Z</updated>
<author>
<name>Christian Hesse</name>
<email>mail@eworm.de</email>
</author>
<published>2015-08-13T22:02:50Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=aa12084f9835783abbd1f1e4609f8de05e73cec4'/>
<id>urn:sha1:aa12084f9835783abbd1f1e4609f8de05e73cec4</id>
<content type='text'>
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 &lt;mail@eworm.de&gt;
Reviewed-by: John Keeping &lt;john@keeping.me.uk&gt;
</content>
</entry>
<entry>
<title>ui-patch: match git-format-patch(1) output</title>
<updated>2014-12-28T13:44:44Z</updated>
<author>
<name>John Keeping</name>
<email>john@keeping.me.uk</email>
</author>
<published>2014-12-28T13:10:33Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=7552266aaccb9445e082fc04215afcb55ad543d8'/>
<id>urn:sha1:7552266aaccb9445e082fc04215afcb55ad543d8</id>
<content type='text'>
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 &lt;john@keeping.me.uk&gt;
</content>
</entry>
<entry>
<title>ui-patch: Flush stdout after outputting data</title>
<updated>2014-06-28T13:59:15Z</updated>
<author>
<name>John Keeping</name>
<email>john@keeping.me.uk</email>
</author>
<published>2014-06-11T20:01:50Z</published>
<link rel='alternate' type='text/html' href='http://git.cetero.st/cgit/commit/?id=2efb59ed0fa8eced79fa702bc47454d3406c3431'/>
<id>urn:sha1:2efb59ed0fa8eced79fa702bc47454d3406c3431</id>
<content type='text'>
It looks like cached patches are truncated to the nearest 1024-byte
boundary in the patch body. E.g.:

&gt; mricon@nikko:[/tmp]$ wget -O no-cache
&gt; "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=6e1b4fdad5157bb9e88777d525704aba24389bee"
...
&gt; 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:

&gt; mricon@nikko:[/tmp]$ wget -O yes-cache
&gt; "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=6e1b4
&gt; fdad5157bb9e88777d525704aba24389bee"
...
&gt; 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:

&gt; mricon@nikko:[/tmp]$ wget -O no-cache
&gt; "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=2840c566e95599cd60c7143762ca8b49d9395050"
...
&gt; 2014-06-11 15:41:33 (1.07 MB/s) - ‘no-cache’ saved [979644]

979644 bytes with a cache-miss

&gt; mricon@nikko:[/tmp]$ wget -O yes-cache
&gt; "http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/patch/?id=2840c
&gt; 566e95599cd60c7143762ca8b49d9395050"
...
&gt; 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 &lt;mricon@kernel.org&gt;
</content>
</entry>
</feed>
