Why not the magic of pathspec: (exclude) excluding specified files from git log output?

This is a continuation of Ignore files in git log -p and is also associated with Making 'git log "to ignore changes for specific paths .

I am using git 1.9.2. I am trying to use the magic of pathspec :(exclude) to indicate that some fragments should not be displayed on the output of git log -p . However, the fixes I want to exclude are still showing up on the output.

Here is a minimal working example that reproduces the situation:

 $ cd ~/Desktop $ mkdir test_exclude $ cd test_exclude $ git init $ mkdir testdir $ printf "my first cpp file\n" > testdir/test1.cpp $ printf "my first xml file\n" > testdir/test2.xml $ git add testdir/ $ git commit -m "added two test files" 

Now I want to show that all patches in my history expect those that match the XML files in the testdir folder. Therefore, following the VonC answer , I run

 $ git log --patch -- . ":(exclude)testdir/*.xml" 

but the patch for my testdir/test2.xml file is still showing in the output:

 commit 37767da1ad4ad5a5c902dfa0c9b95351e8a3b0d9 Author: xxxxxxxxxxxxxxxxxxxxxxxxx Date: Mon Aug 18 12:23:56 2014 +0100 added two test files diff --git a/testdir/test1.cpp b/testdir/test1.cpp new file mode 100644 index 0000000..3a721aa --- /dev/null +++ b/testdir/test1.cpp @@ -0,0 +1 @@ +my first cpp file diff --git a/testdir/test2.xml b/testdir/test2.xml new file mode 100644 index 0000000..8b7ce86 --- /dev/null +++ b/testdir/test2.xml @@ -0,0 +1 @@ +my first xml file 

What am I doing wrong? What should I do to tell git log -p not to show the patch associated with all XML files in my testdir folder?

+7
git git-log
source share
1 answer

Nevermind The problem is apparently fixed in Git 1.9.5 (more specifically, in commit ed22b4173bd8d6dbce6236480bd30a63dd54834e ). The toy example in my question above works as expected in Git 2.2.1:

 $ git --version git version 2.2.1 $ mkdir test_exclude $ cd test_exclude/ $ git init Initialized empty Git repository in /Users/jubobs/Desktop/test_exclude/.git/ $ mkdir testdir $ printf "my first cpp file\n" > testdir/test1.cpp $ printf "my first xml file\n" > testdir/test2.xml $ git add testdir/ $ git commit -m "added two test files" [master (root-commit) 5429d04] added two test files 2 files changed, 2 insertions(+) create mode 100644 testdir/test1.cpp create mode 100644 testdir/test2.xml $ git log --patch -- . ":(exclude)testdir/*.xml" commit 5429d047f140f96c5d6167d083fc1a5eab05fb19 Author: xxxxxxxxxxxxxxxxxxxxxxxxx Date: Fri Dec 26 23:40:18 2014 +0100 added two test files diff --git a/testdir/test1.cpp b/testdir/test1.cpp new file mode 100644 index 0000000..3a721aa --- /dev/null +++ b/testdir/test1.cpp @@ -0,0 +1 @@ +my first cpp file 

As you can see, the output of this git log command does not mention test2.xml .

+4
source share

All Articles