rev-list: support delimiting objects with NUL bytes
When walking objects, git-rev-list(1) prints each object entry on a
separate line. Some options, such as `--objects`, may print additional
information about tree and blob object on the same line in the form:
$ git rev-list --objects <rev>
<tree/blob oid> SP [<path>] LF
Note that in this form the SP is appended regardless of whether the tree
or blob object has path information available. Paths containing a
newline are also truncated at the newline.
Introduce the `-z` option for git-rev-list(1) which reformats the output
to use NUL-delimiters between objects and associated info in the
following form:
$ git rev-list -z --objects <rev>
<oid> NUL [path=<path> NUL]
In this form, the start of each record is signaled by an OID entry that
is all hexidecimal and does not contain any '='. Additional path info
from `--objects` is appended to the record as a token/value pair
`path=<path>` as-is without any truncation.
For now, the `--objects` flag is the only options that can be used in
combination with `-z`. In a subsequent commit, NUL-delimited support for
other options is added. Other options that do not make sense when used
in combination with `-z` are rejected.
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
c9907a1916
commit
c3d59c2e70
@@ -361,6 +361,27 @@ ifdef::git-rev-list[]
|
||||
--progress=<header>::
|
||||
Show progress reports on stderr as objects are considered. The
|
||||
`<header>` text will be printed with each progress update.
|
||||
|
||||
-z::
|
||||
Instead of being newline-delimited, each outputted object and its
|
||||
accompanying metadata is delimited using NUL bytes. Output is printed
|
||||
in the following form:
|
||||
+
|
||||
-----------------------------------------------------------------------
|
||||
<OID> NUL [<token>=<value> NUL]...
|
||||
-----------------------------------------------------------------------
|
||||
+
|
||||
Additional object metadata, such as object paths, is printed using the
|
||||
`<token>=<value>` form. Token values are printed as-is without any
|
||||
encoding/truncation. An OID entry never contains a '=' character and thus
|
||||
is used to signal the start of a new object record. Examples:
|
||||
+
|
||||
-----------------------------------------------------------------------
|
||||
<OID> NUL
|
||||
<OID> NUL path=<path> NUL
|
||||
-----------------------------------------------------------------------
|
||||
+
|
||||
This mode is only compatible with the `--objects` output option.
|
||||
endif::git-rev-list[]
|
||||
|
||||
History Simplification
|
||||
|
||||
Reference in New Issue
Block a user