Subject: Re: [RFC v2] cat-file: add a --stdin-cmd mode

From: Eric Wong <[email-masked]>
Date: Fri, 28 Jan 2022 06:07:14 +0000

John Cai <[email-masked]> wrote:
> This RFC patch proposes a new flag --stdin-cmd that works with
> git-cat-file --batch. Similar to git-update-ref --stdin, it will accept
> commands and arguments from stdin.
> 
> The start of this idea was discussed in [1], where the original
> motivation was to be able to control when the buffer was flushed to
> stdout in --buffer mode.
> 
> However, this can actually be much more useful in situations when
> git-cat-file --batch is being used as a long lived backend query
> process. At GitLab, we use a pair of cat-file processes. One for
> iterating over object metadata with --batch-check, and the other to grab
> object contents with --batch. However, if we had --stdin-cmd, we could
> get rid of the second --batch-check process, and just have one progress
> where we can flip between getting object info, and getting object contents.
> This can lead to huge savings.

Cool.  I wish I had this back when I worked on a project which uses git.
In case I ever continue, having 2-3 features in git itself would be useful:

1) ability to add new alternates / object directories on-the-fly
2) ability to deal with unlinked packs

And maybe:

3) ability to remove alternates

I've implemented 1 and 2 via libgit2; but not yet 3 (not really
important, atm).

Thanks.