[CGit] [PATCH v2 5/6] cgit_open_filter: hand down repo configuration to script

Ferry Huberts mailings at hupie.com
Sun Mar 6 22:27:41 CET 2011


On 03/06/2011 03:56 PM, Lars Hjemli wrote:
> On Fri, Mar 4, 2011 at 01:31, Ferry Huberts <mailings at hupie.com> wrote:
>> +       while (var_index < ENV_VARS) {
>> +               chars_printed = 0;
>> +               switch (var_index) {
>> +               case 0:
>> +                       chars_printed = snprintf(buffer_var_index, buffer_space,
>> +                                       "CGIT_REPO_URL=%s", (repo->url) ? repo->url : "");
>> +                       break;
>> +
>> +               case 1:
>> +                       chars_printed = snprintf(buffer_var_index, buffer_space,
>> +                                       "CGIT_REPO_NAME=%s", (repo->name) ? repo->name : "");
>> +                       break;
>> +
>> +               case 2:
>> +                       chars_printed = snprintf(buffer_var_index, buffer_space,
>> +                                       "CGIT_REPO_PATH=%s", (repo->path) ? repo->path : "");
>> +                       break;
> ...
> 
> Hmm, this looks like something that should be data-driven. Why not
> declare an array of variable names + offset into the repo struct?
> 
> --
> larsh

why bother?
it's not important how the variables are ordered or transferred into the
environment of the filter, as long as it's done, right?
this keeps it simple :-)




-- 
Ferry Huberts




More information about the CGit mailing list