From: Junio C Hamano <gitster@pobox.com>
To: Taylor Blau <me@ttaylorr.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH 08/11] midx-write.c: avoid directly managed temporary strbuf
Date: Mon, 25 Mar 2024 13:33:11 -0700 [thread overview]
Message-ID: <xmqqv85ahx14.fsf@gitster.g> (raw)
In-Reply-To: <8e32755c492d20eec02c81351d249ce34cc6d7b9.1711387439.git.me@ttaylorr.com> (Taylor Blau's message of "Mon, 25 Mar 2024 13:24:41 -0400")
Taylor Blau <me@ttaylorr.com> writes:
> In midx-write.c::midx_repack(), we construct the command-line arguments
> for a pack-objects invocation which will combine objects from the packs
> below our `--batch-size` option.
>
> To construct the base name of the output pack, we use a temporary
> strbuf, and then push the result of that onto the strvec which holds the
> command-line arguments, after which point we release the strbuf.
>
> We could replace this by doing something like:
>
> struct strbuf buf = STRBUF_INIT;
> strbuf_addf(&buf, "%s/pack/pack", object_dir);
> strvec_push_nodup(&cmd.args, strbuf_detach(&buf));
Hmph, I thought I saw another patch recently that uses
strvec_pushf() to simplify such a sequence. Does the technique
apply here as well?
Ah, yes, exactly. See <9483038c-9529-4243-9b9a-97254fac29c1@web.de>
> @@ -1473,10 +1472,6 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
>
> strvec_push(&cmd.args, "pack-objects");
>
> - strbuf_addstr(&base_name, object_dir);
> - strbuf_addstr(&base_name, "/pack/pack");
> - strvec_push(&cmd.args, base_name.buf);
> -
> if (delta_base_offset)
> strvec_push(&cmd.args, "--delta-base-offset");
> if (use_delta_islands)
> @@ -1487,7 +1482,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size,
> else
> strvec_push(&cmd.args, "-q");
>
> - strbuf_release(&base_name);
> + strvec_pushf(&cmd.args, "%s/pack/pack", object_dir);
>
> cmd.git_cmd = 1;
> cmd.in = cmd.out = -1;
next prev parent reply other threads:[~2024-03-25 20:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 17:24 [PATCH 00/11] midx: split MIDX writing routines into midx-write.c, cleanup Taylor Blau
2024-03-25 17:24 ` [PATCH 01/11] midx-write: initial commit Taylor Blau
2024-03-25 20:30 ` Junio C Hamano
2024-03-25 22:09 ` Taylor Blau
2024-03-25 17:24 ` [PATCH 02/11] midx: extern a pair of shared functions Taylor Blau
2024-03-25 17:24 ` [PATCH 03/11] midx: move `midx_repack` (and related functions) to midx-write.c Taylor Blau
2024-03-25 17:24 ` [PATCH 04/11] midx: move `expire_midx_packs` " Taylor Blau
2024-03-25 17:24 ` [PATCH 05/11] midx: move `write_midx_file_only` " Taylor Blau
2024-03-25 17:24 ` [PATCH 06/11] midx: move `write_midx_file` " Taylor Blau
2024-03-25 17:24 ` [PATCH 07/11] midx: move `write_midx_internal` (and related functions) " Taylor Blau
2024-03-25 17:24 ` [PATCH 08/11] midx-write.c: avoid directly managed temporary strbuf Taylor Blau
2024-03-25 20:33 ` Junio C Hamano [this message]
2024-03-25 22:11 ` Taylor Blau
2024-03-25 17:24 ` [PATCH 09/11] midx-write.c: factor out common want_included_pack() routine Taylor Blau
2024-03-25 20:36 ` Junio C Hamano
2024-03-27 8:29 ` Jeff King
2024-03-25 17:24 ` [PATCH 10/11] midx-write.c: check count of packs to repack after grouping Taylor Blau
2024-03-25 20:41 ` Junio C Hamano
2024-03-25 22:11 ` Taylor Blau
2024-03-25 17:24 ` [PATCH 11/11] midx-write.c: use `--stdin-packs` when repacking Taylor Blau
2024-03-27 8:37 ` Jeff King
2024-03-27 8:39 ` [PATCH 00/11] midx: split MIDX writing routines into midx-write.c, cleanup Jeff King
2024-04-01 21:16 ` [PATCH v2 0/4] " Taylor Blau
2024-04-01 21:16 ` [PATCH v2 1/4] midx-write: move writing-related functions from midx.c Taylor Blau
2024-04-01 21:16 ` [PATCH v2 2/4] midx-write.c: factor out common want_included_pack() routine Taylor Blau
2024-04-02 11:47 ` Patrick Steinhardt
2024-04-01 21:16 ` [PATCH v2 3/4] midx-write.c: check count of packs to repack after grouping Taylor Blau
2024-04-01 21:16 ` [PATCH v2 4/4] midx-write.c: use `--stdin-packs` when repacking Taylor Blau
2024-04-01 21:45 ` Junio C Hamano
2024-04-02 11:47 ` Patrick Steinhardt
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=xmqqv85ahx14.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--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 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.