public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Paul Tan <pyokagan@gmail•com>
Cc: Git List <git@vger•kernel.org>,
	Stefan Beller <sbeller@google•com>,
	Johannes Schindelin <johannes.schindelin@gmx•de>
Subject: Re: [PATCH/WIP v2 03/19] am: implement skeletal builtin am
Date: Mon, 15 Jun 2015 10:54:36 -0700	[thread overview]
Message-ID: <xmqqoakgamcj.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CACRoPnS9fkNQTB8bEKdOBqFgV1E1Mff7oE8rBFDUK+c-woxqZg@mail.gmail.com> (Paul Tan's message of "Tue, 16 Jun 2015 01:20:17 +0800")

Paul Tan <pyokagan@gmail•com> writes:

>> The scripted Porcelain is spawned after applying patches 1-3 from
>> here, when you do not have _GIT_USE_BUILTIN_AM exported.  Haven't
>> RUN_SETUP code did its thing by that time?
>
> Ah right, the RUN_SETUP code would have chdir()-ed to the working
> directory root, so git-am.sh will be unable to find the original
> working directory. To aid it, we would have to chdir() back to the
> original working directory, and unset GIT_DIR.

I do not think that is a correct workaround, though.  GIT_DIR may
have come from the end user, i.e.

	$ GIT_WORK_TREE=somewhere GIT_DIR=somewhere.else git am ...

As the RUN_SETUP|REQUIRE_WORK_TREE bit is merely a convenence in
git.c, one workable way to keep these dual implementations is to do
what built-in commands used to do before these were invented.
Perhaps studying how cmd_diff(), which is run from git.c without
either RUN_SETUP or NEED_WORK_TREE, and taking good bits from it
would help.  I think the implementation roughly would look like
this:

	int cmd_am(int ac, const char **av, const char *prefix)
	{
                /*
                 * NEEDSWORK: once we retire the dual-mode
                 * implementation, this preamble can be removed...                
                 */
		if (... want to do scripted ...) {
                	... spawn the scripted thing ...
		}
		prefix = setup_git_directory();
                setup_work_tree();
                /* ... up to this point */

		... your real "git am in C" comes here ...
	}

  reply	other threads:[~2015-06-15 17:54 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 10:21 [PATCH/WIP v2 00/19] Make git-am a builtin Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 01/19] wrapper: implement xopen() Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 02/19] wrapper: implement xfopen() Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 03/19] am: implement skeletal builtin am Paul Tan
2015-06-14 22:08   ` Junio C Hamano
2015-06-15  9:49     ` Paul Tan
2015-06-15 17:14       ` Junio C Hamano
2015-06-15 17:20         ` Paul Tan
2015-06-15 17:54           ` Junio C Hamano [this message]
2015-06-18  8:44             ` Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 04/19] am: implement patch queue mechanism Paul Tan
2015-06-11 17:39   ` Stefan Beller
2015-06-15 10:46     ` Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 05/19] am: split out mbox/maildir patches with git-mailsplit Paul Tan
2015-06-11 17:45   ` Stefan Beller
2015-06-15 10:08     ` Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 06/19] am: detect mbox patches Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 07/19] am: extract patch, message and authorship with git-mailinfo Paul Tan
2015-06-14 22:10   ` Junio C Hamano
2015-06-11 10:21 ` [PATCH/WIP v2 08/19] am: apply patch with git-apply Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 09/19] am: commit applied patch Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 10/19] am: refresh the index at start Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 11/19] am: refuse to apply patches if index is dirty Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 12/19] am: implement --resolved/--continue Paul Tan
2015-06-11 10:21 ` [PATCH/WIP v2 13/19] am: implement --skip Paul Tan
2015-06-11 10:22 ` [PATCH/WIP v2 14/19] am: implement --abort Paul Tan
2015-06-11 10:22 ` [PATCH/WIP v2 15/19] am: implement quiet option Paul Tan
2015-06-11 10:22 ` [PATCH/WIP v2 16/19] am: exit with user friendly message on patch failure Paul Tan
2015-06-11 10:22 ` [PATCH/WIP v2 17/19] am: implement am --signoff Paul Tan
2015-06-11 10:22 ` [PATCH/WIP v2 18/19] cache-tree: introduce write_index_as_tree() Paul Tan
2015-06-11 10:22 ` [PATCH/WIP v2 19/19] am: implement 3-way merge Paul Tan

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=xmqqoakgamcj.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=johannes.schindelin@gmx$(echo .)de \
    --cc=pyokagan@gmail$(echo .)com \
    --cc=sbeller@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox