From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J. Bakshi" Subject: Re: How to force git to use authentication as author Date: Thu, 14 Jul 2011 17:31:29 +0530 Message-ID: <20110714173129.1116e4b2@shiva.selfip.org> References: <20110714160638.065b6542@shiva.selfip.org> <20110714161838.1e30893a@shiva.selfip.org> <1310641202.18730.16.camel@bee.lab.cmartin.tk> <20110714164547.0b359e60@shiva.selfip.org> <1310643482.6041.17.camel@centaur.lab.cmartin.tk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: =?UTF-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , git@vger.kernel.org To: Carlos =?UTF-8?B?TWFydMOtbg==?= Nieto X-From: git-owner@vger.kernel.org Thu Jul 14 14:01:31 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QhKbj-0001HS-9e for gcvg-git-2@lo.gmane.org; Thu, 14 Jul 2011 14:01:31 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754584Ab1GNMB1 convert rfc822-to-quoted-printable (ORCPT ); Thu, 14 Jul 2011 08:01:27 -0400 Received: from static.206.87.46.78.clients.your-server.de ([78.46.87.206]:36029 "EHLO Kolkata.infoservices.in" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754580Ab1GNMB0 convert rfc822-to-8bit (ORCPT ); Thu, 14 Jul 2011 08:01:26 -0400 Received: from shiva.selfip.org (unknown [122.176.30.116]) by Kolkata.infoservices.in (Postfix) with ESMTPSA id 87BA22004001; Thu, 14 Jul 2011 14:01:23 +0200 (CEST) In-Reply-To: <1310643482.6041.17.camel@centaur.lab.cmartin.tk> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Thu, 14 Jul 2011 13:38:02 +0200 Carlos Mart=C3=ADn Nieto wrote: > On Thu, 2011-07-14 at 16:45 +0530, J. Bakshi wrote: > > On Thu, 14 Jul 2011 13:00:02 +0200 > > Carlos Mart=C3=ADn Nieto wrote: > >=20 > > > On Thu, 2011-07-14 at 16:18 +0530, J. Bakshi wrote: > > > > On Thu, 14 Jul 2011 12:38:59 +0200 > > > > =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason wrote= : > > > >=20 > > > > > On Thu, Jul 14, 2011 at 12:36, J. Bakshi > > > > wrote: > > > > >=20 > > > > > > How can I force git to use the username as define > > > > at /home/git/PASSWD as the author name for git commit ? > > > > >=20 > > > > > Edit the global bashrc to have: > > > > >=20 > > > > > export GIT_AUTHOR_NAME=3D$(cat ~/PASSWD) > > > > >=20 > > > > > ? > > > >=20 > > > > Thanks.=20 > > > >=20 > > > > [1] will it work with file generated by htpasswd ? as that file= is > > > > actually created by same (/home/git/PASSWD) > > >=20 > > > Not directly, if it only has one line, then $(cat ~/PASSWD | cut = -d ':' > > > -f 1) should work, but I haven't tested it. > > >=20 > > > >=20 > > > > [2] And the commit is over http, So is it effective to set the = value > > > > by .bashrc ? > > >=20 > > > You are misunderstanding either how git works or the nomenclature= =2E The > > > commits all happen locally and need no authentication whatsoever = (and > > > usually you're expected to use a real name and email address). Wh= en you > > > need to authenticate is when yuou push your changes somewhere (a = central > > > repo, for example). This is where the ~/.netrc file comes into pl= ay, as > > > I mentioned in the reply to your other mail. > > >=20 > > 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= =2E > > 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. >=20 > That's not how it works. It may even be possible to rewrite the commi= ts > in the post-receive hook in a way that most stuff doesn't break > horribly, this would be rewriting history behind the users' backs, an= d > that only brings problems. >=20 > 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 h= ow > to do it. >=20 > git config user.name "Max Smith" > git config user.mail max.smith@example.com >=20 > and if the config should be valid for every repo, use --global flag. > There is more information in the manual page. >=20 > 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. >=20 > 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 y= ou > 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. >=20 Certainly not an issue at all. As I have mentioned before it is how the= svn repo is working here.=20 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 a= s I have found it is not possible right now http://permalink.gmane.org/gmane.comp.version-control.git/171444