git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Andreas Heiduk <asheiduk@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 1/2] add setup step to filter-branch
Date: Fri, 9 Jun 2017 01:49:55 -0400	[thread overview]
Message-ID: <20170609054955.y52cro2c3bwhl2sh@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqq1sqzuqmh.fsf@gitster.mtv.corp.google.com>

On Mon, Jun 05, 2017 at 11:15:18AM +0900, Junio C Hamano wrote:

> Andreas Heiduk <asheiduk@gmail.com> writes:
> 
> > A specific `--setup` step in `git filter-branch` makes it much easier
> > to define the initial values of variables used in the real filters.
> > Also sourcing/defining utility functions here instead of
> > `--env-filter` improves performance and minimizes clogging the output
> > in case of errors.
> >
> > Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
> > ---
> 
> I was placed on To: line, but I do not have a strong opinion on this
> change, either for or against.
> 
> "filter-branch" program itself may probably already be hard to port
> to C, but I need to point out that this makes it even harder than it
> currently is [*1*], and it is likely that it has to stay implemented
> in shell forever, though.  I do not mind that future myself, but
> those on platforms with weaker implementation of shells might.

I have a feeling that if we were ever to rewrite filter-branch, it would
probably be worth allowing people to write snippets in a better language
(possibly even a domain-specific language). I'm sure that most of the
program being written in shell doesn't help, but if we're spawning one
or more shell instances per commit (plus the Git programs they spawn!),
it's always going to be slow.

But I suspect that would be an uphill battle, as our only stable API
involves starting external processes anyway. You'd probably do better to
pick a language you like and rewrite it in using libgit2's bindings to
that language. It's not feature complete, but basic stuff like "put this
entry in the tree" is certainly mature.

>  *1* The issue is *not* that these individual filter commands expect
>      <command> written as a shell scriptlet; it is that these
>      scriptlets expect to be evaled inside a single shell process,
>      making an update to a shell variable in one command visible to
>      the next command that runs.

I think you'd need a shell "helper" that's a single long-running process
and just reads "eval the index snippet now" instructions from the C
controller. At which point I don't think Andreas's "setup" feature is
any harder to support. We just send an "eval the setup snippet"
instruction first.

I guess one way to think of that is that the C program is itself
generating a shell script.

-Peff

  reply	other threads:[~2017-06-09  5:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-03 10:17 [PATCH 1/2] add setup step to filter-branch Andreas Heiduk
2017-06-03 10:17 ` [PATCH 2/2] add [--] to usage of filter-branch Andreas Heiduk
2017-06-05  8:51   ` Andreas Heiduk
2017-06-09 13:14     ` Junio C Hamano
2017-06-09 14:33       ` Andreas Heiduk
2017-06-05  2:15 ` [PATCH 1/2] add setup step to filter-branch Junio C Hamano
2017-06-09  5:49   ` Jeff King [this message]
2017-06-09 13:11     ` Junio C Hamano
2017-06-10  8:54 ` [PATCH v2 " Andreas Heiduk
2017-06-10  8:54   ` [PATCH v2 2/2] add [--] to usage of filter-branch Andreas Heiduk

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=20170609054955.y52cro2c3bwhl2sh@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=asheiduk@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).