问题描述
我正在编写一个测试套件来运行要在一堆输入文件中进行测试的工具。对于每个输入文件,该工具正在创建相应的输出文件(均为XML格式)。输入和输出文件在Git仓库中签入。
输出文件包含编译工具的时间,因此输出文件在重新编译后肯定会被修改 - 由被测试的工具创建。
要快速浏览一下输出是否已经改变(当我修改工具的源代码时),我想检查一下是否节点 OutputFingerprint
的内容发生了变化(对输出文件的相关部分的内容进行简单散列)。
阅读,我发现有一个 -G
选项:
不幸的是,他们没有提供如何使用 -G
选项的示例。
我的第一个想法是简单地写
git diff -GOutputFingerprint
但那是错误的:
> git diff -GOutputFingerprint
error:invalid option:-GOutputFingerprint
接下来的想法是把正则表达式的斜杠,这也不成功:
> git diff -G / OutputFingerprint /
错误:无效选项:-GC:/ Program Files / Git / OutputFingerprint /
另外,简单地在 -G
和 OutputFingerprint
之间放置空格不起作用:
> git diff -G OutputFingerprint
致命的:模棱两可的参数'OutputFingerprint':未知版本或路径不在工作树中。
使用' - '将路径与修订分开
当我调用<$ c $
- < OutputFingerprint> e45807ca76fc5bb78e9e928c6fb7eed6< c> git diff
没有任何params,我得到了修改: ; / OutputFingerprint>
+< OutputFingerprint> d0846851bc9d52b37f7919def78660a2< / OutputFingerprint>
另一个想法是使用 git diff -S。* OutputFingerprint。* --pickaxe-regex
,但这也不成功。
git --version
给我 git版本1.7.3.1.msysgit.0
,如果这是相关的。
当我询问 git diff --help
时,所提供的手册显示 - G
选项。
那么,有谁能提供一个例子来说明如何使用 git diff -G
正确?
git diff -Garegex
在msysgit 1.7.4下运行正常,但仅在bash会话中(在DOS会话中,它不返回任何内容)
它将显示 报告它的工作原理(仅限于msysgit1.7.4 +),并补充说: 示例:I添加一个新行'aaa'(不含 I'm writing a little test suite that runs the tool to be tested over a bunch of input files. For each input file, a corresponding output file is being created by the tool (both are in XML). Input and output files are checked in on a Git repo. The output files carry the time when the tool was compiled, so the output files are surely modified after they were re-created by the tool being tested. To have a quick glimpse if the output has changed (when I modified the sources of the tool), I'd like to check whether the content of the node Reading the manual for Unfortunately, they provide no example for how to use the My first thought was to simply write but that's wrong: Next thought was to put the regex in slashes, which is also not successful: Also, simply putting a space between When I call Another thought was to use When I ask So, could anyone provide me an example for how to use runs fine with msysgit 1.7.4, but only in a bash session (in a DOS session, it returns nothing) It will display the The OP eckes reports it works (with msysgit1.7.4+ only), adding that the Example: I add a new line 'aaa' (without 这篇关于我如何使用git diff -G?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! diff
,如果正则表达式匹配已添加的 或删除的行版本。
已添加或已删除:未更改。
含义在您的案例中, -G
选项包括:
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-sdsfwkOwner=for ...
+ aaa
OutputFingerprint
has changed (simple hash over the contents of the relevant parts of the output file).git-diff
, I found that there's a -G
option:-G
option. git diff -GOutputFingerprint
> git diff -GOutputFingerprint
error: invalid option: -GOutputFingerprint
> git diff -G/OutputFingerprint/
error: invalid option: -GC:/Program Files/Git/OutputFingerprint/
-G
and OutputFingerprint
doesn't work:> git diff -G OutputFingerprint
fatal: ambiguous argument 'OutputFingerprint': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
git diff
without any params, I get the modification:- <OutputFingerprint>e45807ca76fc5bb78e9e928c6fb7eed6</OutputFingerprint>
+ <OutputFingerprint>d0846851bc9d52b37f7919def78660a2</OutputFingerprint>
git diff -S".*OutputFingerprint.*" --pickaxe-regex
, but this is also not successful.git --version
gives me git version 1.7.3.1.msysgit.0
if that is relevant. git diff --help
, the provided manual shows me the -G
option.git diff -G
correctly? git diff -Garegex
diff
if the regex matches a line added or removed from the staged version.
added or removed: not changed.
Meaning in your case, diff
man page for -G
option includes:git add
: just a simple edit)$ 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