git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nguyen Thai Ngoc Duy <pclouds@gmail.com>
To: Michael J Gruber <git@drmicha.warpmail.net>
Cc: git@vger.kernel.org, Matej Batic <matej.batic@ge.infn.it>
Subject: Re: [RFC/PATCH] handle_alias: provide GIT_CWD to !alias
Date: Wed, 13 Apr 2011 20:24:44 +0700	[thread overview]
Message-ID: <BANLkTikKyJb283ZTaX0q=BYkCtp_48Yocg@mail.gmail.com> (raw)
In-Reply-To: <4DA5A228.2040105@drmicha.warpmail.net>

On Wed, Apr 13, 2011 at 8:16 PM, Michael J Gruber
<git@drmicha.warpmail.net> wrote:
> Nguyen Thai Ngoc Duy venit, vidit, dixit 13.04.2011 15:12:
>> On Wed, Apr 13, 2011 at 8:05 PM, Michael J Gruber
>> <git@drmicha.warpmail.net> wrote:
>>> -                       ret = run_command_v_opt(alias_argv, RUN_USING_SHELL);
>>> +                       strbuf_addstr(&sb, "GIT_CWD=");
>>> +                       if (subdir)
>>> +                               strbuf_addstr(&sb, subdir);
>>> +                       env[0] = sb.buf;
>>> +                       env[1] = NULL;
>>> +                       ret = run_command_v_opt_cd_env(alias_argv, RUN_USING_SHELL, NULL, env);
>>> +                       strbuf_release(&sb);
>>>                        if (ret >= 0)   /* normal exit */
>>>                                exit(ret);
>>
>> subdir can be NULL. I'm not sure if it can be empty string though. May
>
> I'm pretty sure that my "if (subdir)" would catch that...

Yes. I skimmed too quick and realized after sending my email.

>> need a check and set it to '.' so "cd $GIT_CWD" does not go back to
>> $HOME.
>
> Well, with the current implementation you get empty or the subdir so
> that you can easily "test -n $GIT_CWD". If you want to cd around you can
> do "cd ./$GIT_CWD" unconditionally. I think this is more useful than
> having a "." there.

In that case should the variable have a another name? CWD/PWD is
usually absolute path. "cd ./$GIT_CWD" looks odd to me. Or you can
getcwd() and set $OLDPWD.
-- 
Duy

  reply	other threads:[~2011-04-13 13:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4DA59B27.50506@ge.infn.it>
2011-04-13 13:05 ` [RFC/PATCH] handle_alias: provide GIT_CWD to !alias Michael J Gruber
2011-04-13 13:12   ` Nguyen Thai Ngoc Duy
2011-04-13 13:16     ` Michael J Gruber
2011-04-13 13:24       ` Nguyen Thai Ngoc Duy [this message]
2011-04-26 22:22   ` Junio C Hamano
2011-04-27  6:47     ` Michael J Gruber
2011-04-27  7:40       ` Nguyen Thai Ngoc Duy
2011-04-27  8:10         ` Michael J Gruber
2011-04-27  8:36           ` [PATCH 1/2] t1020: test !alias in subdirectory Michael J Gruber
2011-04-27  8:36             ` [PATCH 2/2] handle_alias: provide GIT_PREFIX to !alias Michael J Gruber
2011-04-27  9:06               ` Nguyen Thai Ngoc Duy
2011-04-27  9:36                 ` Michael J Gruber

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='BANLkTikKyJb283ZTaX0q=BYkCtp_48Yocg@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=matej.batic@ge.infn.it \
    /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 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 NNTP newsgroup(s).