Subject: Re: git diff --git-ignore

From: Junio C Hamano <[email-masked]>
Date: Sun, 19 Sep 2021 19:23:38 -0700

Aaron Gray <[email-masked]> writes:

> Is it possible to add a --git-ignore flag to git diff so I only see
> the diffs for what I really want to be looking at, and not what I
> don't ;)

How does your --git-ignore option exactly guess differences for
which paths to show and which paths to exclude?  How do you tell the
"git diff --git-ignore" command which paths are what you really want
to be looking at?

If it is by magic, good luck writing such a feature ;-)

If it is like "I only am interested in changes in src/ directory and
the top-level Makefile", then perhaps using pathspec is what you
want.  E.g.

    $ git diff -- src/ Makefile
    $ git diff --cached -- src/ Makefile
    $ git diff master topic -- src/ Makefile
    $ git diff master...topic -- src/ Makefile

Modern Git even allows you to include negative elements to the
pathspec, e.g.

    $ git diff src/ ':(exclude)*.h'

would tell us "show only changes in the src/ directory, but do not
bother with changes to the dot-h files".

HTH