Re: [PATCH/RFC] git.c: support "!!" aliases that do not move cwd
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 6, 2016, 18:42 UTC
- Message-ID
- <xmqq60p5l3om.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20161006114124.4966-1-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 12 quoted lines
> Throwing something at the mailing list to see if anybody is > interested. > > Current '!' aliases move cwd to $GIT_WORK_TREE first, which could make > handling path arguments hard because they are relative to the original > cwd. We set GIT_PREFIX to work around it, but I still think it's more > natural to keep cwd where it is. > > We have a way to do that now after 441981b (git: simplify environment > save/restore logic - 2016-01-26). It's just a matter of choosing the > right syntax. I'm going with '!!'. I'm not very happy with it. But I > do like this type of alias.
I do not know why you are not happy with the syntax, but I personally think it brilliant, both the idea and the preliminary clean-up that made this possible with a simple patch like this.
Show 20 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> git.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/git.c b/git.c
> index 296857a..4c1dcf4 100644
> --- a/git.c
> +++ b/git.c
> @@ -252,6 +252,10 @@ static int handle_alias(int *argcp, const char ***argv)
>
> alias_string++;
> commit_pager_choice();
> + if (*alias_string == '!') {
> + keep_cwd = 0;
> + alias_string++;
> + }
> restore_env(keep_cwd);
>
> child.use_shell = 1;