Re: BUG: git diff --name-only ignores --ignore-*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A quick peek suggests options to tackle this:

a) by including XDF_IGNORE_BLANK_LINES as an option that also forces a
content check
b) adjusting the implementation in diff_flush to better take into
account the specified --ignore-* flags

Now, looking closely at diff_flush it would seem as if all of the
command-line options
  --raw
  --name-only
  --name-status
might benefit from taking into account --ignore-*

So, in the end this is a matter intent and requirements - what should
happen whenever a user provided --ignore*?

>From my point of view, git diff --raw, --name-only, name-status all
should honour --ignore-whitespace*, and all should also honour
--ignore-blank-lines

Below please find a patch which shows the code areas affected;
implementation quality is not acceptable as-is (logic distributed
across the function), because I'd love to get some feedback on --raw
and --name-status and the general approach.

*********************

diff --git a/diff.c b/diff.c
index a8113f1707..7b19cfa5f0 100644
--- a/diff.c
+++ b/diff.c
@@ -4645,11 +4645,13 @@ void diff_setup_done(struct diff_options *options)
/*
* Most of the time we can say "there are changes"
* only by checking if there are changed paths, but
- * --ignore-whitespace* options force us to look
- * inside contents.
+ * options
+ * --ignore-whitespace*
+ * --ignore-blank-lines
+ * force us to look inside contents.
*/
- if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||
+ if ((options->xdl_opts & (XDF_WHITESPACE_FLAGS | XDF_IGNORE_BLANK_LINES)) ||
options->ignore_regex_nr)
options->flags.diff_from_contents = 1;
else
@@ -6408,10 +6410,10 @@ void diff_flush(struct diff_options *options)
if (!q->nr)
goto free_queue;
- if (output_format & (DIFF_FORMAT_RAW |
- DIFF_FORMAT_NAME |
+ if ((output_format & (DIFF_FORMAT_RAW |
DIFF_FORMAT_NAME_STATUS |
- DIFF_FORMAT_CHECKDIFF)) {
+ DIFF_FORMAT_CHECKDIFF)) ||
+ (output_format & DIFF_FORMAT_NAME && !options->flags.diff_from_contents)) {
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
if (check_pair_status(p))
@@ -6449,9 +6451,10 @@ void diff_flush(struct diff_options *options)
separator++;
}
- if (output_format & DIFF_FORMAT_NO_OUTPUT &&
+ if ((output_format & DIFF_FORMAT_NO_OUTPUT &&
options->flags.exit_with_status &&
- options->flags.diff_from_contents) {
+ options->flags.diff_from_contents)) ||
+ (output_format & DIFF_FORMAT_NAME && options->flags.diff_from_contents) {
/*
* run diff_flush_patch for the exit status. setting
* options->file to /dev/null should be safe, because we



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux