Re: [PATCH v3] config: add conditional include
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jul 13, 2016, 07:21 UTC
- Message-ID
- <vpqa8hmroji.fsf@anie.imag.fr>
- In-Reply-To
- <20160712164216.24072-1-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 6 quoted lines
> +`gitdir`:: > + The environment variable `GIT_DIR` must match the following > + pattern for files to be included. The pattern can contain > + standard globbing wildcards and two additional ones, `**/` and > + `/**`, that can match multiple path components. Please refer > + to linkgit:gitignore[5] for details. For convenience:
It's unclear to me whether the whole content of GIT_DIR must match, or whether the pattern should be included (or a be prefix) of $GIT_DIR. From this text, I read it as "the whole content", but ...
Show 7 quoted lines
> + ; include for all repositories inside /path/to/group > + [include "gitdir:/path/to/group/"] > + path = /path/to/foo.inc > + > + ; include for all repositories inside $HOME/to/group > + [include "gitdir:~/to/group/"] > + path = /path/to/foo.inc
... here it seems it only has to be a prefix.
Show 11 quoted lines
> +static int prepare_include_condition_pattern(struct strbuf *pat)
> +{
> + int prefix = 0;
> +
> + /* TODO: maybe support ~user/ too */
> + if (pat->buf[0] == '~' && is_dir_sep(pat->buf[1])) {
> + struct strbuf path = STRBUF_INIT;
> + const char *home = getenv("HOME");
> +
> + if (!home)
> + return error(_("$HOME is not defined"));expand_user_path in path.c seems to do the same as you're doing (but does deal with ~user). Any reason not to use it?
-- Matthieu Moy http://www-verimag.imag.fr/~moy/