Why isn't the pathspec magic :(exclude) excluding the files I specify from git log's output?

Posted by Jubobs on Stack Overflow See other posts from Stack Overflow or by Jubobs
Published on 2014-08-18T11:56:16Z Indexed on 2014/08/19 16:20 UTC
Read the original article Hit count: 154

Filed under:
|

This is a follow-up to Ignore files in git log -p and is also related to Making 'git log' ignore changes for certain paths.

I'm using Git 1.9.2. I'm trying to use the pathspec magic :(exclude) to specify that some patches should not be shown in the output of git log -p. However, patches that I want to exclude still show up in the output.

Here is minimal working example that reproduces the situation:

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

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

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

but the patch for my testdir/test2.xml file still shows up 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?

© Stack Overflow or respective owner

Related posts about git

Related posts about git-log