threads / discuss / 53449

git-credential-store does not work with a file

Subject: git-credential-store does not work with a file

## tl;dr

3 messages between May 12, 2020 and May 13, 2020.

replies: 2people: 3as markdown or json

David Moseler· May 12, 2020, 00:40 UTC · lore
Hi,
I'm using git version 2.17.1. Providing a file to git-credential-store, such as in
git config credential.helper store --file='./git-credentials'
is not working. When using this command, git writes to ~/.git-credentials in the home folder anyway.
Carlo Marcelo Arenas Belón· May 12, 2020, 11:22 UTC · re: David Moseler · lore

Re: git-credential-store does not work with a file

On Tue, May 12, 2020 at 12:40:10AM +0000, David Moseler wrote:
Show 5 quoted lines
> Hi,
> 
> I'm using git version 2.17.1. Providing a file to git-credential-store, such as in
> 
> git config credential.helper store --file='./git-credentials'

your quoting is off, so you are passing to config only the value 'store' while the rest is ignored.

what you really meant to use is probably :
  git config credential.helper "store --file=$PWD/git-credentials"

note that using a relative path might not be what you really want, as the context for when that is run will not be what you expected most likely (ex: the root of your repository)

> is not working. When using this command, git writes to ~/.git-credentials in the home folder anyway.

note that credential.helper is a multi value setting, so you probably also want to clear the list first, if your intention was to only use that file and not the one in ~/.git-credentials.

see `git help gitcredentials` for details
Carlo
Junio C Hamano· May 13, 2020, 21:53 UTC · re: Carlo Marcelo Arenas Belón · lore

Re: git-credential-store does not work with a file

Carlo Marcelo Arenas Belón <carenas@gmail.com> writes:
Show 9 quoted lines
> On Tue, May 12, 2020 at 12:40:10AM +0000, David Moseler wrote:
>> Hi,
>> 
>> I'm using git version 2.17.1. Providing a file to git-credential-store, such as in
>> 
>> git config credential.helper store --file='./git-credentials'
>
> your quoting is off, so you are passing to config only the value 'store' while
> the rest is ignored.

Actually it is worse than that. If it were "the rest is ignored", we can fix it to give an error. But the problem is, the rest is *not* ignored. It is used as an argument with a meaning that the user did not expect it to have.

The above asks "we want to update the value of credential.helper variable(s) and set 'store' as its value, but we want to do so only for the entries whose current value match the regular expression given as the last argument".

It is unlikely that a credential.helper variable defined with the value "--file=./git-credentials", so the command silently succeeds after replacing 0 entries.

The same issue exists with "--replace-all", "--unset" and other forms of "git config" that take an optional value_regex.

This is now totally offtopic for a thread about credential-store, but we probably should fix the command line UI for this feature.

Perhaps
 1) Teach all the forms of "git config" that currently takes an
    optional value_regex to accept "--value-regexp=regex" option.
    It will be an error to give both --value-regexp parameter and
    the optional "value_regex" argument.  Wait for several releases.
 2) Update these forms to warn when the current "optional"
    value_regex syntax is used, and tell users to explicitly use the
    "--value-regexp=regex" option.  Wait for several releases.
 3) Remove support for the "optional" value_regex syntax and error
    out when it is used.
over a few years.

← back to recent threads