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

Re: v2.10.0: ls-tree exit status is always 0, this differs from ls(1)

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2016, 20:39 UTC
Message-ID
<xmqqeg4d6l7k.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160921194004.QOizfyGm8%steffen@sdaoden.eu>
Steffen Nurpmeso <steffen@sdaoden.eu> writes:
Show 15 quoted lines
> diff --git a/Documentation/git-ls-tree.txt b/Documentation/git-ls-tree.txt
> index dbc91f9..8ebeced 100644
> --- a/Documentation/git-ls-tree.txt
> +++ b/Documentation/git-ls-tree.txt
> @@ -33,6 +33,10 @@ in the current working directory.  Note that:
>     However, the current working directory can be ignored by passing
>     --full-tree option.
>  
> + - the behaviour is different to that of "/bin/ls" in sofar as non-existing
> +   '<path>' arguments are silently ignored and not reflected in the exit
> +   status code.
> +
>  OPTIONS
>  -------
>  <tree-ish>::

Sorry, but I did not notice that there was an attached patch when I was reading your response for the first time. Risk of using an attachment to e-mail ;-)

I think this issue does not need a separate bullet point. The existing text says:

    Note that:
     - the behaviour is slightly different from that of "/bin/ls" in that the
       '<path>' denotes just a list of patterns to match, e.g. so specifying
       directory name (without `-r`) will behave differently, and order of the
       arguments does not matter.
     - the behaviour is similar to that of "/bin/ls" in that the '<path>' is
       taken as relative to the current working directory.  E.g. when you are
       in a directory 'sub' that has a directory 'dir', you can run 'git
       ls-tree -r HEAD dir' to list the contents of the tree (that is
       'sub/dir' in `HEAD`).  You don't want to give a tree that is not at the
       root level (e.g. `git ls-tree -r HEAD:sub dir`) in this case, as that
       would result in asking for 'sub/sub/dir' in the `HEAD` commit.
       However, the current working directory can be ignored by passing
       --full-tree option.

and what caused your surprise is already covered by the first bullet point, if the reader knows what "patterns to match" means in Git's command line tools; it just needs to be extended to be more meaningful to those who don't, I think.

How about rewriting the first bullet point like so instead:
  - the behaviour is different from that of "/bin/ls" in that the
    '<path>' are actually patterns to match, e.g. so specifying
    directory name (without `-r`) will behave differently, the order
    of the arguments does not matter, and a '<path>' argument that
    does not match any path is not an error (i.e. if there is no
    path that matches any pattern, nothing is shown in the output).
Previous: Steffen NurpmesoNext: Steffen Nurpmeso
Message 4 of 7 in “v2.10.0: ls-tree exit status is always 0, this differs from ls(1)”
  1. Steffen NurpmesoSep 21, 2016
  2. Junio C HamanoSep 21, 2016
  3. Steffen NurpmesoSep 21, 2016
  4. Junio C HamanoSep 21, 2016
  5. Steffen NurpmesoSep 21, 2016
  6. Michael J GruberSep 22, 2016
  7. Steffen NurpmesoSep 22, 2016

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.