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

Re: How to force git to use authentication as author

From
Ferry Huberts <mailings@hupie.com>
Date
Jul 14, 2011, 12:16 UTC
Message-ID
<4E1EDE19.6060109@hupie.com>
In-Reply-To
<20110714173129.1116e4b2@shiva.selfip.org>
On 07/14/2011 02:01 PM, J. Bakshi wrote:
Show 83 quoted lines
> On Thu, 14 Jul 2011 13:38:02 +0200
> Carlos Martín Nieto <cmn@elego.de> wrote:
> 
>> On Thu, 2011-07-14 at 16:45 +0530, J. Bakshi wrote:
>>> On Thu, 14 Jul 2011 13:00:02 +0200
>>> Carlos Martín Nieto <cmn@elego.de> wrote:
>>>
>>>> On Thu, 2011-07-14 at 16:18 +0530, J. Bakshi wrote:
>>>>> On Thu, 14 Jul 2011 12:38:59 +0200
>>>>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>>>>>
>>>>>> On Thu, Jul 14, 2011 at 12:36, J. Bakshi <joydeep@infoservices.in>
>>>>> wrote:
>>>>>>
>>>>>>> How can I force git to use the username as define
>>>>> at /home/git/PASSWD as the author name for git commit ?
>>>>>>
>>>>>> Edit the global bashrc to have:
>>>>>>
>>>>>>     export GIT_AUTHOR_NAME=$(cat ~/PASSWD)
>>>>>>
>>>>>> ?
>>>>>
>>>>> Thanks. 
>>>>>
>>>>> [1] will it work with file generated by htpasswd ? as that file is
>>>>> actually created by same (/home/git/PASSWD)
>>>>
>>>> Not directly, if it only has one line, then $(cat ~/PASSWD | cut -d ':'
>>>> -f 1) should work, but I haven't tested it.
>>>>
>>>>>
>>>>> [2] And the commit is over http, So is it effective to set the value
>>>>> by .bashrc ?
>>>>
>>>> You are misunderstanding either how git works or the nomenclature. The
>>>> commits all happen locally and need no authentication whatsoever (and
>>>> usually you're expected to use a real name and email address). When you
>>>> need to authenticate is when yuou push your changes somewhere (a central
>>>> repo, for example). This is where the ~/.netrc file comes into play, as
>>>> I mentioned in the reply to your other mail.
>>>>
>>> Exactly, when we need to push we are asked about authentication. I
>>> like to configure the central git server in a way so that the
>>> user-name as in authentication, be set as author name by the git
>>> server itself. actually it is how I configured svn server over http.
>>> So comparing to that I am trying to achieve the same. Say your
>>> user-name is there at htpasswd file as Carlos, so when you
>>> authenticate by Carlos to push , the author-name will automatically
>>> become as Carlos. No way to customize that with specific username.
>>> That's the idea.
>>
>> That's not how it works. It may even be possible to rewrite the commits
>> in the post-receive hook in a way that most stuff doesn't break
>> horribly, this would be rewriting history behind the users' backs, and
>> that only brings problems.
>>
>> The way to set the author name and mail in a standard way, be it
>> user-wide or per-repo. You can write up some simple instructions on how
>> to do it.
>>
>>     git config user.name "Max Smith"
>>     git config user.mail max.smith@example.com
>>
>> and if the config should be valid for every repo, use --global flag.
>> There is more information in the manual page.
>>
>> You could then add a check in the post-receive hook to reject pushes
>> with invalid author names, if you feel it's worth it.
>>
>> Taking a step back, why is this even an issue, though? If you don't
>> trust your developers to set their name and email correctly, why do you
>> trust them to write code? If it's company policy for people to be
>> referred to by their usernames rather than their given names, why not
>> tell them to set it to that[0]? It seems like you are trying to solve a
>> social issue with a technological measure that works at a different
>> level.
>>
> 
> Certainly not an issue at all. As I have mentioned before it is how the svn repo is working here. 
> So we are trying to follow the same with git too. Without effecting too much of the already running
> environment, so that the users need not bother too much with git. But as I have found it is not possible right now
> 
As Erik said:
Show 5 quoted lines
> This will (as you point out) only lead to problems, because rewriting
> the history at commit-time will have the effect that a push leaves you
> in the situation where you end up with a different history on the
> workstation and the server. All branches off the pushed branch will
> become a hell, and a clusterfck of darkness and terror will take over.

SVN and Git are _totally_ different models. Do not try to force Git into the svn model, it'll just give you __major__ headaches.

OTOH: It'll teach your users all the advanced uses of Git very rapidly. LOL
Show 5 quoted lines
> http://permalink.gmane.org/gmane.comp.version-control.git/171444
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Ferry Huberts
Previous: J. BakshiNext: Jakub Narebski
Message 11 of 15 in “How to force git to use authentication as author”
  1. J. BakshiJul 14, 2011
  2. Ævar Arnfjörð BjarmasonJul 14, 2011
  3. J. BakshiJul 14, 2011
  4. Carlos Martín NietoJul 14, 2011
  5. J. BakshiJul 14, 2011
  6. Carlos Martín NietoJul 14, 2011
  7. Erik Faye-LundJul 14, 2011
  8. J. BakshiJul 14, 2011
  9. Carlos Martín NietoJul 14, 2011
  10. J. BakshiJul 14, 2011
  11. Ferry HubertsJul 14, 2011
  12. Jakub NarebskiJul 14, 2011
  13. J. BakshiJul 14, 2011
  14. Erik Faye-LundJul 14, 2011
  15. Jonathan NiederJul 14, 2011

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.