Subject: Re: git ls-files -X option is relative to repo root

From: Junio C Hamano <[email-masked]>
Date: Fri, 13 Feb 2015 14:02:10 -0800

Daniel Finnie <[email-masked]> writes:

> Do you have any comments on why the path in --exclude-from=<path> is
> relative to the project root?

Not really.

Because ls-files was designed to be used by Porcelain scripts, and
because the first thing Porcelain scripts are expected to do is to
learn the prefix and then cd to the root level of the working tree
before doing anything else, <path> that is relative to the root
level of the working tree ends up to be not so unnatural thing to be
used with --exclude-from=<path> (e.g. ".git/info/exclude").

If it were relative to whatever subdirectory the invoker of the
Porcelain script happened to be, Porcelain would have to do a lot
more (e.g. in "cd x/y && myPorcelain ../../.git/info/exclude", the
myPorcelain script would first have to learn the prefix is x/y, go
up two levels, and then strip two ../ from ../../.git/info/exclude
to turn it into .git/info/exclude when it runs ls-files).

So that is a convenience explanation in retrospect, but "Why" is
often a futile question to ask when talking about evolution, in
which whatever works gets picked.