git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Vu <ryanvu87@gmail.com>
To: git@vger.kernel.org
Subject: gitconfig - interaction between credential.helper and includeIf
Date: Mon, 24 Jun 2024 22:59:33 -0700	[thread overview]
Message-ID: <CAF4erGWF+Lx=K09yFhd_abC2M5b5Ab0vM2uehkdVmridmsHqDg@mail.gmail.com> (raw)

What did you do before the bug happened? (Steps to reproduce your issue)

I created the following files:

``` ~/workspace/.gitconfig-workspace
[credential]
    helper = store --file ~/workspace/.git-credentials-workspace
```

``` ~/.gitconfig
[credential]
    helper = store
[includeIf "gitdir:~/workspace/"]
    path = ~/workspace/.gitconfig-workspace
```

I then tried to use my credentials in a repository under `~/workspace`.

What did you expect to happen? (Expected behavior)

I expected that within `~/workspace`, the credential file would be
`~/workspace/.git-credentials-workspace`.

I expected that outside `~/workspace`, the credential file would be
`~/.git-credentials`.

The two `.git-credentials*` files have different credentials to the same URL.

What happened instead? (Actual behavior)

The credentials within file `~/workspace/.git-credentials-workspace`
are not being properly applied for repositories within `~/workspace`.

What's different between what you expected and what actually happened?

I expected that `~/.git-credentials` and
`~/workspace/.git-credentials-workspace` would be isolated from each
other. But there are interactions even though `includeIf` was used.

Anything else you want to add:

The following configuration works:

``` ~/.gitconfig
[credential]
    helper = store
[includeIf "gitdir:~/workspace/"]
    path = ~/workspace/.gitconfig-workspace
[includeIf "gitdir:~/another-workspace/"]
    path = ~/another-workspace/.gitconfig-another-workspace
```

``` ~/another-workspace/.gitconfig-another-workspace
[credential]
    helper = store --file ~/another-workspace/.git-credentials-another-workspace
```

This is not ideal as repositories must be contained within these
enumerated paths.


This configuration has unexpected behavior:

``` ~/.gitconfig
[includeIf "gitdir:~/workspace/"]
    path = ~/workspace/.gitconfig-workspace
[credential]
    helper = store
```

The credential in `~/workspace/.git-credentials-workspace` will be
accessed and then stored into `~/.git-credentials`. Git is interacting
with both files.

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.45.2
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58
PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
compiler info: clang: 15.0.0 (clang-1500.3.9.4)
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/zsh


[Enabled Hooks]

             reply	other threads:[~2024-06-25  5:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25  5:59 Ryan Vu [this message]
2024-06-25 13:20 ` gitconfig - interaction between credential.helper and includeIf Jeff King
2024-06-25 16:53   ` Ryan Vu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF4erGWF+Lx=K09yFhd_abC2M5b5Ab0vM2uehkdVmridmsHqDg@mail.gmail.com' \
    --to=ryanvu87@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).