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

Git credential-cache manager is not treating `path=` correctly

From
Gabriel Nützi <gnuetzi@gmail.com>
Date
Aug 23, 2023, 16:23 UTC
Message-ID
<CAA9rTuccfyXO66YApDfss6JM9+JuUzZxDiYyfG_qShfehyAEsQ@mail.gmail.com>

I report this potential bug: https://stackoverflow.com/questions/76963207/git-credential-cache-does-not-matchpath-correctly

I really dont get Git `2.41.0` and its crude `git credential-cache` manager:

When I test `git credential-cache` with the below script (`setsid test.sh`). if it can report 3 different passwords it will fail with

``` fatal: could not read Username for 'https://www.server.com/repos/1.git': No such device or address ``` on the first run, and when the script runs **a second time** it will pass happily.

The `git credential-store` on the other hand does not work at all and on the first `git credential fill` prompt the user.

**Question: What is going on here. This makes no sense and results in peculiar fails on CI**

*Note: setsid is to detach from the controlling terminal that git does not prompt or something.* *Note: We need `useHttpPath=true` to tell Git to use the `path` in credential `fill` statements (AFAIK).

```shell #!/bin/bash set -e # set -x # IMPORTANT: ======================================= # Execute this script inside a container # and check if it reports all password correctly # # ==================================================

# git credential-cache exit || true

git config --global --unset-all credential.helper || true git config --global --add credential.helper "" # git config --global --add credential.helper "store" # Does not work at all. git config --global --add credential.helper "cache --timeout=7200"

git config --global "credential.https://www.server.com/repos/1.git.useHttpPath" true git config --global "credential.https://www.server.com/repos/2.git.useHttpPath" true

export GIT_TRACE=1
# Add 3 credentials, 2 specifics with `path=`
# 1 with general host.
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/1.git"
    echo "username=banana"
    echo "password=banana1"
} | git credential approve
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/2.git"
    echo "username=banana"
    echo "password=banana2"
} | git credential approve
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "username=banana"
    echo "password=general"
} | git credential approve
echo "Check the credentials"
# Check it
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/1.git"
} | git credential fill | grep -q "password=banana1" || {
    echo "wrong pass banana1"
    exit 1
}
{
    echo "protocol=https"
    echo "host=www.server.com"
    echo "path=repos/2.git"
} | git credential fill | grep -q "password=banana2" || {
    echo "wrong pass banana2"
    exit 1
}
{
    echo "protocol=https"
    echo "host=www.server.com"
} | git credential fill | grep -q "password=general" || {
    echo "wrong pass general"
    exit 1
}

echo "all passwords correctly reported" ```

Next: Jeff King
Message 1 of 4 in “Git credential-cache manager is not treating `path=` correctly”
  1. Gabriel NütziAug 23, 2023
  2. Jeff KingAug 23, 2023
  3. Ganriel NütziAug 23, 2023
  4. Jeff KingAug 24, 2023

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.