git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Christian Couder <christian.couder@gmail.com>
Cc: Jeff King <peff@peff.net>,
	 Peter Krefting <peter@softwolves.pp.se>,
	git@vger.kernel.org,  "Osipov,
	Michael (IN IT IN)" <michael.osipov@innomotics.com>,
	 Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH v2] bisect: Honor log.date
Date: Tue, 16 Apr 2024 08:42:10 -0700	[thread overview]
Message-ID: <xmqq8r1dfh65.fsf@gitster.g> (raw)
In-Reply-To: <CAP8UFD0W7PUHTg2NwuVkQJik2+HqTDF6KRZZ8tA_dW7-YZtsbQ@mail.gmail.com> (Christian Couder's message of "Tue, 16 Apr 2024 13:01:34 +0200")

Christian Couder <christian.couder@gmail.com> writes:

>> IMHO this config thing is a good example of the strength of the separate
>> "show" process. If our goal is to trigger all the niceties of "git
>> show", it is tricky to catch them all. The revision machinery is pretty
>> reusable, but there's no easy way to figure out which config affects
>> git-show and so on. Of course if we had a way to invoke git-show
>> in-process that would work, but I suspect there are unexpected corner
>> cases that might trigger.
>
> Sorry for not following the topic closely and for replying to this so
> late, but I think that by now we should have some kind of guidelines
> about when forking a new process is Ok and when it's not.

I thought we had passed that stage long ago.  A case like this one
we see in this patch, where it is run just once immediately before
we give control back to the end-user (as opposed to "gets run each
time in a tight loop"), I would see it a no-brainer to discount the
"fork+exec is so expensive" objection more than we would otherwise,
especially when the upside of running an external command is so much
bigger.

There actually should be a different level of "running it as a
separate command" that we do not have.  If we can split out and
encapsulate the global execution context sufficiently into a "bag of
state variables" structure, and rewrite cmd_foo() for each such
command we wish to be able to run from inside an executing Git into
two parts:

 - cmd_foo() that prepares the global execution context to a
   "pristine" state, calls into cmd__foo() with that "bag of state
   variables" structure as one of the parameters, and exits when
   everything is done.

 - cmd__foo() that does the rest, including reading the
   configuration files, parsing of the command line arguments to
   override them, doing the actual work.

then the codepath we are changing from using diff-tree to show can
do something like:

	struct git_global_state state = GIT_GLOBAL_STATE_INIT;
	struct strvec args = STRVEC_INIT;

        strvec_pushl(&args, ...);
        cmd__show(&state, args.nr , args.v);

and expect that cmd__show() will do the _right thing_, right?

And to reach that ultimate goal, I do not think using run_command()
API in the meantime poses hindrance.  The real work should be in the
implementation of cmd__show(), not the open-coded use of revisions
API at each such point where you are tempted to spawn an external
command via run_command() API, which will have to be consolidated
and replaced with a call to cmd__show() anyway.


  reply	other threads:[~2024-04-16 15:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-30 23:10 [PATCH v2] bisect: Honor log.date Peter Krefting
2024-03-31  2:14 ` Junio C Hamano
2024-03-31 17:10   ` Peter Krefting
2024-03-31 22:58     ` Junio C Hamano
2024-04-01  2:32       ` Jeff King
2024-04-01 15:50         ` Peter Krefting
2024-04-01 16:32           ` Jeff King
2024-04-01 17:03             ` Junio C Hamano
2024-04-03  1:27               ` Jeff King
2024-04-16 11:01         ` Christian Couder
2024-04-16 15:42           ` Junio C Hamano [this message]
2024-04-16 19:53             ` Peter Krefting
2024-04-20 17:13               ` 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

  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=xmqq8r1dfh65.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=michael.osipov@innomotics.com \
    --cc=peff@peff.net \
    --cc=peter@softwolves.pp.se \
    /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).