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:49:16 +0530 Message-ID: <20110714174916.07dd314d@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: Carlos =?UTF-8?B?TWFydMOtbg==?= Nieto , =?UTF-8?B?w4Z2?= =?UTF-8?B?YXIgQXJuZmrDtnLDsA==?= , git@vger.kernel.org To: kusmabite@gmail.com X-From: git-owner@vger.kernel.org Thu Jul 14 14:19:22 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 1QhKsz-00025j-Tb for gcvg-git-2@lo.gmane.org; Thu, 14 Jul 2011 14:19:22 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754584Ab1GNMTQ convert rfc822-to-quoted-printable (ORCPT ); Thu, 14 Jul 2011 08:19:16 -0400 Received: from static.206.87.46.78.clients.your-server.de ([78.46.87.206]:40885 "EHLO Kolkata.infoservices.in" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754111Ab1GNMTP convert rfc822-to-8bit (ORCPT ); Thu, 14 Jul 2011 08:19:15 -0400 Received: from shiva.selfip.org (unknown [122.176.30.116]) by Kolkata.infoservices.in (Postfix) with ESMTPSA id ED1952004001; Thu, 14 Jul 2011 14:19:10 +0200 (CEST) In-Reply-To: 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 14:00:06 +0200 Erik Faye-Lund wrote: > On Thu, Jul 14, 2011 at 1:38 PM, 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: > >> > >> > 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 wrot= e: > >> > > > >> > > > On Thu, Jul 14, 2011 at 12:36, J. Bakshi > >> > > 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: > >> > > > > >> > > > =C2=A0 =C2=A0 export GIT_AUTHOR_NAME=3D$(cat ~/PASSWD) > >> > > > > >> > > > ? > >> > > > >> > > Thanks. > >> > > > >> > > [1] will it work with file generated by htpasswd ? as that fil= e 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 nomenclatur= e. The > >> > commits all happen locally and need no authentication whatsoever= (and > >> > usually you're expected to use a real name and email address). W= hen you > >> > need to authenticate is when yuou push your changes somewhere (a= central > >> > repo, for example). This is where the ~/.netrc file comes into p= lay, 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 htt= p. > >> 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 automaticall= y > >> 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 com= mits > > 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. >=20 > 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 yo= u > 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= =2E >=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= how > > to do it. > > > > =C2=A0 =C2=A0git config user.name "Max Smith" > > =C2=A0 =C2=A0git config user.mail max.smith@example.com > > > > and if the config should be valid for every repo, use --global flag= =2E > > There is more information in the manual page. > > > > You could then add a check in the post-receive hook to reject pushe= s > > with invalid author names, if you feel it's worth it. > > >=20 > Denying a push is much more elegant than rewriting, but (as I pointed > out in my other mail) also has a lot of problems with distributed > work-flows. And let's face it when changing from SVN to Git, the > distributed nature is about the last feature that you'd want to give > up ;) >=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= 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 n= ot > > tell them to set it to that[0]? It seems like you are trying to sol= ve a > > social issue with a technological measure that works at a different > > level. >=20 > Very well said, I completely agree! As I mentioned already in my previous mail, it is not an issue but we p= resently use it with svn in a positive way. Say 5 designer are working with same template, but in different section= =2E So it is very easy to understand who is working on what and also these 5 designers can see/review the codes among them and how = previous code effect their work. So this features are exploited here wi= th that positive direction.=20