eck*_*kes 5 git git-diff msysgit
我正在编写一个小测试套件来运行要在一堆输入文件上进行测试的工具.对于每个输入文件,该工具正在创建相应的输出文件(两者都是XML格式).输入和输出文件在Git仓库中签入.
输出文件带有编译工具的时间,因此输出文件在被测试工具重新创建后肯定会被修改.
如果输出已经改变(当我修改工具的源代码时)快速一瞥,我想检查节点的内容是否OutputFingerprint已经改变(对输出文件的相关部分的内容进行简单的哈希) .
阅读手册git-diff,我发现有一个-G选项:
-G <regex>
查找添加或删除的行与给定<regex>匹配的差异.
不幸的是,它们没有提供如何使用该-G选项的示例.
我的第一个想法是简单地写
git diff -GOutputFingerprint
Run Code Online (Sandbox Code Playgroud)
但那是错的:
> git diff -GOutputFingerprint
error: invalid option: -GOutputFingerprint
Run Code Online (Sandbox Code Playgroud)
接下来的想法是将正则表达式放入斜杠,这也是不成功的:
> git diff -G/OutputFingerprint/
error: invalid option: -GC:/Program Files/Git/OutputFingerprint/
Run Code Online (Sandbox Code Playgroud)
此外,只是在两者之间放置一个空格-G并且OutputFingerprint不起作用:
> git diff -G OutputFingerprint
fatal: ambiguous argument 'OutputFingerprint': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Run Code Online (Sandbox Code Playgroud)
当我打电话git diff没有任何参数时,我得到修改:
- <OutputFingerprint>e45807ca76fc5bb78e9e928c6fb7eed6</OutputFingerprint>
+ <OutputFingerprint>d0846851bc9d52b37f7919def78660a2</OutputFingerprint>
Run Code Online (Sandbox Code Playgroud)
另一种想法是使用git diff -S".*OutputFingerprint.*" --pickaxe-regex,但这也不成功.
git --versiongit version 1.7.3.1.msysgit.0如果这是相关的,我会告诉我.
当我问git diff --help,提供的手册向我显示了-G选项.
那么,有人能为我提供一个如何git diff -G正确使用的例子吗?
git diff -Garegex
Run Code Online (Sandbox Code Playgroud)
使用msysgit 1.7.4运行正常,但仅在bash会话中(在DOS会话中,它不返回任何内容)
它将显示diff正则表达式是否匹配从分阶段版本添加或删除的行.
添加或删除:未更改.
你的意思是,它不会起作用
该OP eckes报告它的工作原理(与msysgit1.7.4 +只),并补充说,diff手册页的-G选项包括:
"查找添加或删除的行与给定正则表达式匹配的
差异",这与diff输出相关,其中更改的行打印为一个添加的行和一个删除的行.
示例:我添加了一个新行'aaa'(没有git add:只是一个简单的编辑)
$ git diff -Gaaa
diff --git a/conf/fragments/xxx_repos.conf b/conf/fragments/xxx_repos.coindex 263fa85..3475f9b 100644
--- a/conf/fragments/xxx_repos.conf
+++ b/conf/fragments/xxx_repos.conf
@@ -10,3 +10,4 @@ repo xxx-sdsfwk
RW+ = vonc user1 user2
RW = @xxx_users
xxx-sdsfwk "Owner" = "for..."
+aaa
Run Code Online (Sandbox Code Playgroud)