All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, David Turner <dturner@twosigma.com>
Subject: Re: [PATCH 3/6] tmp-objdir: introduce API for temporary object directories
Date: Fri, 30 Sep 2016 14:25:43 -0700	[thread overview]
Message-ID: <xmqqponl84h4.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160930193613.dwpjiw5xps6a3wgj@sigill.intra.peff.net> (Jeff King's message of "Fri, 30 Sep 2016 15:36:13 -0400")

Jeff King <peff@peff.net> writes:

> diff --git a/sha1_file.c b/sha1_file.c
> index 9a79c19..65deaf9 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -421,6 +421,12 @@ void add_to_alternates_file(const char *reference)
>  	free(alts);
>  }
>  
> +void add_to_alternates_internal(const char *reference)
> +{
> +	prepare_alt_odb();
> +	link_alt_odb_entries(reference, strlen(reference), '\n', NULL, 0);
> +}
> +

A function _internal being extern felt a bit funny.  We are only
appending so the first one does not have to be reprepare.

> +static int tmp_objdir_destroy_1(struct tmp_objdir *t, int on_signal)
> +{
> +	int err;
> +
> +	if (!t)
> +		return 0;
> +
> +	if (t == the_tmp_objdir)
> +		the_tmp_objdir = NULL;
> +
> +	/*
> +	 * This may use malloc via strbuf_grow(), but we should
> +	 * have pre-grown t->path sufficiently so that this
> +	 * doesn't happen in practice.
> +	 */
> +	err = remove_dir_recursively(&t->path, 0);
> +
> +	/*
> +	 * When we are cleaning up due to a signal, we won't bother
> +	 * freeing memory; it may cause a deadlock if the signal
> +	 * arrived while libc's allocator lock is held.
> +	 */
> +	if (!on_signal)
> +		tmp_objdir_free(t);
> +	return err;
> +}
> +
> +int tmp_objdir_destroy(struct tmp_objdir *t)
> +{
> +	return tmp_objdir_destroy_1(t, 0);
> +}

Looks sensible.

> +	t = xmalloc(sizeof(*t));
> +	strbuf_init(&t->path, 0);
> +	argv_array_init(&t->env);
> +
> +	strbuf_addf(&t->path, "%s/incoming-XXXXXX", get_object_directory());

I was wondering where you would put this in.  Inside .git/objects/
sounds good.

> +/*
> + * Make sure we copy packfiles and their associated metafiles in the correct
> + * order. All of these ends_with checks are slightly expensive to do in
> + * the midst of a sorting routine, but in practice it shouldn't matter.
> + * We will have a relatively small number of packfiles to order, and loose
> + * objects exit early in the first line.
> + */
> +static int pack_copy_priority(const char *name)
> +{
> +	if (!starts_with(name, "pack"))
> +		return 0;
> +	if (ends_with(name, ".keep"))
> +		return 1;
> +	if (ends_with(name, ".pack"))
> +		return 2;
> +	if (ends_with(name, ".idx"))
> +		return 3;
> +	return 4;
> +}

Thanks for being careful.  A blind "cp -r" would have ruined the
day.

We do not do bitmaps upon receiving, I guess.

> + *	struct tmp_objdir *t = tmp_objdir_create();
> + *	if (!run_command_v_opt_cd_env(cmd, 0, NULL, tmp_objdir_env(t)) &&
> + *	    !tmp_objdir_migrate(t))
> + *		printf("success!\n");
> + *	else
> + *		die("failed...tmp_objdir will clean up for us");

Made me briefly wonder if a caller might want to use appropriate
environment to use the tmp-objdir given by the API in addition to
its own, but then such a caller just needs to prepare its own argv-array
and concatenate tmp_objdir_env() before making the opt_cd_env call,
so this is perfectly fine.


  reply	other threads:[~2016-09-30 21:25 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 19:35 [PATCH 0/6] receive-pack: quarantine pushed objects Jeff King
2016-09-30 19:35 ` [PATCH 1/6] check_connected: accept an env argument Jeff King
2016-09-30 19:36 ` [PATCH 2/6] sha1_file: always allow relative paths to alternates Jeff King
2016-10-02  9:07   ` René Scharfe
2016-10-02 13:03     ` Jeff King
2016-10-02 15:38     ` Jeff King
2016-10-02 16:59       ` Jeff King
2016-09-30 19:36 ` [PATCH 3/6] tmp-objdir: introduce API for temporary object directories Jeff King
2016-09-30 21:25   ` Junio C Hamano [this message]
2016-09-30 22:13     ` Jeff King
2016-09-30 21:32   ` David Turner
2016-09-30 22:44     ` Jeff King
2016-09-30 23:07       ` David Turner
2016-09-30 19:36 ` [PATCH 4/6] receive-pack: quarantine objects until pre-receive accepts Jeff King
2016-10-01  9:12   ` Jeff King
2017-04-08 14:53     ` Ævar Arnfjörð Bjarmason
2017-04-10 21:14       ` Jeff King
2016-09-30 19:36 ` [PATCH 5/6] tmp-objdir: put quarantine information in the environment Jeff King
2016-09-30 19:36 ` [PATCH 6/6] tmp-objdir: do not migrate files starting with '.' Jeff King
2016-10-02  9:20 ` [PATCH 0/6] receive-pack: quarantine pushed objects Christian Couder
2016-10-02 13:02   ` Jeff King
2016-10-03  6:45     ` Christian Couder
2016-10-03 20:48 ` [PATCH v2 0/5] " Jeff King
2016-10-03 20:49   ` [PATCH v2 1/5] check_connected: accept an env argument Jeff King
2016-10-05 19:01     ` Jakub Narębski
2016-10-05 19:06       ` Jeff King
2016-10-03 20:49   ` [PATCH v2 2/5] tmp-objdir: introduce API for temporary object directories Jeff King
2016-10-03 20:49   ` [PATCH v2 3/5] receive-pack: quarantine objects until pre-receive accepts Jeff King
2016-10-03 20:49   ` [PATCH v2 4/5] tmp-objdir: put quarantine information in the environment Jeff King
2016-10-03 20:49   ` [PATCH v2 5/5] tmp-objdir: do not migrate files starting with '.' Jeff King
2016-10-03 21:25   ` [PATCH v2 0/5] receive-pack: quarantine pushed objects Junio C Hamano
2016-10-03 21:28     ` Jeff King

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=xmqqponl84h4.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=dturner@twosigma.com \
    --cc=git@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.