{"thread":{"id":"56686","subject":"Inconsistency in git credential helper docs","startedAt":"2021-10-11T21:36:26Z","lastAt":"2021-10-12T02:21:57Z","messageCount":2,"participants":["Chris Chow","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"438507","messageId":"CAH4DS54U-qN+NY2A50bBawbL1cwD74fdaZdQKdhXyZSzFS-Y+g@mail.gmail.com","threadId":"56686","inReplyTo":null,"subject":"Inconsistency in git credential helper docs","fromName":"Chris Chow","fromEmail":"cchow@nianticlabs.com","sentAt":"2021-10-11T21:36:13Z","receivedAt":"2021-10-11T21:36:26Z","isPatch":false,"sender":{"key":"cchow@nianticlabs.com","avatar":null},"body":"Hello,\n\nThere appears to be a small inconsistency / bug in the documentation\nlocated at https://git-scm.com/docs/gitcredentials.\n\nUnder the \"Custom Helpers\" subhead, there's a line that reads\n> Generally speaking, rule (3) above is the simplest for users to specify. Authors of credential helpers should make an effort to assist their users by naming their program \"git-credential-$NAME\", and putting it in the $PATH or $GIT_EXEC_PATH during installation, which will allow a user to enable it with git config credential.helper $NAME.\n\nEarlier in the document, under \"Configuration Options > helper\", there\nis a line that reads\n> The name of an external credential helper, and any associated options. If the helper name is not an absolute path, then the string git credential- is prepended\n\nI think the latter text is correct. The maintainers of the google\ncloud SDK followed the advice in the first part, naming their cred\nhelper `git-credential-gcloud.sh`, which is not accessible if you set\nthe custom credential helper to `gcloud.sh`. I had to make a symlink\nat `credential-gcloud.sh`, following the instructions in the latter\nblock, to make it work. One could of course just specify the full path\nin .gitconfig, but I figured it might be good to have these parts be\nconsistent anyways.\n\nBest,\nChris\n"},{"id":"438514","messageId":"YWTxQrOBTT8bWmFg@coredump.intra.peff.net","threadId":"56686","inReplyTo":"CAH4DS54U-qN+NY2A50bBawbL1cwD74fdaZdQKdhXyZSzFS-Y+g@mail.gmail.com","subject":"Re: Inconsistency in git credential helper docs","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-10-12T02:21:54Z","receivedAt":"2021-10-12T02:21:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 11, 2021 at 02:36:13PM -0700, Chris Chow wrote:\n\n> There appears to be a small inconsistency / bug in the documentation\n> located at https://git-scm.com/docs/gitcredentials.\n\nI'm not sure I see what you mean.\n\n> Under the \"Custom Helpers\" subhead, there's a line that reads\n> > Generally speaking, rule (3) above is the simplest for users to specify. Authors of credential helpers should make an effort to assist their users by naming their program \"git-credential-$NAME\", and putting it in the $PATH or $GIT_EXEC_PATH during installation, which will allow a user to enable it with git config credential.helper $NAME.\n\nOK, so here you'd call your helper git-credential-gcloud.sh so that:\n\n  git config credential.helper gcloud.sh\n\nwould work.\n\n> Earlier in the document, under \"Configuration Options > helper\", there\n> is a line that reads\n> > The name of an external credential helper, and any associated options. If the helper name is not an absolute path, then the string git credential- is prepended\n\nAnd likewise here, we will run \"git credential-gcloud.sh\", which in turn\ncalls \"git-credential-gcloud.sh\" (since there is no builtin of that\nname).\n\nBut we would never call \"credential-gcloud.sh\" in this way. You\ncould say:\n\n  git config credential.helper '!credential-gcloud.sh'\n\nof course, but that is skipping the auto-name stuff entirely.\n\n> I think the latter text is correct. The maintainers of the google\n> cloud SDK followed the advice in the first part, naming their cred\n> helper `git-credential-gcloud.sh`, which is not accessible if you set\n> the custom credential helper to `gcloud.sh`. I had to make a symlink\n> at `credential-gcloud.sh`, following the instructions in the latter\n> block, to make it work. One could of course just specify the full path\n> in .gitconfig, but I figured it might be good to have these parts be\n> consistent anyways.\n\nBoth pieces of text are pointing to the name that the gcloud folks used.\nI'm not sure why it didn't work, or how a symlink could possibly have\nhelped. Can you share the exact sequence of commands, with output, that\nshows what you're seeing?\n\nHere's a toy example that shows the kind of thing that should work:\n\n  # toy helper that lets us know when it's running\n  { echo '#!/bin/sh' && echo 'echo >&2 running the foo helper'; } >foo.sh\n  chmod +x foo.sh\n\n  # add our current directory to PATH to experiment; usually these\n  # commands would go into /usr/local/bin, ~/bin, etc\n  export PATH=$PATH:$PWD\n\n  # make sure we're in a repo so we can stick our config somewhere. In\n  # the real world you'd probably be using \"git config --global\" or\n  # similar.\n  git init\n  git config credential.helper foo.sh\n\n  # this should say \"credential-foo.sh is not a git command\", because we\n  # tried to run \"git credential-foo.sh\", but that doesn't exist (the\n  # command itself is a noop; it just tries to remove a bogus credential\n  # that you don't actually have, but that's enough to trigger each\n  # helper).\n  echo url=https://user:pass@example.com | git credential reject\n\n  # now try it again with credential-foo.sh in the path. That also won't\n  # work, with the same outcome.\n  mv foo.sh credential-foo.sh\n  echo url=https://user:pass@example.com | git credential reject\n\n  # now try it with git-credential-foo.sh in the path. This should\n  # trigger the helper successfully.\n  mv credential-foo.sh git-credential-foo.sh\n  echo url=https://user:pass@example.com | git credential reject\n\nWhat I'm suspecting is that the \"credential-foo.sh is not a git command\"\nmessage may have confused you, and then while debugging it you did\nsomething else (e.g., tweaking your PATH, setting the execute bit, etc)\nthat led the original git-credential-gcloud.sh to work.\n\n-Peff\n"}]}