git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ryan Williams via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Ryan Williams <ryan@runsascoded.com>
Subject: Re: [PATCH] ls-tree: default <tree-ish> to HEAD
Date: Mon, 07 Aug 2023 09:25:57 -0700	[thread overview]
Message-ID: <xmqqmsz2hl9m.fsf@gitster.g> (raw)
In-Reply-To: <pull.1566.git.1691412557518.gitgitgadget@gmail.com> (Ryan Williams via GitGitGadget's message of "Mon, 07 Aug 2023 12:49:17 +0000")

"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.

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.

So, I dunno.

Thanks.

  reply	other threads:[~2023-08-07 16:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 12:49 [PATCH] ls-tree: default <tree-ish> to HEAD Ryan Williams via GitGitGadget
2023-08-07 16:25 ` Junio C Hamano [this message]
2023-08-11 17:35   ` Taylor Blau
2023-08-11 18:22   ` Linus Arver

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

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

  git send-email \
    --in-reply-to=xmqqmsz2hl9m.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=ryan@runsascoded.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.
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 NNTP newsgroup(s).