Thread (2 messages) flat view 2 messages, 2 authors, 2017-02-26

Re: [PATCH v5 1/1] config: add conditional include

From: Junio C Hamano <hidden>
Date: 2017-02-24 17:54:48

Duy Nguyen [off-list ref] writes:
quoted
quoted
+     if (skip_prefix_mem(cond, cond_len, "gitdir:", &cond, &cond_len))
+             return include_by_gitdir(cond, cond_len, 0);
+     else if (skip_prefix_mem(cond, cond_len, "gitdir/i:", &cond, &cond_len))
+             return include_by_gitdir(cond, cond_len, 1);
This may be OK for now, but it should be trivial to start from a
table with two entries, i.e.

        struct include_cond {
                const char *keyword;
                int (*fn)(const char *, size_t);
        };

and will show a better way to do things to those who follow your
footsteps.
Yeah I don't see a third include coming soon and did not go with that.
Let's way for it and refactor then.
I would have said exactly that in my message if you already had
include_by_gitdir() and include_by_gitdir_i() as separate functions.

But I didn't, because the above code gives an excuse to the person
who adds the third one to be lazy and add another "else if" for
expediency, because making it table-driven would require an extra
work to add two wrapper functions that do not have anything to do
with the third one being added.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help