2

Ideally I'd like to check the number of lines changed and reject is it's greater than some number. I think I understand the commit-hooks are the right way to go about it but I've struggled to get it working or get the number of lines that the commit changes.

nickponline
  • 25,354
  • 32
  • 99
  • 167
  • 2
    `git diff --stat` will give you this kind of info. You have to decide how to use the counts. This also seems a bit self-defeating as it encourages someone to check in a single "real" change as four separate commits to escape the too-many-changes counter. – torek Sep 17 '13 at 21:18
  • 1
    I have to agree with Torek. Any attempt to restrict something like this is only going to give you an arbitrary rule that will inevitably get in somebody's way and cause bad behavior. – Chris Hayes Sep 18 '13 at 03:25
  • Fair enough. Thanks for the advice. – nickponline Sep 18 '13 at 05:37

1 Answers1

0

Without judging the pertinence of such a hook, note that this kind of restriction is precisely what Virtual References or "VREFs" are for in gitolite (a small authorization layer you can out on top of git)

You can see the list of default VREFs here.
It includes VREF / MAX_NEWBIN_SIZE which does use diff --stat, to prevent committing large binary files (which is actually a good limitation to have enforced in a git repo).

`git diff --stat=999,999 $oldtree $newtree`
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250