为什么不是pathspec magic:(排除)从git log的输出中排除指定文件? [英] Why isn't the pathspec magic :(exclude) excluding the specified files from git log's output?
问题描述
这是忽略git log -p中的文件并且也与使'git log'忽略某些路径的更改。
我使用的是Git 1.9.2。我试图使用pathspec magic :( :(排除)
来指定一些补丁不应该显示在的输出中git log -p
。然而,我想排除的补丁仍然显示在输出中。
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 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 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"
但是我的 testdir / test2.xml
文件仍显示在输出中:
$ b
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
我是什么做错了?我应该做些什么来告诉 git log -p
不要在我的 testdir
文件夹中显示与所有XML文件相关的补丁?
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?
推荐答案
Nevermind。这个问题似乎已在Git 1.9.5中得到解决(更具体地说,在提交 ed22b4173bd8d6dbce6236480bd30a63dd54834e
)。上面我的问题中的玩具示例在Git 2.2.1中按预期工作:
Nevermind. The problem appears to have been 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
正如您所见,没有提及 test2.xml
in根据需要输出 git log
命令。
As you can see, there is no mention of test2.xml
in the output of that git log
command, as desired.
这篇关于为什么不是pathspec magic:(排除)从git log的输出中排除指定文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!