git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>,
	git@vger.kernel.org, Aman Gupta <themastermind1@gmail.com>
Subject: Re: [PATCHv2 2/2] merge-one-file: fix broken merges with alternate work trees
Date: Fri, 29 Apr 2011 18:46:46 -0400	[thread overview]
Message-ID: <20110429224646.GA4095@sigill.intra.peff.net> (raw)
In-Reply-To: <7vtydgvfx4.fsf@alter.siamese.dyndns.org>

On Fri, Apr 29, 2011 at 03:41:43PM -0700, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > This patch makes merge-one-file chdir to the toplevel of the working
> > tree (and exit if we don't have one). This most closely matches the
> > assumption made by the original script (before separate work trees were
> > invented), and matches what happens when the script is called as part of
> > a merge strategy.
> >
> > While we're at it, we'll also error-check the call to cat.
> > Merging a file in a subdirectory could in fact fail, as the
> > redirection relies on the "checkout-index" call just prior
> > to create leading directories. But we never noticed, since
> > we ignored the error return from running cat.
> 
> This part is probably incorrect as we have && before cat that checks
> an error from checkout-index that fails to create such a subdirectory, no?

Sort of. In the original code, checkout-index wrote to one spot, and cat
wrote to another, so they could fail independently, masking the bug.

Now that the code correctly respects GIT_WORK_TREE, that should never
happen, and the only reason for cat to fail is something like ENOSPC
(checkout-index wrote the original version, but we are writing the merge
result, which could be larger).

> And then "exec git update-index -- $4" at the last step would have failed.

No. In the old code, it succeeded because it respected GIT_WORK_TREE, so
it marked the original stage-2 version as the merge result (hence the
bogus merge results).

In the new code, if we got ENOSPC, then it would mark the truncated
merge result as good (except that we probably would also fail to write a
new index due to the same error...).

It's unlikely, I'll grant, but I don't see a reason not to check the
error.

-Peff

      reply	other threads:[~2011-04-29 22:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BANLkTimoehqY9ViF7AkQC3YU8e4Sq-OT_w@mail.gmail.com>
2011-04-29 18:52 ` [PATCH 2/2] merge-one-file: fix broken merges with GIT_WORK_TREE Jeff King
2011-04-29 22:23   ` [PATCHv2 1/2] add tests for merge-index / merge-one-file Jeff King
2011-04-29 22:24   ` [PATCHv2 2/2] merge-one-file: fix broken merges with alternate work trees Jeff King
2011-04-29 22:41     ` Junio C Hamano
2011-04-29 22:46       ` Jeff King [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=20110429224646.GA4095@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=martin.von.zweigbergk@gmail.com \
    --cc=themastermind1@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).