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