All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Olivier ROLAND <cyrus-dev@edla.org>
Cc: git@vger.kernel.org
Subject: Re: Bug report : bad filter-branch (OSX only)
Date: Wed, 29 Apr 2015 00:56:00 -0400	[thread overview]
Message-ID: <20150429045600.GA10781@peff.net> (raw)
In-Reply-To: <20150429043947.GA10702@peff.net>

On Wed, Apr 29, 2015 at 12:39:47AM -0400, Jeff King wrote:

> So I can't figure out how to replicate the problem here.

Actually, that's not quite true. I could get hold of an OS X system to
replicate, which I just did.

The problem is that commit 3b754f212 does not have a newline at the end
of its commit message, and the OS X version of sed doesn't preserve
that.

Here's a much smaller reproduction recipe:

  git init
  echo content >file
  git add file
  tree=$(git write-tree)
  commit=$(printf 'no newline' | git commit-tree $tree)
  git update-ref HEAD $commit
  git filter-branch

On my Linux system, this results in an unchanged history, but on OS X,
the commit is rewritten to have a newline at the end of the commit
message.

The culprit is this line from git-filter-branch:

        sed -e '1,/^$/d' <../commit | \
                eval "$filter_msg" > ../message ||
                        die "msg filter failed: $filter_msg"

The "sed" command silently appends an extra newline to the final line of
the message.  You can see the sed behavior more directly with:

  printf foo | sed -ne 1p

which adds a newline on OS X, but not when using GNU sed on Linux. It
looks like OS X has just BSD sed, so the same behavior probably happens
on FreeBSD and elsewhere.

I'm not sure of a solution short of replacing the use of sed here with
something else. perl would be a simple choice, but filter-branch does
not otherwise depend on it. We could use a shell "read" loop, but those
are quite slow (and filter-branch is slow enough as it is!).

-Peff

  reply	other threads:[~2015-04-29  4:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-26  9:25 Bug report : bad filter-branch (OSX only) Olivier ROLAND
2015-04-28  5:55 ` Jeff King
2015-04-28 11:02   ` Olivier ROLAND
2015-04-29  4:39     ` Jeff King
2015-04-29  4:56       ` Jeff King [this message]
2015-04-29  5:39         ` Junio C Hamano
2015-04-29 15:48           ` Jeff King
2015-04-29 16:30             ` Junio C Hamano
2015-04-29 16:43               ` Jeff King
2015-04-29 17:13                 ` Junio C Hamano
2015-04-29 18:17               ` Johannes Sixt
2015-04-29 14:42 ` Roberto Tyley

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=20150429045600.GA10781@peff.net \
    --to=peff@peff.net \
    --cc=cyrus-dev@edla.org \
    --cc=git@vger.kernel.org \
    /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.