All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Tan <pyokagan@gmail.com>
To: Junio C Hamano <gitster@pobox.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: Thu, 18 Jun 2015 16:44:32 +0800	[thread overview]
Message-ID: <CACRoPnRfTCyTj=WnygzwSNu7s_2iGrtygPEh7u2d1Hqchd1ZxQ@mail.gmail.com> (raw)
In-Reply-To: <xmqqoakgamcj.fsf@gitster.dls.corp.google.com>

On Tue, Jun 16, 2015 at 1:54 AM, Junio C Hamano <gitster@pobox.com> wrote:
> 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 ...

Ah, forgot about that ><

> 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 ...
>         }
>

Ah OK. Just to be sure, I took a look at run_builtin() in git.c, and
indeed it only just does:

prefix = setup_git_directory();
trace_repo_setup(prefix);
setup_work_tree();

which is not bad at all. Thanks.

Regards,
Paul

  reply	other threads:[~2015-06-18  8:44 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
2015-06-18  8:44             ` Paul Tan [this message]
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='CACRoPnRfTCyTj=WnygzwSNu7s_2iGrtygPEh7u2d1Hqchd1ZxQ@mail.gmail.com' \
    --to=pyokagan@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=sbeller@google.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.
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.