2

I have a GIT repository foo with 2 branches: branch1 and branch2. I want to set up a gitolite rule that denies pushing modifications for this file only for branch1 for bar user. This is what I've tried so far:

repo foo
    - branch1/this = bar

repo foo
    - branch1/NAME/this = bar

repo foo
    - branch1 /NAME/this = bar

I don't even know if this is possible with gitolite.

Any help very much welcome. Thanks in advance.


EDIT: I tried this 2 configurations as suggested. The following:

-  branch1 VREF/NAME/this = bar
RW branch2 VREF/NAME/this = @all

rejects both branches

remote: FATAL: W VREF/NAME/this testing bar DENIED by VREF/NAME/this
remote: error: hook declined to update refs/heads/branch2
remote: FATAL: W VREF/NAME/this testing bar DENIED by VREF/NAME/this
remote: error: hook declined to update refs/heads/branch1
To debian:testing.git
 ! [remote rejected] branch2 -> branch2 (hook declined)
 ! [remote rejected] branch1 -> branch1 (hook declined)
error: failed to push some refs to 'debian:testing.git'

While the following

RW branch2 VREF/NAME/this = @all
-  branch1 VREF/NAME/this = bar

allows both branches to be pushed

To debian:testing.git
   f6bc01d..09b63ab  branch2 -> branch2
   7a868cf..09bcb63  branch1 -> branch1

Using the same branch (branch1)

RW branch1 VREF/NAME/this = @all
-  branch1 VREF/NAME/this = bar

To debian:testing.git
   9c50fc4..02f350d  branch1 -> branch1

-  branch1 VREF/NAME/this = bar
RW branch1 VREF/NAME/this = @all

remote: FATAL: W VREF/NAME/this testing bar DENIED by VREF/NAME/this
remote: error: hook declined to update refs/heads/branch1
To debian:testing.git
 ! [remote rejected] branch1 -> branch1 (hook declined)
Community
  • 1
  • 1
m0skit0
  • 25,268
  • 11
  • 79
  • 127

1 Answers1

1

It should be:

repo foo
    - branch1 VREF/NAME/this = bar

I used a similar VREF-based rule for "gitolite disallow access for directory on master branch but not on user branch".
'VREF/...' is the important part ('NAME' alone won't work, 'VREF/NAME' will)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the fast answer. I just saw your answer [here](http://stackoverflow.com/questions/11899405/gitolite-disallow-access-for-directory-on-master-branch-but-not-on-user-branch) but this doesn't seem to work for me. – m0skit0 Nov 15 '13 at 13:25
  • `remote: FATAL: W VREF/NAME/this foo bar DENIED by VREF/NAME/this remote: error: hook declined to update refs/heads/branch2` – m0skit0 Nov 15 '13 at 13:26
  • @m0skit0 Try to add a success rule after the deny rule: `RW branch2 VREF/NAME/this = @all` – VonC Nov 15 '13 at 13:28
  • @m0skit0 if that doesn't work, try the same success rule *before* the deny rule. Check also that your '`branch2`' local branch is pushed to a '`branch2`' upstream branch (`git branch -vvv`) – VonC Nov 15 '13 at 13:29
  • Yes, it's pushed to remote: `branch2 f6bc01d [origin/branch2] Testing`. I added `RW+ branch1 VREF/NAME/this = bar` before the deny. Still the same. – m0skit0 Nov 15 '13 at 15:21
  • @m0skit0 why not add the success rule I mentioned earlier? (success rule on branch2) – VonC Nov 15 '13 at 15:22
  • Sorry I misunderstood. I added `RW branch2 VREF/NAME/this = @all` and kept previous deny rule. I can push the file to both branches now. The rule looks like applying to all branches, no matter which one I specify. – m0skit0 Nov 15 '13 at 15:30
  • @m0skit0 and what if you reverse the order between the two rules? – VonC Nov 15 '13 at 15:31
  • Rejected in both branches. – m0skit0 Nov 15 '13 at 15:34
  • @m0skit0 can you edit your question with those two configs, and their result? – VonC Nov 15 '13 at 15:35
  • @m0skit0 Could you try a success rule **for the same branch**? `RW branch1 VREF/NAME/this = @all` (before or after the deny rule for the same branch `branch1`) – VonC Nov 15 '13 at 15:57
  • Updated the question with it – m0skit0 Nov 15 '13 at 16:11