How to use git diff -G?

I am writing a small test suite that runs a testing tool through a bunch of input files. For each input file, the tool is created by the corresponding output file (both are in XML). Input and output files are checked on the Git repository.

The output files bear the time that the tool was compiled, so the output files were undoubtedly modified after they were recreated by the tool under test.

To quickly see if the result has changed (when I changed the sources of the tool), I would like to check if the contents of the node OutputFingerprint (a simple hash over the contents of the corresponding parts of the output file).

Reading the manual for git-diff , I found that the -G option exists:

-G <regular expression>
Find the differences whose added or deleted row matches the given <regex>.

Unfortunately, they do not contain examples of using the -G option.

My first thought was to just write

 git diff -GOutputFingerprint 

but this is wrong:

 > git diff -GOutputFingerprint error: invalid option: -GOutputFingerprint 

The next thought was to put the regular expression in slashes, which also failed:

 > git diff -G/OutputFingerprint/ error: invalid option: -GC:/Program Files/Git/OutputFingerprint/ 

In addition, simply placing a space between -G and OutputFingerprint does not work:

 > git diff -G OutputFingerprint fatal: ambiguous argument 'OutputFingerprint': unknown revision or path not in the working tree. Use '--' to separate paths from revisions 

When I call git diff without any parameters, I get a modification:

 - <OutputFingerprint>e45807ca76fc5bb78e9e928c6fb7eed6</OutputFingerprint> + <OutputFingerprint>d0846851bc9d52b37f7919def78660a2</OutputFingerprint> 

Another thought was to use git diff -S".*OutputFingerprint.*" --pickaxe-regex , but that also failed.

git --version gives me git version 1.7.3.1.msysgit.0 , if that matters.

When I ask git diff --help , the provided manual shows me the -G option.

So, can someone provide me an example of how to use git diff -G correctly?

+5
source share
1 answer
 git diff -Garegex 

works fine with msysgit 1.7.4, but only in a bash session (in a DOS session, it returns nothing)

It will display diff if the regular expression matches a string added or removed from the phased version.
added or deleted: not changed .
Value in your case will not work

The OP eckes report works (only with msysgit1.7.4 +), adding that diff for the -G option includes:

"Look for differences whose added or deleted line matches the given regular expression",
which refers to the output of diff , where the modified line is printed as one added and one deleted line .


Example: I add a new line 'aaa' (without git add : simple editing)

 $ 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 
+5
source

All Articles