git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH 1/2] commit: add parse_commit_repl() to replace commits at parsing time

From
Christian Couder <chriscool@tuxfamily.org>
Date
Aug 18, 2010, 04:07 UTC
Message-ID
<201008180607.54675.chriscool@tuxfamily.org>
In-Reply-To
<AANLkTimu0r_3L7_YJgfMVb6saFOyOK-mHLiKyTG_6Q5O@mail.gmail.com>
On Wednesday 18 August 2010 05:17:52 Nguyen Thai Ngoc Duy wrote:
Show 27 quoted lines
> 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 "0 123"?
> 
> 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.
We discussed this inconsistency in this thread:
http://thread.gmane.org/gmane.comp.version-control.git/152321/ 

So we can resolve the inconsistency with Duy's patch to make parse_object() return object.sha1[] = "0123".

It's simpler and probably safer. The downside is that the sha1 will not be consistent with the content anymore and that it will be more difficult to realize that an object has been replaced as there will be no sha1 change to be seen.

Best regards, Christian.

Previous: Nguyen Thai Ngoc DuyNext: Jonathan Nieder
Message 4 of 8 in “commit: add parse_commit_repl() to replace commits at parsing time”
  1. 1/2 commit: add parse_commit_repl() to replace commits at parsing timeChristian Couder, Aug 17, 2010
  2. Junio C HamanoAug 17, 2010
  3. Nguyen Thai Ngoc DuyAug 18, 2010
  4. Christian CouderAug 18, 2010
  5. Jonathan NiederAug 18, 2010
  6. Nguyen Thai Ngoc DuyAug 18, 2010
  7. Junio C HamanoAug 18, 2010
  8. Christian CouderAug 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.