Search code examples
gitbranchprefixaccess-controlgitolite

branch name with same prefix will have same access control in gitolite


I wrote gitolite.conf file:

repo Lib
   RW+     = git
   RW  dev = fabby
   RW  develop = fabby
   RW  dev_tele = fabby
  1. fabby can not only make changes on dev, develop and dev_tele,
  2. but can also on branches with dev prefix like dev1, dev_1, devdd or dev_drv...
  3. fabby can not make changes on branches with dev postfix like mdev

so how can I edit gitolite.conf file, and make fabby only have write access control on branch dev, develop and dev_tele?


Solution

  • According to the documentation, this is how "refexes" are treated:

    Note 2: refex matching:

    (refex = optional regex to match the ref being pushed)

    • an empty refex is treated as 'refs/.*'
    • a refex that does not start with 'refs/' is prefixed with 'refs/heads/'
    • finally, a '^' is prefixed
    • the ref being pushed is matched against this resulting refex

    Since "refexes" are regular expressions, and the system automatically prefixes them with ^refs/heads/, this explains your experience. (In regular expressions, the ^ character is an anchor to match the beginning of a line.)

    Adding a $ to the end of your branches should anchor the end as well, giving you the results you want:

    repo Lib
       RW+     = git
       RW  dev$ = fabby
       RW  develop$ = fabby
       RW  dev_tele$ = fabby
    

    This will cause Gitolite to see, e.g., ^refs/heads/dev$, which should match your dev branch name exactly.