git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
SHStefan Hoffmeister <stefan.hoffmeister@gmail.com>
Date
Aug 26, 2021, 06:53 UTC
Message-ID
<CALhB_QNZJtUoSEE==xBoX3cTxE4duB+QqsSzuyeY7JFMh7sKhQ@mail.gmail.com>

When using the --name-only option on git diff (git 2.33.0), command-line parameters such as --ignore-blank-lines are not respected.

Instead, git diff behaves as if these options were not specified at all.

This is either an implementation defect, or a documentation defect, because that (IMHO surprising) behaviour is not spelled out in https://git-scm.com/docs/git-diff.

IMHO, this is an implementation defect, as --ignore-* is orthogonal to --name-only. I would like to use --name-only to identify the set of files which have only(!) --ignore-* changes (by intersecting the set of files returned by git diff with, and without --ignore-*).

The bash script below reproduces this for --ignore-blank-lines; the same would extend to the other --ignore-* options as well.

**************************** #!/usr/bin/env bash

set -e

GIT_REPO=repo TEST_FILE=the_file.txt

rm -rf ./${GIT_REPO} mkdir ${GIT_REPO} pushd ${GIT_REPO}

git init --initial-branch=main git config user.name "myuser" git config user.email "myuser@example.com"

cat << EOF > ${TEST_FILE} Hello world. EOF

git add -A git commit -m"Initial commit"

# add empty lines cat << EOF >> ${TEST_FILE}

EOF

without_name_only=$(git diff --ignore-blank-lines) echo "---- Without --name-only: ${without_name_only}"

with_name_only=$(git diff --ignore-blank-lines --name-only) echo "---- With --name-only: ${with_name_only}"

if [[ ${without_name_only} != ${with_name_only} ]] ; then
    echo "
fail: expected same data returned
"
    exit 1
else
    echo "
pass: all good
"
    exit 0
fi
Next: Junio C Hamano
Message 1 of 2 in “BUG: git diff --name-only ignores --ignore-*”
  1. Stefan HoffmeisterAug 26, 2021
  2. Junio C HamanoAug 26, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.