<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/usage.c, branch v2.12.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.12.0</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.12.0'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2017-01-31T21:14:56Z</updated>
<entry>
<title>Merge branch 'jk/vreport-sanitize'</title>
<updated>2017-01-31T21:14:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-01-31T21:14:56Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=daf75f2e6bb9f2f723eb0532c08dd6002fb17190'/>
<id>urn:sha1:daf75f2e6bb9f2f723eb0532c08dd6002fb17190</id>
<content type='text'>
An error message with an ASCII control character like '\r' in it
can alter the message to hide its early part, which is problematic
when a remote side gives such an error message that the local side
will relay with a "remote: " prefix.

* jk/vreport-sanitize:
  vreport: sanitize ASCII control chars
  Revert "vreportf: avoid intermediate buffer"
</content>
</entry>
<entry>
<title>vreport: sanitize ASCII control chars</title>
<updated>2017-01-11T21:54:08Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-01-11T14:02:23Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=f290089879501a855df2eb41db5b38cb0035a765'/>
<id>urn:sha1:f290089879501a855df2eb41db5b38cb0035a765</id>
<content type='text'>
Our error() and die() calls may report messages with
arbitrary data (e.g., filenames or even data from a remote
server). Let's make it harder to cause confusion with
mischievous filenames. E.g., try:

  git rev-parse "$(printf "\rfatal: this argument is too sneaky")" --

