This is a note on "macros" versus "templates".
Before reading this mail, please skim through at a high level,
since we make references to those examples:
-
http://gitolite.com/gitolite/templates/index.html
(documentation on templates)
-
https://groups.google.com/forum/#!msg/gitolite/c_nZswh28WE/zwieuZHDAQAJ
(a good example of macro use that came up on the list
recently)
Also, a quick terminology note: "compile time" means "when you
push to the gitolite-admin repo", and "run time" means "when
actually checking a user's access to a repo".
----------------------------------------------------------------------
The main differences are these:
* A macro is text replacement **in the conf file**. As such,
it does its thing only at compile time. It has no role at
run time, in fact it does not *exist* at run time.
A template is also, **conceptually**, a text replacement
operation, but most of the "replacement" is at run time.
(So of course templates *do* exist at runtime -- they just
look like rules for a repo group, if you look in the
compiled conf file.)
* A macro definition is simply text, and using a macro simply
replaces placeholders in the definition (`%1`, `%2`, etc),
wherever they occur in the macro definition, with the
corresponding word or string from the macro call arguments.
Templates have a defined syntax. There are no placeholders,
per se. Or rather, the placeholders are implicit in the
syntax.
* A macro does not give you anything you could not do without
using the feature. Its main benefit is help reduce
laborious repetition and potential copy-paste errors.
A template helps you make significant permissions changes
without having to recompile the conf file.
(It's only for convenience that we recommend keeping the
template-data in gitolite.conf, so it seems like you need to
recompile. See the "bypassing gitolite.conf [...]" section
in the template doc for alternatives.)
* Macros work alone. Each macro stands by itself; you can't,
for example, invoke two macros on the same line.
Templates are designed to be combined. A repo typically
"uses" more than one template, and all those templates'
rules apply to the repo.
* Macros can be written in any order.
Template **definitions** must be written carefully. Whan a
repo uses more than one template, the order in which those
templates are **defined** is the order in which those rules
are (conceptually) inserted. This becomes important because
of deny rules.
(See the template page. If the `@is_suspended` template was
defined *after* any of the others, it would not work!)
Hope that helps.
sitaram