{"thread":{"id":"61678","subject":"gitconfig - interaction between credential.helper and includeIf","startedAt":"2024-06-25T05:59:45Z","lastAt":"2024-06-25T16:54:07Z","messageCount":3,"participants":["Ryan Vu","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"497603","messageId":"CAF4erGWF+Lx=K09yFhd_abC2M5b5Ab0vM2uehkdVmridmsHqDg@mail.gmail.com","threadId":"61678","inReplyTo":null,"subject":"gitconfig - interaction between credential.helper and includeIf","fromName":"Ryan Vu","fromEmail":"ryanvu87@gmail.com","sentAt":"2024-06-25T05:59:33Z","receivedAt":"2024-06-25T05:59:45Z","isPatch":false,"sender":{"key":"ryanvu87@gmail.com","avatar":null},"body":"What did you do before the bug happened? (Steps to reproduce your issue)\n\nI created the following files:\n\n``` ~/workspace/.gitconfig-workspace\n[credential]\n    helper = store --file ~/workspace/.git-credentials-workspace\n```\n\n``` ~/.gitconfig\n[credential]\n    helper = store\n[includeIf \"gitdir:~/workspace/\"]\n    path = ~/workspace/.gitconfig-workspace\n```\n\nI then tried to use my credentials in a repository under `~/workspace`.\n\nWhat did you expect to happen? (Expected behavior)\n\nI expected that within `~/workspace`, the credential file would be\n`~/workspace/.git-credentials-workspace`.\n\nI expected that outside `~/workspace`, the credential file would be\n`~/.git-credentials`.\n\nThe two `.git-credentials*` files have different credentials to the same URL.\n\nWhat happened instead? (Actual behavior)\n\nThe credentials within file `~/workspace/.git-credentials-workspace`\nare not being properly applied for repositories within `~/workspace`.\n\nWhat's different between what you expected and what actually happened?\n\nI expected that `~/.git-credentials` and\n`~/workspace/.git-credentials-workspace` would be isolated from each\nother. But there are interactions even though `includeIf` was used.\n\nAnything else you want to add:\n\nThe following configuration works:\n\n``` ~/.gitconfig\n[credential]\n    helper = store\n[includeIf \"gitdir:~/workspace/\"]\n    path = ~/workspace/.gitconfig-workspace\n[includeIf \"gitdir:~/another-workspace/\"]\n    path = ~/another-workspace/.gitconfig-another-workspace\n```\n\n``` ~/another-workspace/.gitconfig-another-workspace\n[credential]\n    helper = store --file ~/another-workspace/.git-credentials-another-workspace\n```\n\nThis is not ideal as repositories must be contained within these\nenumerated paths.\n\n\nThis configuration has unexpected behavior:\n\n``` ~/.gitconfig\n[includeIf \"gitdir:~/workspace/\"]\n    path = ~/workspace/.gitconfig-workspace\n[credential]\n    helper = store\n```\n\nThe credential in `~/workspace/.git-credentials-workspace` will be\naccessed and then stored into `~/.git-credentials`. Git is interacting\nwith both files.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n[System Info]\ngit version:\ngit version 2.45.2\ncpu: arm64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58\nPDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64\ncompiler info: clang: 15.0.0 (clang-1500.3.9.4)\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n"},{"id":"497619","messageId":"20240625132001.GA535756@coredump.intra.peff.net","threadId":"61678","inReplyTo":"CAF4erGWF+Lx=K09yFhd_abC2M5b5Ab0vM2uehkdVmridmsHqDg@mail.gmail.com","subject":"Re: gitconfig - interaction between credential.helper and includeIf","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-06-25T13:20:01Z","receivedAt":"2024-06-25T13:20:06Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 24, 2024 at 10:59:33PM -0700, Ryan Vu wrote:\n\n> I created the following files:\n> \n> ``` ~/workspace/.gitconfig-workspace\n> [credential]\n>     helper = store --file ~/workspace/.git-credentials-workspace\n> ```\n> \n> ``` ~/.gitconfig\n> [credential]\n>     helper = store\n> [includeIf \"gitdir:~/workspace/\"]\n>     path = ~/workspace/.gitconfig-workspace\n> ```\n\ncredential.helper is a multi-valued config key that forms a list, and\nGit will try each one in sequence. So in your ~/workspace repositories,\nyou've configured _two_ helpers: a vanilla \"store\" and one with the\n--file option.\n\nYou can reset the list with an empty string. So putting:\n\n  [credential]\n  helper =\n  helper = store --file ~/workspace/.git-credentials-workspace\n\nin your .gitconfig-workspace would do what you want.\n\n-Peff\n"},{"id":"497627","messageId":"CAF4erGXkP3AR3dNvsqmo5FBLxOaGZhd9pHCHKsL8Q0BV5BiKJA@mail.gmail.com","threadId":"61678","inReplyTo":"20240625132001.GA535756@coredump.intra.peff.net","subject":"Re: gitconfig - interaction between credential.helper and includeIf","fromName":"Ryan Vu","fromEmail":"ryanvu87@gmail.com","sentAt":"2024-06-25T16:53:55Z","receivedAt":"2024-06-25T16:54:07Z","isPatch":false,"sender":{"key":"ryanvu87@gmail.com","avatar":null},"body":"Thank you! I have the configurations working now.\n\nOn Tue, Jun 25, 2024 at 6:20 AM Jeff King <peff@peff.net> wrote:\n>\n> On Mon, Jun 24, 2024 at 10:59:33PM -0700, Ryan Vu wrote:\n>\n> > I created the following files:\n> >\n> > ``` ~/workspace/.gitconfig-workspace\n> > [credential]\n> >     helper = store --file ~/workspace/.git-credentials-workspace\n> > ```\n> >\n> > ``` ~/.gitconfig\n> > [credential]\n> >     helper = store\n> > [includeIf \"gitdir:~/workspace/\"]\n> >     path = ~/workspace/.gitconfig-workspace\n> > ```\n>\n> credential.helper is a multi-valued config key that forms a list, and\n> Git will try each one in sequence. So in your ~/workspace repositories,\n> you've configured _two_ helpers: a vanilla \"store\" and one with the\n> --file option.\n>\n> You can reset the list with an empty string. So putting:\n>\n>   [credential]\n>   helper =\n>   helper = store --file ~/workspace/.git-credentials-workspace\n>\n> in your .gitconfig-workspace would do what you want.\n>\n> -Peff\n"}]}