From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-1.7 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_WEB,T_RP_MATCHES_RCVD shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 0418F20282 for ; Tue, 13 Jun 2017 11:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752249AbdFML0E (ORCPT ); Tue, 13 Jun 2017 07:26:04 -0400 Received: from mout.gmx.net ([212.227.17.21]:55767 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752109AbdFML0E (ORCPT ); Tue, 13 Jun 2017 07:26:04 -0400 Received: from virtualbox ([37.201.192.198]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MJmcS-1dJe1m2JW8-001EKd; Tue, 13 Jun 2017 13:25:54 +0200 Date: Tue, 13 Jun 2017 13:25:53 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Jeff King cc: git@vger.kernel.org, Junio C Hamano Subject: Re: [PATCH v2 8/8] Use the early config machinery to expand aliases In-Reply-To: <20170610100730.j62kh2hayt6zknr5@sigill.intra.peff.net> Message-ID: References: <20170610100730.j62kh2hayt6zknr5@sigill.intra.peff.net> User-Agent: Alpine 2.21.1 (DEB 209 2017-03-23) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K0:91YGaP0ZRRW6e6Gf4CcY+TP+ertDIdcarpV1t0pstciqXhjNHsW Q/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: X-Mailing-List: git@vger.kernel.org Hi Peff, On Sat, 10 Jun 2017, Jeff King wrote: > On Thu, Jun 08, 2017 at 09:53:53PM +0200, Johannes Schindelin wrote: > > > @@ -245,36 +201,37 @@ static int handle_options(const char ***argv, int *argc, int *envchanged) > > > > static int handle_alias(int *argcp, const char ***argv) > > { > > + struct strbuf cdup_dir = STRBUF_INIT; > > int envchanged = 0, ret = 0, saved_errno = errno; > > int count, option_count; > > const char **new_argv; > > const char *alias_command; > > char *alias_string; > > - int unused_nongit; > > - > > - save_env_before_alias(); > > - setup_git_directory_gently(&unused_nongit); > > > > alias_command = (*argv)[0]; > > - alias_string = alias_lookup(alias_command, NULL); > > + alias_string = alias_lookup(alias_command, &cdup_dir); > > if (alias_string) { > > if (alias_string[0] == '!') { > > struct child_process child = CHILD_PROCESS_INIT; > > > > + if (cdup_dir.len) > > + setup_git_directory(); > > + > > I'm really confused here. We went to all the trouble to record the > cdup_dir as part of the alias lookup so that we could make sure to > chdir() to it. Right, that was my first idea. But then the test suite taught me that we set at least GIT_PREFIX and that tests break (or, in other words, promises Git made earlier) if those variables are not set. So as a quick fix, I simply called setup_git_directory() instead of chdir(cdup_dir.buf). > I understand why you must use setup_git_directory() and not just a > chdir(), because the latter sets up variables like GIT_PREFIX and > GIT_DIR that the shell alias may be depending on. Exactly. > But couldn't we just unconditionally do: > > setup_git_directory_gently(); But of course we can do that! Why on earth did I not think of that... Will change the code accordingly. Ciao, Dscho