git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Jonathan Tan" <jonathantanmy@google.com>
Cc: git@vger.kernel.org, me@ttaylorr.com, gitster@pobox.com,
	bagasdotme@gmail.com
Subject: Re: [PATCH v2] commit,shallow: unparse commits if grafts changed
Date: Fri, 3 Jun 2022 09:29:55 -0400	[thread overview]
Message-ID: <394c054e-e1d2-41a5-a655-2ad3cb7219e0@github.com> (raw)
In-Reply-To: <220603.86k09yxf4z.gmgdl@evledraar.gmail.com>

On 6/3/2022 5:30 AM, Ævar Arnfjörð Bjarmason wrote:
> 
> On Thu, Jun 02 2022, Jonathan Tan wrote:
> 
>> diff --git a/commit.c b/commit.c
>> index 59b6c3e455..1537ea73d0 100644
>> --- a/commit.c
>> +++ b/commit.c
>> @@ -120,6 +120,17 @@ int commit_graft_pos(struct repository *r, const struct object_id *oid)
>>  		       commit_graft_oid_access);
>>  }
>>  
>> +static void unparse_commit(struct repository *r, const struct object_id *oid)
>> +{
>> +	struct commit *c = lookup_commit(r, oid);
>> +
>> +	if (!c->object.parsed)
>> +		return;
>> +	free_commit_list(c->parents);
>> +	c->parents = NULL;
>> +	c->object.parsed = 0;
>> +}

This looks good. I took a quick inventory of 'struct commit' and
agree that this is all we need. There is no need to clear the date
or maybe_tree members. The commit_graph_data slab might have some
information if there were no grafts before (but are now), but the
existence of grafts should clear the commit-graph already and stop
that slab from being used.

>>  int register_commit_graft(struct repository *r, struct commit_graft *graft,
>>  			  int ignore_dups)
>>  {
>> @@ -145,6 +156,7 @@ int register_commit_graft(struct repository *r, struct commit_graft *graft,
>>  			(r->parsed_objects->grafts_nr - pos - 1) *
>>  			sizeof(*r->parsed_objects->grafts));
>>  	r->parsed_objects->grafts[pos] = graft;
>> +	unparse_commit(r, &graft->oid);
>>  	return 0;
>>  }
>>  
>> @@ -253,8 +265,10 @@ void reset_commit_grafts(struct repository *r)
>>  {
>>  	int i;
>>  
>> -	for (i = 0; i < r->parsed_objects->grafts_nr; i++)
>> +	for (i = 0; i < r->parsed_objects->grafts_nr; i++) {
>> +		unparse_commit(r, &r->parsed_objects->grafts[i]->oid);
>>  		free(r->parsed_objects->grafts[i]);
>> +	}
>>  	r->parsed_objects->grafts_nr = 0;
>>  	r->parsed_objects->commit_graft_prepared = 0;
>>  }
> 
> Are we going to have the same issue with tags, c.f. parse_tag() and
> there being no unparse_tag()?
> 
> (I don't know offhand, just asking)

Grafts are only on commits. You cannot replace what a tag is pointing
at with a graft. Replace-objects is a different thing and changes it at
the OID level (and I don't think this can happen during the process
without concurrent external changes to the filesystem).

Thanks,
-Stolee

  reply	other threads:[~2022-06-03 13:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 21:08 [PATCH] commit-reach: do not parse and iterate minima Jonathan Tan
2022-03-23 23:30 ` Junio C Hamano
2022-03-24 15:27   ` Derrick Stolee
2022-03-24 22:06     ` Taylor Blau
2022-03-25 14:32       ` Derrick Stolee
2022-03-24 22:15     ` Jonathan Tan
2022-03-24 12:05 ` Bagas Sanjaya
2022-03-24 22:19   ` Jonathan Tan
2022-03-24 15:29 ` Derrick Stolee
2022-03-24 22:21   ` Jonathan Tan
2022-06-02 23:11 ` [PATCH v2] commit,shallow: unparse commits if grafts changed Jonathan Tan
2022-06-03  9:30   ` Ævar Arnfjörð Bjarmason
2022-06-03 13:29     ` Derrick Stolee [this message]
2022-06-03 15:27       ` Jonathan Tan
2022-06-03 15:26     ` Jonathan Tan
2022-06-06 17:54 ` [PATCH v3] " Jonathan Tan

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=394c054e-e1d2-41a5-a655-2ad3cb7219e0@github.com \
    --to=derrickstolee@github.com \
    --cc=avarab@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=me@ttaylorr.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).