From f5f76190a833bf105483a7da9b4b61ab03e373ba Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Thu, 7 Jan 2010 23:58:08 +0530 Subject: [PATCH 1/2] Add quiet option to git-ls-files --quiet option suppresses error output in --error-unmatch mode. Modify documentation to reflect changes. Signed-off-by: Ramkumar Ramachandra --- Documentation/git-ls-files.txt | 6 ++++++ builtin-ls-files.c | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 625723e..0a1f94e 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -82,6 +82,12 @@ OPTIONS Skips files matching pattern. Note that pattern is a shell wildcard pattern. +--q:: +--quiet:: + Only meaningful in --error-unmatch mode. Do not output an + error message if does not appear in the index. Instead + exit with non-zero status silently. + -X :: --exclude-from=:: exclude patterns are read from ; 1 per line. diff --git a/builtin-ls-files.c b/builtin-ls-files.c index c9a03e5..40560da 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -421,12 +421,13 @@ static int option_parse_exclude_standard(const struct option *opt, int cmd_ls_files(int argc, const char **argv, const char *prefix) { - int require_work_tree = 0, show_tag = 0; + int require_work_tree = 0, show_tag = 0, quiet = 0; struct dir_struct dir; struct option builtin_ls_files_options[] = { { OPTION_CALLBACK, 'z', NULL, NULL, NULL, "paths are separated with NUL character", PARSE_OPT_NOARG, option_parse_z }, + OPT__QUIET(&quiet), OPT_BOOLEAN('t', NULL, &show_tag, "identify the file status with tags"), OPT_BOOLEAN('v', NULL, &show_valid_bit, @@ -547,10 +548,11 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix) if (ps_matched) { int bad; - bad = report_path_error(ps_matched, pathspec, prefix_offset); - if (bad) - fprintf(stderr, "Did you forget to 'git add'?\n"); - + if (!quiet) { + bad = report_path_error(ps_matched, pathspec, prefix_offset); + if (bad) + fprintf(stderr, "Did you forget to 'git add'?\n"); + } return bad ? 1 : 0; } -- 1.6.5