or

  git rev-parse "$(printf "\x1b[5mblinky\x1b[0m")" --

Let's block all ASCII control characters, with the exception
of TAB and LF. We use both in our own messages (and we are
necessarily sanitizing the complete output of snprintf here,
as we do not have access to the individual varargs). And TAB
and LF are unlikely to cause confusion (you could put
"\nfatal: sneaky\n" in your filename, but it would at least
not _cover up_ the message leading to it, unlike "\r").

We'll replace the characters with a "?", which is similar to
how "ls" behaves. It might be nice to do something less
lossy, like converting them to "\x" hex codes. But replacing
with a single character makes it easy to do in-place and
without worrying about length limitations. This feature
should kick in rarely enough that the "?" marks are almost
never seen.

We'll leave high-bit characters as-is, as they are likely to
be UTF-8 (though there may be some Unicode mischief you
could cause, which may require further patches).

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Revert "vreportf: avoid intermediate buffer"</title>
<updated>2017-01-11T21:52:00Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-01-11T14:02:03Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=b5a9e435c6dfb40df0a27521c1c6590c8f68ffb2'/>
<id>urn:sha1:b5a9e435c6dfb40df0a27521c1c6590c8f68ffb2</id>
<content type='text'>
This reverts commit f4c3edc0b156362a92bf9de4f0ec794e90a757fc.

The purpose of that commit was to let us write errors of
arbitrary length to stderr by skipping the intermediate
buffer and sending our varargs straight to fprintf. That
works, but it comes with a downside: we do not get access to
the varargs before they are sent to stderr.

On balance, it's not a good tradeoff. Error messages larger
than our 4K buffer are quite uncommon, and we've lost the
ability to make any modifications to the output (e.g., to
remove non-printable characters).

The only way to have both would be one of:

  1. Write into a dynamic buffer. But this is a bad idea for
     a low-level function that may be called when malloc()
     has failed.

  2. Do our own printf-format varargs parsing. This is too
     complex to be worth the trouble.

Let's just revert that change and go back to a fixed buffer.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'cc/apply-am'</title>
<updated>2016-09-19T20:47:18Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-09-19T20:47:17Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=81358dc238372793b1590efa149cc1581d1fbd98'/>
<id>urn:sha1:81358dc238372793b1590efa149cc1581d1fbd98</id>
<content type='text'>
"git am" has been taught to make an internal call to "git apply"'s
innards without spawning the latter as a separate process.

* cc/apply-am: (41 commits)
  builtin/am: use apply API in run_apply()
  apply: learn to use a different index file
  apply: pass apply state to build_fake_ancestor()
  apply: refactor `git apply` option parsing
  apply: change error_routine when silent
  usage: add get_error_routine() and get_warn_routine()
  usage: add set_warn_routine()
  apply: don't print on stdout in verbosity_silent mode
  apply: make it possible to silently apply
  apply: use error_errno() where possible
  apply: make some parsing functions static again
  apply: move libified code from builtin/apply.c to apply.{c,h}
  apply: rename and move opt constants to apply.h
  builtin/apply: rename option parsing functions
  builtin/apply: make create_one_file() return -1 on error
  builtin/apply: make try_create_file() return -1 on error
  builtin/apply: make write_out_results() return -1 on error
  builtin/apply: make write_out_one_result() return -1 on error
  builtin/apply: make create_file() return -1 on error
  builtin/apply: make add_index_file() return -1 on error
  ...
</content>
</entry>
<entry>
<title>usage: add get_error_routine() and get_warn_routine()</title>
<updated>2016-09-07T19:29:53Z</updated>
<author>
<name>Christian Couder</name>
<email>christian.couder@gmail.com</email>
</author>
<published>2016-09-04T20:18:28Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=725149beab088b1368cc01aa3f1a7845db14132d'/>
<id>urn:sha1:725149beab088b1368cc01aa3f1a7845db14132d</id>
<content type='text'>
Let's make it possible to get the current error_routine and warn_routine,
so that we can store them before using set_error_routine() or
set_warn_routine() to use new ones.

This way we will be able put back the original routines, when we are done
with using new ones.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>usage: add set_warn_routine()</title>
<updated>2016-09-07T19:29:53Z</updated>
<author>
<name>Christian Couder</name>
<email>christian.couder@gmail.com</email>
</author>
<published>2016-09-04T20:18:27Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=b83f108b082dfd5452d5c1ab03596fa13750d23f'/>
<id>urn:sha1:b83f108b082dfd5452d5c1ab03596fa13750d23f</id>
<content type='text'>
There are already set_die_routine() and set_error_routine(),
so let's add set_warn_routine() as this will be needed in a
following commit.

Signed-off-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>error_errno: use constant return similar to error()</title>
<updated>2016-08-31T18:11:54Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2016-08-31T03:41:22Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=4df5e91867498f7c6ee4bf5a464a5c24dc89034b'/>
<id>urn:sha1:4df5e91867498f7c6ee4bf5a464a5c24dc89034b</id>
<content type='text'>
Commit e208f9c (make error()'s constant return value more
visible, 2012-12-15) introduced some macro trickery to make
the constant return from error() more visible to callers,
which in turn can help gcc produce better warnings (and
possibly even better code).

Later, fd1d672 (usage.c: add warning_errno() and
error_errno(), 2016-05-08) introduced another variant, and
subsequent commits converted some uses of error() to
error_errno(), losing the magic from e208f9c for those
sites.

As a result, compiling vcs-svn/svndiff.c with "gcc -O3"
produces -Wmaybe-uninitialized false positives (at least
with gcc 6.2.0). Let's give error_errno() the same
treatment, which silences these warnings.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>usage.c: add warning_errno() and error_errno()</title>
<updated>2016-05-09T19:29:08Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-05-08T09:47:22Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=fd1d672300f36b2b06c2951ec450de0cf8f17797'/>
<id>urn:sha1:fd1d672300f36b2b06c2951ec450de0cf8f17797</id>
<content type='text'>
Similar to die_errno(), these functions will append strerror()
automatically.

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>usage.c: move format processing out of die_errno()</title>
<updated>2016-05-09T19:29:08Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2016-05-08T09:47:21Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=58e4e5118ae3707b417a19e8dc9224ac25c3f32f'/>
<id>urn:sha1:58e4e5118ae3707b417a19e8dc9224ac25c3f32f</id>
<content type='text'>
fmt_with_err() will be shared with the coming error_errno() and
warning_errno().

Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>vreportf: avoid intermediate buffer</title>
<updated>2015-08-11T21:29:36Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-08-11T18:13:59Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=f4c3edc0b156362a92bf9de4f0ec794e90a757fc'/>
<id>urn:sha1:f4c3edc0b156362a92bf9de4f0ec794e90a757fc</id>
<content type='text'>
When we call "die(fmt, args...)", we end up in vreportf with
two pieces of information:

  1. The prefix "fatal: "

  2. The original fmt and va_list of args.

We format item (2) into a temporary buffer, and then fprintf
the prefix and the temporary buffer, along with a newline.
This has the unfortunate side effect of truncating any error
messages that are longer than 4096 bytes.

Instead, let's use separate calls for the prefix and
newline, letting us hand the item (2) directly to vfprintf.
This is essentially undoing d048a96 (print
warning/error/fatal messages in one shot, 2007-11-09), which
tried to have the whole output end up in a single `write`
call.

But we can address this instead by explicitly requesting
line-buffering for the output handle, and by making sure
that the buffer is empty before we start (so that outputting
the prefix does not cause a flush due to hitting the buffer
limit).

We may still break the output into two writes if the content
is larger than our buffer, but there's not much we can do
there; depending on the stdio implementation, that might
have happened even with a single fprintf call.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
