summaryrefslogtreecommitdiff
path: root/Documentation/git-ls-files.txt
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-08-03 20:36:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-08-03 20:36:08 (GMT)
commit8e56affcb52e2cf344437a892356a419985ea4ba (patch)
tree87cb75f189f886671d4b2d0e66f912ca9912ece7 /Documentation/git-ls-files.txt
parent37e4bdd5ee5d6a7e09feaf5857299aac8fd56aeb (diff)
parentce74de931d7aea9746e37632534eacc63b0c1a90 (diff)
downloadgit-8e56affcb52e2cf344437a892356a419985ea4ba.zip
git-8e56affcb52e2cf344437a892356a419985ea4ba.tar.gz
git-8e56affcb52e2cf344437a892356a419985ea4ba.tar.bz2
Merge branch 'zh/ls-files-format'
"git ls-files" learns the "--format" option to tweak its output. * zh/ls-files-format: ls-files: introduce "--format" option
Diffstat (limited to 'Documentation/git-ls-files.txt')
-rw-r--r--Documentation/git-ls-files.txt39
1 files changed, 38 insertions, 1 deletions
diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt
index 0dabf3f..d798641 100644
--- a/Documentation/git-ls-files.txt
+++ b/Documentation/git-ls-files.txt
@@ -20,7 +20,7 @@ SYNOPSIS
[--exclude-standard]
[--error-unmatch] [--with-tree=<tree-ish>]
[--full-name] [--recurse-submodules]
- [--abbrev[=<n>]] [--] [<file>...]
+ [--abbrev[=<n>]] [--format=<format>] [--] [<file>...]
DESCRIPTION
-----------
@@ -192,6 +192,13 @@ followed by the ("attr/<eolattr>").
to the contained files. Sparse directories will be shown with a
trailing slash, such as "x/" for a sparse directory "x".
+--format=<format>::
+ A string that interpolates `%(fieldname)` from the result being shown.
+ It also interpolates `%%` to `%`, and `%xx` where `xx` are hex digits
+ interpolates to character with hex code `xx`; for example `%00`
+ interpolates to `\0` (NUL), `%09` to `\t` (TAB) and %0a to `\n` (LF).
+ --format cannot be combined with `-s`, `-o`, `-k`, `-t`, `--resolve-undo`
+ and `--eol`.
\--::
Do not interpret any more arguments as options.
@@ -223,6 +230,36 @@ quoted as explained for the configuration variable `core.quotePath`
(see linkgit:git-config[1]). Using `-z` the filename is output
verbatim and the line is terminated by a NUL byte.
+It is possible to print in a custom format by using the `--format`
+option, which is able to interpolate different fields using
+a `%(fieldname)` notation. For example, if you only care about the
+"objectname" and "path" fields, you can execute with a specific
+"--format" like
+
+ git ls-files --format='%(objectname) %(path)'
+
+FIELD NAMES
+-----------
+The way each path is shown can be customized by using the
+`--format=<format>` option, where the %(fieldname) in the
+<format> string for various aspects of the index entry are
+interpolated. The following "fieldname" are understood:
+
+objectmode::
+ The mode of the file which is recorded in the index.
+objectname::
+ The name of the file which is recorded in the index.
+stage::
+ The stage of the file which is recorded in the index.
+eolinfo:index::
+eolinfo:worktree::
+ The <eolinfo> (see the description of the `--eol` option) of
+ the contents in the index or in the worktree for the path.
+eolattr::
+ The <eolattr> (see the description of the `--eol` option)
+ that applies to the path.
+path::
+ The pathname of the file which is recorded in the index.
EXCLUDE PATTERNS
----------------