Michael McNeil Forbes <michael.for...@gmail.com> writes:
On Apr 3, 2018, at 12:07 PM, Magnus Therning <mag...@therning.org> wrote:Michael Forbes <michael.for...@gmail.com> writes:Hi,I am trying to find a good solution to this use-case that seems to requireexpansion in the .gitconfig file:1. Multiple users share the same account on a machine (this is using CoCalc <http://cocalc.org> where the user is the project id so changing this isnot an option).2. We would like to be able to use git, but with proper recording of whichuser made the commit.I work this with mercurial by having each user set an environment variable when they log in, and then adding the following to the project .hgrc file:[ui] username = $LC_HG_USERNAMEThis fails in the .gitconfig file as expansion is not performed<https://stackoverflow.com/questions/11262010/shell-variable-expansion-in-git-config/11262153#11262153>.A workaround suggested there is to do something like this in the .bashrcfile: git config --global user.name=$LC_GIT_USERNAMEThis means, however, that all commits will be logged as the last user who logged in - which mucks up the use case where multiple people might belogged in at the same time.Any suggestions for how to get git to work nicely in this case?If I understand you correctly you rely on the logged in user setting$LC_GIT_USERNAME properly, how is that done?If it's done using some script, maybe you can simply modify that scriptto *create* the proper ~/.gitconfig at the same time?The user sets LC_GIT_USERNAME properly on their own computer, then when they ssh to the shared machine, this variable is passed throughby ssh. Each user on the shared machine thus has an appropriateLC_GIT_USERNAME in their environment that I want git to use. If anyone modifies ~/.gitconfig on the shared machine, then it will affect allusers, so that is not a good option.
Oh, so it's a requirement that more than one user can be logged in at a
time, on the same account, and having different settings for `ui.username`? You can direct `git` to a specific configuration file using `$GIT_CONFIG`. So an option would be to set it based on `$LC_GIT_USERNAME` upon login (you can create the configuration automatically on login too, if you want to.) /M -- Magnus Therning OpenPGP: 0x927912051716CE39 email: mag...@therning.org jabber: mag...@therning.org twitter: magthe http://therning.org/magnusIt is better to keep your mouth shut and appear stupid than to open it
and remove all doubt. — Mark Twain -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: PGP signature