git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jeff King <peff@peff.net>
Cc: "Sebastian Schuberth" <sschuberth@gmail.com>,
	"Raphael Stolt" <raphael.stolt@gmail.com>,
	"Git Mailing List" <git@vger.kernel.org>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: Possible bug in includeIf / conditional includes
Date: Thu, 11 May 2017 09:19:50 +0200	[thread overview]
Message-ID: <CACBZZX4ob04fG9ZZtvbdcqrYOKijoZohVdUCNyeayHZtdtNyxQ@mail.gmail.com> (raw)
In-Reply-To: <20170511062924.6euaynsbyocjcw3q@sigill.intra.peff.net>

On Thu, May 11, 2017 at 8:29 AM, Jeff King <peff@peff.net> wrote:
> On Thu, May 11, 2017 at 02:26:16AM -0400, Jeff King wrote:
>
>> > So whether this is a bug in the code or not it seems to definitely be
>> > a doc bug, whatever it does with relative files should be in the docs.
>>
>> The includeIf variables should behave exactly as the documentation you
>> quoted above. The conditional impacts whether we respect the keys in
>> that section, but not the meaning of the keys.
>>
>> I thought that was clear, but as somebody who was involved in the
>> development of both the original and the conditional includes, my
>> opinion probably doesn't count. I wouldn't mind a patch to make that
>> more explicit in the documentation.
>
> I figured I'd just do this while we're thinking about it, since it
> should be trivial. But it's actually there already:
>
>   You can include a config file from another conditionally by setting a
>   `includeIf.<condition>.path` variable to the name of the file to be
>   included. The variable's value is treated the same way as
>   `include.path`.
>
> I'm open to suggestions to make that more obvious, though.

Yes I started writing up a patch to make this better but once I
started doing that it wasn't really any better.

FWIW the reasons I didn't find this while quickly skimming the thing:

1. It says "The included file is expanded immediately, as if its
contents had been found at the location of the include directive.". At
first I thought this referred to glob expansion, not
s/expanded/interpolated/, the example section uses "expand" in the
context of pathnames, which caused the confusion.

Maybe this would make that less confusing by saying the same thing
without using the same phrasing to mean completely different things:

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 475e874d51..49855353c7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -167,8 +167,8 @@ Example

        [include]
                path = /path/to/foo.inc ; include by absolute path
-               path = foo ; expand "foo" relative to the current file
-               path = ~/foo ; expand "foo" in your `$HOME` directory
+               path = foo ; find & include "foo" relative to the current file
+               path = ~/foo ; find & include "foo" in your `$HOME` directory

        ; include if $GIT_DIR is /path/to/foo/.git
        [includeIf "gitdir:/path/to/foo/.git"]

2. There is no example of such expansion for IncludeIf, prose should
always be backed up by examples for the lazy reader when possible:

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 475e874d51..fc4b87cd7e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -173,6 +173,8 @@ Example
        ; include if $GIT_DIR is /path/to/foo/.git
        [includeIf "gitdir:/path/to/foo/.git"]
                path = /path/to/foo.inc
+               path = foo ; find & include "foo" relative to the current file
+               path = ~/foo ; find & include "foo" in your `$HOME` directory

        ; include for all repositories inside /path/to/group
        [includeIf "gitdir:/path/to/group/"]

3. When I read reference docs I almost never start at the beginning &
read it all the way through, in this case I thought I could help
someone out by maybe answering a question on the ML quickly, so I went
to the examples section, found no example (fixed above), then searched
for "relative" or "path" in my pager and the only results were for the
"Includes" section that has a paragraph that's only talking about
"include.path".

Of course we say "same rules apply" below, but I managed not to spot
that. Maybe this:

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 475e874d51..b35d9a7b80 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -95,8 +95,11 @@ Conditional includes

 You can include a config file from another conditionally by setting a
 `includeIf.<condition>.path` variable to the name of the file to be
-included. The variable's value is treated the same way as
-`include.path`. `includeIf.<condition>.path` can be given multiple times.
+included.
+
+If variable's value is a relative path it's treated the same way as
+`include.path`. `includeIf.<condition>.path` can also be given
+multiple times.

 The condition starts with a keyword followed by a colon and some data
 whose format and meaning depends on the keyword. Supported keywords

Would make it easier to find. Here we say the same thing but include
both "path" & "relative".

  reply	other threads:[~2017-05-11  7:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-10 17:00 Possible bug in includeIf / conditional includes raphael.stolt
2017-05-10 18:58 ` Sebastian Schuberth
2017-05-10 19:48   ` Ævar Arnfjörð Bjarmason
2017-05-10 21:21     ` Raphael Stolt
2017-05-10 21:37       ` Raphael Stolt
2017-05-11  6:26     ` Jeff King
2017-05-11  6:29       ` Jeff King
2017-05-11  7:19         ` Ævar Arnfjörð Bjarmason [this message]
2017-05-11  7:42           ` Jeff King
2017-05-11  7:49             ` Ævar Arnfjörð Bjarmason
2017-05-11  7:54               ` Jeff King
2017-05-11  9:09                 ` [PATCH 0/4] doc improvements for config includes Jeff King
2017-05-11  9:10                   ` [PATCH 1/4] docs/config: clarify include/includeIf relationship Jeff King
2017-05-11 16:47                     ` Ramsay Jones
2017-05-12  9:28                       ` Jeff King
2017-05-11  9:11                   ` [PATCH 2/4] docs/config: give a relative includeIf example Jeff King
2017-05-11  9:13                   ` [PATCH 3/4] docs/config: avoid the term "expand" for includes Jeff King
2017-05-11  9:14                   ` [PATCH 4/4] docs/config: consistify include.path examples Jeff King
2017-05-11  9:41                     ` Junio C Hamano
2017-05-11  9:29                   ` [PATCH 0/4] doc improvements for config includes Ævar Arnfjörð Bjarmason
2017-05-11  7:54             ` Possible bug in includeIf / conditional includes Junio C Hamano
2017-05-11  7:56               ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACBZZX4ob04fG9ZZtvbdcqrYOKijoZohVdUCNyeayHZtdtNyxQ@mail.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=raphael.stolt@gmail.com \
    --cc=sschuberth@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).