{"thread":{"id":"56381","subject":"BUG: git diff --name-only ignores --ignore-*","startedAt":"2021-08-26T06:53:56Z","lastAt":"2021-08-26T18:42:37Z","messageCount":2,"participants":["Stefan Hoffmeister","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"433811","messageId":"CALhB_QNZJtUoSEE==xBoX3cTxE4duB+QqsSzuyeY7JFMh7sKhQ@mail.gmail.com","threadId":"56381","inReplyTo":null,"subject":"BUG: git diff --name-only ignores --ignore-*","fromName":"Stefan Hoffmeister","fromEmail":"stefan.hoffmeister@gmail.com","sentAt":"2021-08-26T06:53:31Z","receivedAt":"2021-08-26T06:53:56Z","isPatch":false,"sender":{"key":"stefan.hoffmeister@gmail.com","avatar":null},"body":"When using the --name-only option on git diff (git 2.33.0),\ncommand-line parameters such as  --ignore-blank-lines are not\nrespected.\n\nInstead, git diff behaves as if these options were not specified at all.\n\nThis is either an implementation defect, or a documentation defect,\nbecause that (IMHO surprising) behaviour is not spelled out in\nhttps://git-scm.com/docs/git-diff.\n\nIMHO, this is an implementation defect, as --ignore-* is orthogonal to\n--name-only. I would like to use --name-only to identify the set of\nfiles which have only(!) --ignore-* changes (by intersecting the set\nof files returned by git diff with, and without --ignore-*).\n\nThe bash script below reproduces this for --ignore-blank-lines; the\nsame would extend to the other --ignore-* options as well.\n\n****************************\n#!/usr/bin/env bash\n\nset -e\n\nGIT_REPO=repo\nTEST_FILE=the_file.txt\n\nrm -rf ./${GIT_REPO}\nmkdir ${GIT_REPO}\npushd ${GIT_REPO}\n\ngit init --initial-branch=main\ngit config user.name \"myuser\"\ngit config user.email \"myuser@example.com\"\n\ncat << EOF > ${TEST_FILE}\nHello world.\nEOF\n\ngit add -A\ngit commit -m\"Initial commit\"\n\n# add empty lines\ncat << EOF >> ${TEST_FILE}\n\n\nEOF\n\nwithout_name_only=$(git diff --ignore-blank-lines)\necho \"----\nWithout --name-only:\n${without_name_only}\"\n\nwith_name_only=$(git diff --ignore-blank-lines --name-only)\necho \"----\nWith --name-only:\n${with_name_only}\"\n\nif [[ ${without_name_only} != ${with_name_only} ]] ; then\n    echo \"\nfail: expected same data returned\n\"\n    exit 1\nelse\n    echo \"\npass: all good\n\"\n    exit 0\nfi\n"},{"id":"433858","messageId":"xmqqwno8dp4b.fsf@gitster.g","threadId":"56381","inReplyTo":"CALhB_QNZJtUoSEE==xBoX3cTxE4duB+QqsSzuyeY7JFMh7sKhQ@mail.gmail.com","subject":"Re: BUG: git diff --name-only ignores --ignore-*","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-08-26T18:42:28Z","receivedAt":"2021-08-26T18:42:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Hoffmeister <stefan.hoffmeister@gmail.com> writes:\n\n> When using the --name-only option on git diff (git 2.33.0),\n> command-line parameters such as  --ignore-blank-lines are not\n> respected.\n\nI think I've seen something related this one at around\n\n  https://lore.kernel.org/git/xmqq4kkl1atq.fsf@gitster.c.googlers.com/\n\n(look for mention of --name-only in the message).\n\nIt would make things more expensive to make --name-only inspect\nchanges when these options are in effect (iow, the --name-only\ncurrently is about \"are these the same blob object?  if not, show\nthe path\" and nothing else) but it would probably be OK, as the user\nexpresses their willingness to spend extra cycles by explicitly\ngiving --ignore-* options.\n\n"}]}