| 336 | }; |
| 337 | |
| 338 | int cmd_ls_tree(int argc, |
| 339 | const char **argv, |
| 340 | const char *prefix, |
| 341 | struct repository *repo UNUSED) |
| 342 | { |
| 343 | struct object_id oid; |
| 344 | struct tree *tree; |
| 345 | int i, full_tree = 0; |
| 346 | int full_name = !prefix || !*prefix; |
| 347 | read_tree_fn_t fn = NULL; |
| 348 | enum ls_tree_cmdmode cmdmode = MODE_DEFAULT; |
| 349 | int null_termination = 0; |
| 350 | struct ls_tree_options options = { 0 }; |
| 351 | const struct option ls_tree_options[] = { |
| 352 | OPT_BIT('d', NULL, &options.ls_options, N_("only show trees"), |
| 353 | LS_TREE_ONLY), |
| 354 | OPT_BIT('r', NULL, &options.ls_options, N_("recurse into subtrees"), |
| 355 | LS_RECURSIVE), |
| 356 | OPT_BIT('t', NULL, &options.ls_options, N_("show trees when recursing"), |
| 357 | LS_SHOW_TREES), |
| 358 | OPT_BOOL('z', NULL, &null_termination, |
| 359 | N_("terminate entries with NUL byte")), |
| 360 | OPT_CMDMODE('l', "long", &cmdmode, N_("include object size"), |
| 361 | MODE_LONG), |
| 362 | OPT_CMDMODE(0, "name-only", &cmdmode, N_("list only filenames"), |
| 363 | MODE_NAME_ONLY), |
| 364 | OPT_CMDMODE(0, "name-status", &cmdmode, N_("list only filenames"), |
| 365 | MODE_NAME_STATUS), |
| 366 | OPT_CMDMODE(0, "object-only", &cmdmode, N_("list only objects"), |
| 367 | MODE_OBJECT_ONLY), |
| 368 | OPT_BOOL(0, "full-name", &full_name, N_("use full path names")), |
| 369 | OPT_BOOL(0, "full-tree", &full_tree, |
| 370 | N_("list entire tree; not just current directory " |
| 371 | "(implies --full-name)")), |
| 372 | OPT_STRING_F(0, "format", &options.format, N_("format"), |
| 373 | N_("format to use for the output"), |
| 374 | PARSE_OPT_NONEG), |
| 375 | OPT__ABBREV(&options.abbrev), |
| 376 | OPT_END() |
| 377 | }; |
| 378 | struct ls_tree_cmdmode_to_fmt *m2f = ls_tree_cmdmode_format; |
| 379 | int ret; |
| 380 | |
| 381 | repo_config(the_repository, git_default_config, NULL); |
| 382 | |
| 383 | argc = parse_options(argc, argv, prefix, ls_tree_options, |
| 384 | ls_tree_usage, 0); |
| 385 | options.null_termination = null_termination; |
| 386 | |
| 387 | if (full_tree) |
| 388 | prefix = NULL; |
| 389 | options.prefix = full_name ? NULL : prefix; |
| 390 | |
| 391 | /* |
| 392 | * We wanted to detect conflicts between --name-only and |
| 393 | * --name-status, but once we're done with that subsequent |
| 394 | * code should only need to check the primary name. |
| 395 | */ |
no test coverage detected