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

Re: [PATCH v3] fast-import: add 'ls' command

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 11, 2011, 22:59 UTC
Message-ID
<20110211225904.GA22391@elie>
In-Reply-To
<AANLkTimReMYu7QYZEuunmH6WqUz=C0nOnAZHzB6cddXt@mail.gmail.com>
Sverre Rabbelier wrote:
> On Fri, Feb 11, 2011 at 23:43, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 7 quoted lines
>> Introduce an "ls" command to read directory entries from the active
>> commit or a named commit.  This allows printing a blob from the active
>> commit or copying a blob or tree from a previous commit for use in the
>> current one.
>
> Useful addition I think. What happens if you ask it for a path that is
> not a directory?
Hmm, the documentation was not at all clear, then.  Good catch.

The answer is that it always prints a single dirent, whether the path supplied names a file or a directory.

	FE> ls :1 Documentation
	gfi> 040000 tree 9e6c2b599341d28a2a375f8207507e0a2a627fe9	Documentation
	FE> ls :1 git.c
	gfi> 100644 blob 23610aa0366ebe36e65e78fb8c5fba3f2d0b8f77	git.c
	FE> ls :1 thisfiledoesnotexist
	gfi> 040000 tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904	thisfiledoesnotexist
	FE> ls :1 RelNotes
	gfi> 120000 blob b942e499449d97aeb50c73ca2bdc1c6e6d528743	RelNotes
	FE> ls 9e6c2b599341d28a2a375f8207507e0a2a627fe9 git-fast-import.txt
	gfi> 100644 blob 4f92954396e3f0f97e75b6838a5635b583708870	git-fast-import.txt
	FE> cat-blob b942e499449d97aeb50c73ca2bdc1c6e6d528743
	gfi> b942e499449d97aeb50c73ca2bdc1c6e6d528743 blob 32
	gfi> Documentation/RelNotes/1.7.4.txt
Maybe this patch (for squashing) would help.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index 4f92954..495e01f 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -336,9 +336,9 @@ and control the current import process.  More detailed discussion
 	`stdout` if unspecified.
 
 `ls`::
-	Causes fast-import to print a directory entry in 'ls-tree'
-	format to the file descriptor set with `--cat-blob-fd` or
-	`stdout` if unspecified.
+	Causes fast-import to print a line describing a directory
+	entry in 'ls-tree' format to the file descriptor set with
+	`--cat-blob-fd` or `stdout` if unspecified.
 
 `feature`::
 	Require that fast-import supports the specified feature, or
@@ -927,10 +927,11 @@ middle of a commit but not in the middle of a `data` command.
 
 `ls`
 ~~~~
-Prints a directory entry to a file descriptor previously arranged with
-the `--cat-blob-fd` argument.  This allows printing a blob from the
-active commit (with `cat-blob`) or copying a blob or tree from a
-previous commit for use in the current one (with `filemodify`).
+Prints information about the object at a path to a file descriptor
+previously arranged with the `--cat-blob-fd` argument.  This allows
+printing a blob from the active commit (with `cat-blob`) or copying a
+blob or tree from a previous commit for use in the current one (with
+`filemodify`).
 
 The `ls` command can be used anywhere in the stream that comments are
 accepted, including the middle of a commit.
@@ -957,7 +958,7 @@ Reading from a named tree::
 
 See `filemodify` above for a detailed description of `<path>`.
 
-Output uses the same format as `git ls-tree <tree> -- <path>`:
+Output uses the same format as `git ls-tree <tree> {litdd} <path>`:
 
 ====
 	<mode> SP ('blob' | 'tree' | 'commit') SP <dataref> HT <path> LF
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 3 of 7 in “fast-import: add 'ls' command”
  1. fast-import: add 'ls' commandJonathan Nieder, Feb 11, 2011
  2. Sverre RabbelierFeb 11, 2011
  3. Jonathan NiederFeb 11, 2011
  4. Sverre RabbelierFeb 11, 2011
  5. Junio C HamanoFeb 12, 2011
  6. Jonathan NiederFeb 12, 2011
  7. Jonathan NiederFeb 12, 2011

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.