Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No match for regexp /diff --git (a\/.*) (b\/.*)\n/ #164

Closed
nWidart opened this issue Jul 28, 2016 · 13 comments
Closed

No match for regexp /diff --git (a\/.*) (b\/.*)\n/ #164

nWidart opened this issue Jul 28, 2016 · 13 comments
Labels

Comments

@nWidart
Copy link

nWidart commented Jul 28, 2016

Q A
Branch 0.9.1
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets

Hi,

I installed GrumPHP with one task, php-cs-fixer, and when commiting a file, it shows the following error.

screen shot 2016-07-28 at 16 03 50

However when I run php ./vendor/bin/grumphp run it works as expected.

My configuration

parameters:
    git_dir: .
    bin_dir: vendor/bin
    tasks:
      phpcsfixer:
        config_file: .php_cs
  • Run GrumpHP:
  • git add .
  • git commit composer.json "Test"

Result:

[Gitonomy\Git\Exception\RuntimeException]                                                    
  No match for regexp /diff --git (a\/.*) (b\/.*)\n/ Upcoming: diff --git c/composer.json i/c 
@veewee veewee added the bug label Jul 28, 2016
@Kanti
Copy link
Contributor

Kanti commented Jul 28, 2016

Maybe your git color.ui config is set to always?

Use color.ui true and it should work.

@nWidart
Copy link
Author

nWidart commented Jul 28, 2016

I have/had this in my gitconfig file:

[color]
     ui = true

@Kanti
Copy link
Contributor

Kanti commented Jul 28, 2016

this is more a gitonomy/gitlib problem.
https://github.com/gitonomy/gitlib/issues
Maybe they over there could help out.

@veewee
Copy link
Contributor

veewee commented Jul 29, 2016

I've tried the steps you've described but I am able to commit.
Can you paste your git diff in this issue?

git diff -r -p -m -M --full-index --staged | cat

Did you overwrite the basic git diff command or added a custom diff pager? (For example diff-so-fancy)

@nWidart
Copy link
Author

nWidart commented Jul 29, 2016

The output is the following:

diff --git c/composer.json i/composer.json
index 2d1cef9d4a4dec5d3f18c7f87eb89eb2559202b2..7814c002ac39b65249575ef200225e65dc44f7b1 100644
--- c/composer.json
+++ i/composer.json
@@ -29,7 +29,9 @@
     "mockery/mockery": "~0.9",
     "orchestra/testbench": "^3.1|^3.2",
     "satooshi/php-coveralls": "~1.0",
-    "phpunit/phpcov": "2.*"
+    "phpunit/phpcov": "2.*",
+    "phpro/grumphp": "^0.9.1",
+    "friendsofphp/php-cs-fixer": "^1.11"
   },
   "autoload": {
     "psr-4": {
diff --git c/grumphp.yml i/grumphp.yml
new file mode 100644
index 0000000000000000000000000000000000000000..a68a3a9d8c2b4612420bee3a8d382a3bf16f9536
--- /dev/null
+++ i/grumphp.yml
@@ -0,0 +1,6 @@
+parameters:
+    git_dir: .
+    bin_dir: vendor/bin
+    tasks:
+      phpcsfixer:
+        config_file: .php_cs

I do indeed have diff-so-fancy installed, could that be reason ?

@nWidart
Copy link
Author

nWidart commented Jul 29, 2016

In my .gitconfig file I commented out the pager option :

[core]
   autocrlf = input
   editor = vim
   excludesfile = ~/.yadr/git/gitignore
   # pager = diff-so-fancy | less --tabs=4 -RFX

But it's still showing the same error.

@veewee
Copy link
Contributor

veewee commented Jul 29, 2016

I also use diff-so-fancy, but only with the command:

git dsf

If you overwrite default diff behaviour, your diff can't probably be parsed correctly which results in this error.

Take a look at the message:

No match for regexp /diff --git (a\/.*) (b\/.*)\n/ Upcoming: diff --git c/composer.json i/c 

Your diffs looks like:

diff --git c/composer.json i/composer.json
index 2d1cef9d4a4dec5d3f18c7f87eb89eb2559202b2..7814c002ac39b65249575ef200225e65dc44f7b1 100644
--- c/composer.json
+++ i/composer.json

It should look like

diff --git a/file.json b/file.json

Instead it looks like this:

diff --git c/composer.json i/composer.json

This means that gitlib can't parse the diff. I would expect that diff-so-fancy is the cause of this problem.

@nWidart
Copy link
Author

nWidart commented Jul 29, 2016

Hm I see, that makes sense indeed.

How could I disable diff-so-fancy though, since I've already commented out the pager option.

When I try to source the .gitconfig file, I'm getting the following error

/Users/nicolaswidart/.gitconfig:3: no matches found: [color]

Which is odd since there I have:

[color]
   ui = true

Thanks!

@nWidart
Copy link
Author

nWidart commented Jul 29, 2016

I also removed diff-so-fancy that was installed with brew, using brew uninstall diff-so-fancy, but the error remains.

@veewee
Copy link
Contributor

veewee commented Jul 30, 2016

I've looked into diff-so-fancy and it doesn't seem to transform those a/ b/ things to i/ c/.
Can you tell me which version of git you've installed. Maybe this is a BC break in git or something?

@nWidart
Copy link
Author

nWidart commented Jul 30, 2016

Hello,

I'm using git version 2.9.0.

Thanks,

@veewee
Copy link
Contributor

veewee commented Jul 31, 2016

I've just took a look at the git source code and it looks like it is expecting it to be a/ and b/:
https://github.com/git/git/blob/master/t/t4000-diff-format.sh#L38

Not sure what is going wrong in your installation. Maybe you can try to reinstall git?

@nWidart
Copy link
Author

nWidart commented Jul 31, 2016

Hello,

Thanks to the help of @armababy it was a matter of setting the following:

git config --global diff.mnemonicprefix false

With this, it works..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants