All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Ramsay Jones <ramsay@ramsay1.demon.co.uk>,
	GIT Mailing-list <git@vger.kernel.org>,
	Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Subject: Re: [PATCH] pretty: Fix bug in truncation support for %>, %< and %><
Date: Mon, 29 Apr 2013 10:55:51 -0700	[thread overview]
Message-ID: <20130429175551.GA24467@google.com> (raw)
In-Reply-To: <517C2A68.4030802@ramsay1.demon.co.uk>

Hi,

Ramsay Jones wrote:

> Some systems experience failures in t4205-*.sh (tests 18-20, 27)
> which all relate to the use of truncation with the %< padding
> placeholder. This capability was added in the commit a7f01c6b
> ("pretty: support truncating in %>, %< and %><", 19-04-2013).

This is reproducible when running the test suite for 1.8.3-rc0 on some
Debian test machines (ARM, ia64, powerpc) using gcc 4.6:

  https://buildd.debian.org/status/logs.php?pkg=git&ver=1%3A1.8.3~rc0-1

> The truncation support was implemented with the assistance of a
> new strbuf function (strbuf_utf8_replace). This function contains
> the following code:
>
>        strbuf_attach(sb_src, strbuf_detach(&sb_dst, NULL),
>                      sb_dst.len, sb_dst.alloc);
>
> Unfortunately, this code is subject to unspecified behaviour. In
> particular, the order of evaluation of the argument expressions
> (along with the associated side effects) is not specified by the
> C standard. Note that the second argument expression is a call to
> strbuf_detach() which, as a side effect, sets the 'len' and 'alloc'
> fields of the sb_dst argument to zero.

Makes sense.

[...]
> In order to remove the undesired behaviour, we replace the above
> line of code with:
>
>        strbuf_swap(sb_src, &sb_dst);
>        strbuf_release(&sb_dst);
>
> which achieves the desired effect without provoking unspecified
> behaviour.

Nice cleanup.  I haven't tested the patch but it looks obviously
correct and I assume you've tested it, so for what it's worth,

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

      parent reply	other threads:[~2013-04-29 17:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 19:43 [PATCH] pretty: Fix bug in truncation support for %>, %< and %>< Ramsay Jones
2013-04-27 23:59 ` Duy Nguyen
2013-04-29 21:29   ` Ramsay Jones
2013-04-29 17:55 ` Jonathan Nieder [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130429175551.GA24467@google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    --cc=ramsay@ramsay1.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.