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

Re: [PATCH] ls-tree: default <tree-ish> to HEAD

From
LALinus Arver <linusa@google.com>
Date
Aug 11, 2023, 18:22 UTC
Message-ID
<owly5y5lfnh1.fsf@fine.c.googlers.com>
In-Reply-To
<xmqqmsz2hl9m.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> "Ryan Williams via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> From: Ryan Williams <ryan@runsascoded.com>
>>
>> When no positional arguments are passed to `git ls-tree`, it currently
>> prints "usage" info to stderr and exits with code 129. A more intuitive
>> default would be to operate on the `HEAD` commit's tree (similarly to
>> `git show`, `git log`, and possibly others).
>
> As 'ls-tree' is a plumbing command meant for script writers, it was
> designed to require the users to be more explicit.  So, similarity
> to "show" and other Porcelain commands do not weigh much here.  Same
> for "rev-list" that does not fall back to HEAD.

Indeed, we already partition these commands into these porcelain vs plumbing categories in "man git". There, we say for plumbing

    The interface (input, output, set of options and the semantics) to
    these low-level commands are meant to be a lot more stable than
    Porcelain level commands, because these commands are primarily for
    scripted use. The interface to Porcelain commands on the other hand
    are subject to change in order to improve the end user experience.
Show 11 quoted lines
> This was a very deliberate design decision to help use of the
> plumbing commands.  A buggy script may say
>
>     TREE=$(some command to find a tree object)
>     git ls-tree $TREE
>
> without making sure something sensible is in $TREE (and not even
> quoting it like "$TREE"), and if ls-tree defaulted to something, the
> script will silently produce a wrong result, instead of failing,
> robbing the script writer a chance to notice a bug in their code to
> come up with the TREE object name.

I think this illustrative example (at least the general language of it, if not the entire example) could be added to the referenced section of our docs (I'd be happy to add this).

On a related note, does it make sense to explicitly call out the plumbing vs porcelain distinction in the individual manpages for each command? For example, I grepped for "plumb" in the docs for "git-ls-tree" but came up empty. We could add just a simple "Part of Git plumbing" to a slightly longer

    Part of Git plumbing. Plumbing commands are more stable and are
    designed to work reliably in scripting environments ...
and similarly for all the porecelain commands.
Previous: Taylor Blau
Message 4 of 4 in “ls-tree: default <tree-ish> to HEAD”
  1. ls-tree: default <tree-ish> to HEADRyan Williams via GitGitGadget, Aug 7, 2023
  2. Junio C HamanoAug 7, 2023
  3. Taylor BlauAug 11, 2023
  4. Linus ArverAug 11, 2023

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.