I am currently implementing Gerrit as central code review system. In the process of trying to understand the ins and outs of Gerrit, I got stuck at the sentence below. Taken from the Gerrit documentation:
As Gerrit implements the entire SSH and Git server stack within its own process space, Gerrit maintains complete control over how the repository is updated, and what responses are sent to the
git push
client invoked by the end-user, or byrepo upload
. This allows Gerrit to provide magical refs, such asrefs/for/*
for new change submission andrefs/changes/*
for change replacement.
What does the above statement mean, in particular this sentence: “As Gerrit implements the entire SSH and Git server stack within its own process space”? I tried searching for relevant questions, but the closest I have found is Why is git push gerrit HEAD:refs/for/master used instead of git push origin master, but it doesn’t provide an adequate explanation of how implementation of the server stack allows Gerrit to provide magical refs. Apologies if similar questions have indeed been asked before. Thank you!
It's not hard to implement a magical ref even in "normal git". You just have to implement pre-receive
or update
hook in your remote repository that recognizes the target branch of the push and do whatever it wants to with it (e.g. store the push in another branch).
Althought I do not have any implementation details (I suppose it's much more sophisticated), this is the same behavior as Gerrit's. You push to refs/for/master
and it stores it in refs/changes/66/5066/2
branch (for example).
There are some examples.