diff -uNr patchutils_git/doc/patchutils.xml patchutils_new/doc/patchutils.xml --- patchutils_git/doc/patchutils.xml 2008-06-18 12:56:53.000000000 +0400 +++ patchutils_new/doc/patchutils.xml 2008-06-19 15:29:00.000000000 +0400 @@ -549,6 +549,8 @@ -X FILE --verbose -v + --clean + -c -z -# RANGE @@ -761,6 +763,15 @@ + , + + Always remove all non-diff lines + from the output. Even when excluding + a filename pattern. + + + + Decompress files with extensions .gz and .bz2. diff -uNr patchutils_git/src/filterdiff.c patchutils_new/src/filterdiff.c --- patchutils_git/src/filterdiff.c 2008-06-18 12:56:53.000000000 +0400 +++ patchutils_new/src/filterdiff.c 2008-06-19 15:35:00.000000000 +0400 @@ -77,6 +77,7 @@ } mode; static regex_t *regex = NULL; static size_t num_regex = 0; +static int clean_comments = 0; static int numbering = 0; static int annotating = 0; static int ignore_components = 0; @@ -902,8 +903,9 @@ } /* Show non-diff lines if excluding, or if - * in verbose mode. */ - if (mode == mode_filter && (pat_exclude || verbose)) + * in verbose mode, and if --clean isn't specified. */ + if (mode == mode_filter && (pat_exclude || verbose) + && !clean_comments) fputs (line, stdout); if (getline (&line, &linelen, f) == -1) @@ -920,8 +922,9 @@ if (getline (&line, &linelen, f) == -1) { /* Show non-diff lines if excluding, or if - * in verbose mode. */ - if (mode == mode_filter && (pat_exclude || verbose)) + * in verbose mode, and if --clean isn't specified. */ + if (mode == mode_filter && (pat_exclude || verbose) + && !clean_comments) fputs (header[0], stdout); free (names[0]); goto eof; @@ -930,8 +933,9 @@ if (strncmp (line, is_context ? "--- " : "+++ ", 4)) { /* Show non-diff lines if excluding, or if - * in verbose mode. */ - if (mode == mode_filter && (pat_exclude || verbose)) + * in verbose mode, and if --clean isn't specified. */ + if (mode == mode_filter && (pat_exclude || verbose) + && !clean_comments) fputs (header[0], stdout); free (names[0]); free (header[0]); @@ -1030,6 +1034,8 @@ " show matching hunks or file-level diffs (grepdiff)\n" " --remove-timestamps (filterdiff, grepdiff)\n" " don't show timestamps from output (filterdiff, grepdiff)\n" +" -c, --clean (filterdiff)\n" +" remove all comments (non-diff lines) from output (filterdiff)\n" " -z decompress .gz and .bz2 files\n" " -n show line numbers (lsdiff, grepdiff)\n" " --number-files (lsdiff, grepdiff)\n" @@ -1256,10 +1262,11 @@ {"no-filename", 0, 0, 'h'}, {"empty-files-as-absent", 0, 0, 'E'}, {"number-files", 0, 0, 1000 + 'n'}, + {"clean", 0, 0, 'c'}, {0, 0, 0, 0} }; char *end; - int c = getopt_long (argc, argv, "vp:i:I:x:X:zns#:Ef:Hh", + int c = getopt_long (argc, argv, "vp:i:I:x:X:zns#:Ef:Hhc", long_options, NULL); if (c == -1) break; @@ -1390,6 +1397,9 @@ case 1000 + 'r': removing_timestamp = 1; break; + case 'c': + clean_comments = 1; + break; default: syntax(1); } @@ -1420,6 +1430,11 @@ error (EXIT_FAILURE, 0, "--as-numbered-lines is " "inappropriate in this context"); + if (mode == mode_filter && + verbose && clean_comments) + error (EXIT_FAILURE, 0, "can't use --verbose and " + "--clean options simultaneously"); + if (mode == mode_grep && !regex_file_specified) { int err;