--------
[verse]
'git ls-tree' [-d] [-r] [-t] [-l] [-z]
- [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] [--format=<format>]
+ [--name-only] [--name-status] [--object-only] [--full-name] [--full-tree] [--abbrev[=<n>]] [--format=<format>]
<tree-ish> [<path>...]
DESCRIPTION
--name-only::
--name-status::
List only filenames (instead of the "long" output), one per line.
+ Cannot be combined with `--object-only`.
+
+--object-only::
+ List only names of the objects, one per line. Cannot be combined
+ with `--name-only` or `--name-status`.
+ This is equivalent to specifying `--format='%(objectname)'`, but
+ for both this option and that exact format the command takes a
+ hand-optimized codepath instead of going through the generic
+ formatting mechanism.
--abbrev[=<n>]::
Instead of showing the full 40-byte hexadecimal object
static int chomp_prefix;
static const char *ls_tree_prefix;
static const char *format;
-
struct show_tree_data {
unsigned mode;
enum object_type type;
MODE_DEFAULT = 0,
MODE_LONG,
MODE_NAME_ONLY,
+ MODE_OBJECT_ONLY,
} cmdmode;
static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
return recurse;
}
+ if (cmdmode == MODE_OBJECT_ONLY) {
+ printf("%s%c", find_unique_abbrev(oid, abbrev), line_termination);
+ return recurse;
+ }
+
if (cmdmode == MODE_NAME_ONLY) {
baselen = base->len;
strbuf_addstr(base, pathname);
.mode = MODE_NAME_ONLY, /* And MODE_NAME_STATUS */
.fmt = "%(path)",
},
+ {
+ .mode = MODE_OBJECT_ONLY,
+ .fmt = "%(objectname)",
+ },
{ 0 },
};
MODE_NAME_ONLY),
OPT_CMDMODE(0, "name-status", &cmdmode, N_("list only filenames"),
MODE_NAME_ONLY),
+ OPT_CMDMODE(0, "object-only", &cmdmode, N_("list only objects"),
+ MODE_OBJECT_ONLY),
OPT_SET_INT(0, "full-name", &chomp_prefix,
N_("use full path names"), 0),
OPT_BOOL(0, "full-tree", &full_tree,
for opts in \
"--name-only --long" \
- "--name-status --long"
+ "--name-status --long" \
+ "--name-only --object-only" \
+ "--name-status --object-only" \
+ "--object-only --long" \
+ "--object-only --format"
do
test_expect_success "usage: incompatible options: $opts" '
test_expect_code 129 git ls-tree $opts $tree
'
done
-
test_done