{"thread":{"id":"56382","subject":"Re: BUG: git diff --name-only ignores --ignore-*","startedAt":"2021-08-26T09:05:50Z","lastAt":"2021-08-26T09:05:50Z","messageCount":1,"participants":["Stefan Hoffmeister"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"433816","messageId":"CALhB_QN1k6=j8KQZcP6W3doiQ3BWZYFAKw9fRhVLz2ZRz9gm4g@mail.gmail.com","threadId":"56382","inReplyTo":null,"subject":"Re: BUG: git diff --name-only ignores --ignore-*","fromName":"Stefan Hoffmeister","fromEmail":"stefan.hoffmeister@econos.de","sentAt":"2021-08-26T09:05:30Z","receivedAt":"2021-08-26T09:05:50Z","isPatch":false,"sender":{"key":"stefan.hoffmeister@econos.de","avatar":null},"body":"A quick peek suggests options to tackle this:\n\na) by including XDF_IGNORE_BLANK_LINES as an option that also forces a\ncontent check\nb) adjusting the implementation in diff_flush to better take into\naccount the specified --ignore-* flags\n\nNow, looking closely at diff_flush it would seem as if all of the\ncommand-line options\n  --raw\n  --name-only\n  --name-status\nmight benefit from taking into account --ignore-*\n\nSo, in the end this is a matter intent and requirements - what should\nhappen whenever a user provided --ignore*?\n\nFrom my point of view, git diff --raw, --name-only, name-status all\nshould honour --ignore-whitespace*, and all should also honour\n--ignore-blank-lines\n\nBelow please find a patch which shows the code areas affected;\nimplementation quality is not acceptable as-is (logic distributed\nacross the function), because I'd love to get some feedback on --raw\nand --name-status and the general approach.\n\n*********************\n\ndiff --git a/diff.c b/diff.c\nindex a8113f1707..7b19cfa5f0 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -4645,11 +4645,13 @@ void diff_setup_done(struct diff_options *options)\n/*\n* Most of the time we can say \"there are changes\"\n* only by checking if there are changed paths, but\n- * --ignore-whitespace* options force us to look\n- * inside contents.\n+ * options\n+ * --ignore-whitespace*\n+ * --ignore-blank-lines\n+ * force us to look inside contents.\n*/\n- if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||\n+ if ((options->xdl_opts & (XDF_WHITESPACE_FLAGS | XDF_IGNORE_BLANK_LINES)) ||\noptions->ignore_regex_nr)\noptions->flags.diff_from_contents = 1;\nelse\n@@ -6408,10 +6410,10 @@ void diff_flush(struct diff_options *options)\nif (!q->nr)\ngoto free_queue;\n- if (output_format & (DIFF_FORMAT_RAW |\n- DIFF_FORMAT_NAME |\n+ if ((output_format & (DIFF_FORMAT_RAW |\nDIFF_FORMAT_NAME_STATUS |\n- DIFF_FORMAT_CHECKDIFF)) {\n+ DIFF_FORMAT_CHECKDIFF)) ||\n+ (output_format & DIFF_FORMAT_NAME && !options->flags.diff_from_contents)) {\nfor (i = 0; i < q->nr; i++) {\nstruct diff_filepair *p = q->queue[i];\nif (check_pair_status(p))\n@@ -6449,9 +6451,10 @@ void diff_flush(struct diff_options *options)\nseparator++;\n}\n- if (output_format & DIFF_FORMAT_NO_OUTPUT &&\n+ if ((output_format & DIFF_FORMAT_NO_OUTPUT &&\noptions->flags.exit_with_status &&\n- options->flags.diff_from_contents) {\n+ options->flags.diff_from_contents)) ||\n+ (output_format & DIFF_FORMAT_NAME && options->flags.diff_from_contents) {\n/*\n* run diff_flush_patch for the exit status. setting\n* options->file to /dev/null should be safe, because we\n"}]}