Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Glen Choo <chooglen@google.com>
To: Taylor Blau <me@ttaylorr.com>, git@vger.kernel.org
Cc: Jeff King <peff@peff.net>, Chris Torek <chris.torek@gmail.com>,
	Derrick Stolee <derrickstolee@github.com>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v5 2/2] gc: introduce `gc.recentObjectsHook`
Date: Fri, 09 Jun 2023 16:33:10 -0700	[thread overview]
Message-ID: <kl6lwn0cfbyh.fsf@chooglen-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <f661b54941a12c9bd8e226aebb4f0d53c10479c8.1686178684.git.me@ttaylorr.com>

Taylor Blau <me@ttaylorr.com> writes:

> When performing a garbage collection operation on a repository with
> unreachable objects, Git makes its decision on what to do with those
> object(s) bed on how recent the objects are or not. Generally speaking,

s/bed/based/ ?

> +gc.recentObjectsHook::
> +	When considering whether or not to remove an object (either when
> +	generating a cruft pack or storing unreachable objects as
> +	loose), use the shell to execute the specified command(s).
> +	Interpret their output as object IDs which Git will consider as
> +	"recent", regardless of their age. By treating their mtimes as
> +	"now", any objects (and their descendants) mentioned in the
> +	output will be kept regardless of their true age.

Thanks! I think this version will be clear to prospective users.

> +static int run_one_gc_recent_objects_hook(struct oidset *set,
> +					    const char *args)
> +{
> +	struct child_process cmd = CHILD_PROCESS_INIT;
> +	struct strbuf buf = STRBUF_INIT;
> +	FILE *out;
> +	int ret = 0;
> +
> +	cmd.use_shell = 1;
> +	cmd.out = -1;
> +
> +	strvec_push(&cmd.args, args);
> +
> +	if (start_command(&cmd))
> +		return -1;
> +
> +	out = xfdopen(cmd.out, "r");
> +	while (strbuf_getline(&buf, out) != EOF) {
> +		struct object_id oid;
> +		const char *rest;
> +
> +		if (parse_oid_hex(buf.buf, &oid, &rest) || *rest) {
> +			ret = error(_("invalid extra cruft tip: '%s'"), buf.buf);

To be consistent with the other error message, perhaps s/extra cruft
tip/additional recent object/?

> +static void load_gc_recent_objects(struct recent_data *data)
> +{
> +	const struct string_list *programs;
> +	int ret = 0;
> +	size_t i;
> +
> +	data->extra_recent_oids_loaded = 1;
> +
> +	if (git_config_get_string_multi("gc.recentobjectshook", &programs))
> +		return;
> +
> +	for (i = 0; i < programs->nr; i++) {
> +		ret = run_one_gc_recent_objects_hook(&data->extra_recent_oids,
> +						       programs->items[i].string);
> +		if (ret)
> +			die(_("unable to enumerate additional recent objects"));

This error message to be exact.

> +test_expect_success 'gc.recentObjectsHook' '
> +	git init repo &&
> +	test_when_finished "rm -fr repo" &&
> +	(
> +		cd repo &&
> +
> +		# Create a handful of objects.
> +		#
> +		#   - one reachable commit, "base", designated for the reachable
> +		#     pack
> +		#   - one unreachable commit, "cruft.discard", which is marked
> +		#     for deletion
> +		#   - one unreachable commit, "cruft.old", which would be marked
> +		#     for deletion, but is rescued as an extra cruft tip

Perhaps we intended to drop "cruft tips" in the test comments too? e.g.
here and..

> +test_expect_success 'multi-valued gc.recentObjectsHook' '
> +	git init repo &&
> +	test_when_finished "rm -fr repo" &&
> +	(
> +		cd repo &&
> +
> +		test_commit base &&
> +		git branch -M main &&
> +
> +		git checkout --orphan cruft.a &&
> +		git rm -fr . &&
> +		test_commit --no-tag cruft.a &&
> +		cruft_a="$(git rev-parse HEAD)" &&
> +
> +		git checkout --orphan cruft.b &&
> +		git rm -fr . &&
> +		test_commit --no-tag cruft.b &&
> +		cruft_b="$(git rev-parse HEAD)" &&
> +
> +		git checkout main &&
> +		git branch -D cruft.a cruft.b &&
> +		git reflog expire --all --expire=all &&
> +
> +		echo "echo $cruft_a" | write_script extra-tips.a &&
> +		echo "echo $cruft_b" | write_script extra-tips.b &&
> +		echo "false" | write_script extra-tips.c &&
> +
> +		git rev-list --objects --no-object-names $cruft_a $cruft_b \
> +			>cruft.raw &&
> +		sort cruft.raw >cruft.expect &&
> +
> +		# ensure that each extra cruft tip is saved by its

here.

Aside from those trivial points, everything looks good.

  reply	other threads:[~2023-06-09 23:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 23:20 [PATCH v3 0/2] pack-objects: introduce `pack.extraRecentObjectsHook` Taylor Blau
2023-05-11 23:20 ` [PATCH v3 1/2] reachable.c: extract `obj_is_recent()` Taylor Blau
2023-05-11 23:20 ` [PATCH v3 2/2] builtin/pack-objects.c: introduce `pack.recentObjectsHook` Taylor Blau
2023-05-12  4:58   ` Jeff King
2023-05-15 20:15     ` Taylor Blau
2023-05-12 21:24   ` Jeff King
2023-05-12 21:36     ` Taylor Blau
2023-05-12 21:46       ` Jeff King
2023-05-12 21:45     ` Jeff King
2023-05-12 22:01       ` Jeff King
2023-05-12 23:21         ` Junio C Hamano
2023-05-13  0:11           ` Jeff King
2023-05-13  0:11             ` Jeff King
2023-05-15 20:49       ` Taylor Blau
2023-05-15 20:38     ` Taylor Blau
2023-05-11 23:23 ` [PATCH v3 0/2] pack-objects: introduce `pack.extraRecentObjectsHook` Taylor Blau
2023-05-11 23:39 ` Junio C Hamano
2023-05-11 23:48   ` Taylor Blau
2023-05-16  0:23 ` [PATCH v4 0/2] gc: introduce `gc.recentObjectsHook` Taylor Blau
2023-05-16  0:24   ` [PATCH v4 1/2] reachable.c: extract `obj_is_recent()` Taylor Blau
2023-05-16  0:24   ` [PATCH v4 2/2] gc: introduce `gc.recentObjectsHook` Taylor Blau
2023-05-24 23:21     ` Glen Choo
2023-06-07 22:56       ` Taylor Blau
2023-06-07 22:58 ` [PATCH v5 0/2] " Taylor Blau
2023-06-07 22:58   ` [PATCH v5 1/2] reachable.c: extract `obj_is_recent()` Taylor Blau
2023-06-07 22:58   ` [PATCH v5 2/2] gc: introduce `gc.recentObjectsHook` Taylor Blau
2023-06-09 23:33     ` Glen Choo [this message]
2023-06-12 21:14       ` Junio C Hamano

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=kl6lwn0cfbyh.fsf@chooglen-macbookpro.roam.corp.google.com \
    --to=chooglen@google.com \
    --cc=chris.torek@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).