summaryrefslogtreecommitdiffstats
path: root/src/syntactic-sugar/continuation-lines
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/syntactic-sugar/continuation-lines36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/syntactic-sugar/continuation-lines b/src/syntactic-sugar/continuation-lines
new file mode 100644
index 0000000..d63475f
--- /dev/null
+++ b/src/syntactic-sugar/continuation-lines
@@ -0,0 +1,36 @@
+# vim: syn=perl:
+
+# "sugar script" (syntactic sugar helper) for gitolite3
+
+# Enabling this script in the rc file allows you to use back-slash escaped
+# continuation lines, like in C or shell etc.
+
+# This script also serves as an example "sugar script" if you want to write
+# your own (and maybe send them to me). A "sugar script" in gitolite will be
+# executed via a perl 'do' and is expected to contain one function called
+# 'sugar_script'. This function should take a listref and return a listref.
+# Each item in the list is one line. There are NO newlines; g3 kills them off
+# fairly early in the process.
+
+# If you're not familiar with perl please do not try this. Ask me to write
+# you a sugar script instead.
+
+sub sugar_script {
+ my $lines = shift;
+
+ my @out = ();
+ my $keep = '';
+ for my $l (@$lines) {
+ # skip RULE_INFO lines if in continuation mode
+ next if $keep and $l =~ /^ *#/;
+ if ( $l =~ s/\\$// ) {
+ $keep .= $l;
+ } else {
+ $l = $keep . $l if $keep;
+ $keep = '';
+ push @out, $l;
+ }
+ }
+
+ return \@out;
+}