git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to use git attributes to configure server-side checks?
@ 2011-09-21 19:32 Michael Haggerty
  2011-09-21 20:02 ` Jay Soffian
  2011-09-21 20:17 ` Junio C Hamano
  0 siblings, 2 replies; 31+ messages in thread
From: Michael Haggerty @ 2011-09-21 19:32 UTC (permalink / raw)
  To: git discussion list

I was thinking of using git attributes to configure a server-side
"update" hook that does some basic sanity checking before accepting a
push.  I thought I could do something like

~/.gitattributes:
    *.c whitespace

~/crappy-vendor-code/.gitattributes:
    # This code doesn't conform to our standards; disable check:
    *.c -whitespace

This would allow fine-grained specification of which checks are applied
to which files, and ensure that the hook configuration is kept
synchronized with changes to the content.

What I can't figure out is how a server-side update hook can inquire
about the gitattributes that were associated with a file *in a
particular commit*, as opposed to in the current working tree.  I would
like to ask questions like "was the "whitespace" attribute set on file F
in commit C?"

I see that there is an (undocumented) API involving
git_attr_set_direction() that seems to let gitattributes to be read out
of the index instead of the working tree.  But I am still confused:

1. The "git check-attr" program doesn't seem to expose the
git_attr_set_direction() functionality.

2. Even if it did, would that be enough?  It seems like the update hook
(assuming a bare repository) would have to "git reset" the index to the
commit that it wants to check.  Is that allowed?  Is the index a scratch
space that the update hook can use however it likes?  If so, is there
some kind of locking that would prevent multiple simultaneous pushes
from overwriting each other's index stat, or would the update script
have to implement its own locking scheme?

Am I going about this entirely the wrong way?

Thanks,
Michael

-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2012-02-17 20:00 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-21 19:32 How to use git attributes to configure server-side checks? Michael Haggerty
2011-09-21 20:02 ` Jay Soffian
2011-09-21 20:17 ` Junio C Hamano
2011-09-22  8:28   ` Michael Haggerty
2011-09-22 15:41     ` Jay Soffian
2011-09-22 17:13       ` Jeff King
2011-09-22 18:41         ` Jay Soffian
2011-09-22 19:22           ` Junio C Hamano
2011-09-22 20:58           ` Jeff King
2011-09-22 21:04             ` Jeff King
2011-09-23 10:06             ` Michael Haggerty
2011-09-23 19:33               ` Jeff King
2011-09-23 19:40                 ` Junio C Hamano
2011-09-23 19:44                   ` Jeff King
2011-09-24  6:05                 ` Michael Haggerty
2011-09-24  6:15                   ` Jeff King
2011-09-24 11:03                     ` Michael Haggerty
2011-09-26  4:09                       ` Junio C Hamano
2011-09-26  4:28                         ` Michael Haggerty
2011-09-26 11:05                       ` Jeff King
2011-09-26 14:14                         ` Jakub Narebski
2011-09-26 15:11                         ` Michael Haggerty
2011-09-22 17:26     ` Junio C Hamano
2011-09-23  8:35       ` Michael Haggerty
2011-09-23 12:49         ` Stephen Bash
2011-09-23 13:31           ` Michael Haggerty
2011-09-22 22:54     ` Jakub Narebski
2011-09-23 10:38       ` Michael Haggerty
2012-02-17 18:42   ` Michael Haggerty
2012-02-17 19:26     ` Junio C Hamano
2012-02-17 19:59       ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).