git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 13, 2015, 22:02 UTC
Message-ID
<xmqqy4o1lbbx.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAG4vEKP760_sq1fsJD_1jjz0_G+T8NosSXDqx0bvQy4tPVz5JQ@mail.gmail.com>
Daniel Finnie <dan@danfinnie.com> 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.

Previous: Daniel Finnie
Message 5 of 5 in “git ls-files -X option is relative to repo root”
  1. Daniel FinnieFeb 13, 2015
  2. Junio C HamanoFeb 13, 2015
  3. Junio C HamanoFeb 13, 2015
  4. Daniel FinnieFeb 13, 2015
  5. Junio C HamanoFeb 13, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.