git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Christian Couder <chriscool@tuxfamily.org>, git <git@vger.kernel.org>
Subject: Re: [RFC/PATCH 1/2] commit: add parse_commit_repl() to replace commits at parsing time
Date: Wed, 18 Aug 2010 13:17:52 +1000	[thread overview]
Message-ID: <AANLkTimu0r_3L7_YJgfMVb6saFOyOK-mHLiKyTG_6Q5O@mail.gmail.com> (raw)
In-Reply-To: <7vbp91aqfk.fsf@alter.siamese.dyndns.org>

On Wed, Aug 18, 2010 at 7:18 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Christian Couder <chriscool@tuxfamily.org> writes:
>
>> The function parse_commit() is not safe regarding replaced commits
>> because it uses the buffer of the replacement commit but the object
>> part of the commit struct stay the same. Especially the sha1 is not
>> changed so it doesn't match the content of the commit.
>
> This all sounds backwards to me, if I am reading the discussion correctly.
>
> If a replace record says commit 0123 is replaced by commit 4567 (iow, 0123
> was a mistake, and pretend that its content is what is recorded in 4567),
> and when we are honoring the replace records (iow, we are not fsck),
> shouldn't read_sha1("0123") give us a piece of memory that stores what is
> recorded in 4567, parse_object("0123") return a struct commit whose buffer
> points at a block of memory that has what is recorded in 4567 _while_ its
> object.sha1[] say "0123"?

1. parse_object() as it is now would return object.sha1[] = "4567".
2. lookup_commit(), then parse_commit() would return object.sha1[] = "0123".

> What problem are you trying to solve?

Inconsistency in replacing objects. I have no comments whether #1 or
#2 is expected behavior. But at least it should stick to one behavior
only.
-- 
Duy

  reply	other threads:[~2010-08-18  3:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-17  1:58 [RFC/PATCH 1/2] commit: add parse_commit_repl() to replace commits at parsing time Christian Couder
2010-08-17 21:18 ` Junio C Hamano
2010-08-18  3:17   ` Nguyen Thai Ngoc Duy [this message]
2010-08-18  4:07     ` Christian Couder
2010-08-18  4:24       ` Jonathan Nieder
2010-08-18  4:37         ` Nguyen Thai Ngoc Duy
2010-08-18 14:50       ` Junio C Hamano
2010-08-20  4:04         ` Christian Couder

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=AANLkTimu0r_3L7_YJgfMVb6saFOyOK-mHLiKyTG_6Q5O@mail.gmail.com \
    --to=pclouds@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).