git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH] handle_alias: provide GIT_CWD to !alias

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Apr 13, 2011, 13:16 UTC
Message-ID
<4DA5A228.2040105@drmicha.warpmail.net>
In-Reply-To
<BANLkTimubmaV437LvdG8QcmFFjyWujQRzw@mail.gmail.com>
Nguyen Thai Ngoc Duy venit, vidit, dixit 13.04.2011 15:12:
Show 14 quoted lines
> 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...
> 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.

Michael
Previous: Nguyen Thai Ngoc DuyNext: Nguyen Thai Ngoc Duy
Message 3 of 12 in “handle_alias: provide GIT_CWD to !alias”
  1. handle_alias: provide GIT_CWD to !aliasMichael J Gruber, Apr 13, 2011
  2. Nguyen Thai Ngoc DuyApr 13, 2011
  3. Michael J GruberApr 13, 2011
  4. Nguyen Thai Ngoc DuyApr 13, 2011
  5. Junio C HamanoApr 26, 2011
  6. Michael J GruberApr 27, 2011
  7. Nguyen Thai Ngoc DuyApr 27, 2011
  8. Michael J GruberApr 27, 2011
  9. 1/2 t1020: test !alias in subdirectoryMichael J Gruber, Apr 27, 2011
  10. 2/2 handle_alias: provide GIT_PREFIX to !aliasMichael J Gruber, Apr 27, 2011
  11. Nguyen Thai Ngoc DuyApr 27, 2011
  12. Michael J GruberApr 27, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.