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

Lars Hjemli hjemli at gmail.com
Sun Mar 6 15:56:31 CET 2011


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


More information about the CGit mailing list