From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id ABA1A1F5AE for ; Wed, 5 May 2021 18:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234640AbhEESdd (ORCPT ); Wed, 5 May 2021 14:33:33 -0400 Received: from cloud.peff.net ([104.130.231.41]:45692 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbhEESdd (ORCPT ); Wed, 5 May 2021 14:33:33 -0400 Received: (qmail 19603 invoked by uid 109); 5 May 2021 18:32:35 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 05 May 2021 18:32:35 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 12528 invoked by uid 111); 5 May 2021 18:32:36 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 05 May 2021 14:32:36 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 5 May 2021 14:32:35 -0400 From: Jeff King To: Eric Sunshine Cc: Theodor Negrescu , Git List Subject: Re: BUG: Git path --config doesn't work with ~ symbol Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Wed, May 05, 2021 at 02:21:38PM -0400, Eric Sunshine wrote: > On Wed, May 5, 2021 at 2:14 PM Jeff King wrote: > > On Wed, May 05, 2021 at 09:06:12PM +0300, Theodor Negrescu wrote: > > > I ran the command "git config --file ~/git-settings/.gitconfig -l" > > > (git-settings is a repo where I keep my config, the global one is just > > > an include) > > > > I don't think this is a bug in git-config. It is generally the shell > > that is responsible for expanding "~" and passing along the result to > > commands. E.g.: > > > > $ strace -e execve git config --file ~/foo --list > > execve("/home/peff/local/git/current/bin/git", ["git", "config", "--file", "/home/peff/foo", "--list"], 0x7ffc10a88130 /* 55 vars */) = 0 > > > > I'd guess this might be related to Windows somehow. Are you entering the > > command in a bash shell, or via some other mechanism? > > Is OPT_FILENAME supposed to handle tilde-expansion? I ask because > git-config is using OPT_STRING for this option, whereas other commands > use OPT_FILENAME for their `--file` options. No, I don't think so. The point of OPT_FILENAME() is that it handles the directory-change from setting up the git directory before we even the the cmd_*() function. But that isn't necessary here, because cmd_config() applies the prefix manually. So this works as expected: $ git init $ mkdir subdir $ git config --file=foo my.dir root $ git config --file=subdir/foo my.dir sub $ git config --file=foo --list my.dir=root $ cd subdir $ git config --file=foo --list my.dir=sub Possibly the code could be simplified a little by using OPT_FILENAME(), though. -Peff