larsxschneider / ShowInGitHub

Xcode plugin to open the GitHub page of the commit of the currently selected line in the editor window.
BSD 2-Clause "Simplified" License
239 stars 36 forks source link

Unable to find filename with git blame error #14

Closed dcaunt closed 10 years ago

dcaunt commented 10 years ago

I'm seeing the error Unable to find filename with git blame when trying to Open either a commit or file on GitHub. I tried for a couple of projects, one on a corporate GitHub and one on github.com.

In the system console, I can see logs showing my GIT remotes (shows remotes correctly) and GIT blame (blank). Xcode's blame and comparison source control features are working fine.

larsxschneider commented 10 years ago

Can you post a redacted version of your remotes and the output of git status? Thanks!

dcaunt commented 10 years ago

Below is my setup for Mantle, as this is public:

$ git remote -v origin https://github.com/MantleFramework/Mantle.git (fetch) origin https://github.com/MantleFramework/Mantle.git (push)

$ git status On branch master Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

Console output from Xcode:

15/04/2014 14:34:32.348 Xcode[4464]: GIT remotes: ( "origin\thttps://github.com/MantleFramework/Mantle.git (fetch)", "origin\thttps://github.com/MantleFramework/Mantle.git (push)", "" ) 15/04/2014 14:34:32.450 Xcode[4464]: GIT blame:

larsxschneider commented 10 years ago

I wasn't able to reproduce the error.

Can you go to your Mantle directory and run the following on the command?

git --no-pager blame -L11,11 -l -s -n -f -p /[YOUR-PATH]/Mantle/Mantle/Mantle.h

What is the output? Is your Git located at /usr/bin/git? What is your Git/Xcode/OSX version?

Thanks!

dcaunt commented 10 years ago

My git is a symlink to Homebrew's git:

/usr/local/bin/git -> ../Cellar/git/1.9.1/bin/git

Git version is 1.9.1:

$ git --version git version 1.9.1

Xcode Version 5.1.1 (5B1008). OS X Mavericks 10.9.2 Build 13C64

blame output:

$ git --no-pager blame -L11,11 -l -s -n -f -p ~/Projects/Mantle/Mantle/Mantle.h f175aa35efa9c0da42b724039f6140a6c6690726 9 11 1 author Justin Spahr-Summers author-mail redacted author-time 1357512637 author-tz -0800 committer Justin Spahr-Summers committer-mail redacted committer-time 1357512637 committer-tz -0800 summary Use framework-style imports in Mantle.h previous aedc4242930b69f174d5b40ece7083ece7bb2ad5 Mantle/Mantle.h filename Mantle/Mantle.h

import <Mantle/MTLModel.h>

larsxschneider commented 10 years ago

I tried a number of things but I was not able to reproduce the error. However, I made a change to capture git errors a little better. Can you checkout the new error-report branch and compile/run this branch on your local machine? Then we should know what goes wrong on your end.

https://github.com/larsxschneider/ShowInGitHub/tree/error-report

dcaunt commented 10 years ago

Thanks, this is interesting:

Call: git --no-pager blame -L0,0 -l -s --show-number --show-name --porcelain >/Users/dcaunt/Projects/ShowInGitHub/Source/Classes/SIGPlugin.m

Output:

Version: git version 1.7.10.2 (Apple Git-33)

xcrun shows a different version again:

$ xcrun git --version git version 1.8.5.2 (Apple Git-48)

Looks like there is definitely a problem in my setup.

dcaunt commented 10 years ago

So I took a look at the plugin source and you're calling /usr/bin/git which is quite outdated. My git config contains a value which isn't valid in Git 1.7 (push.default = simple) and this causes the command to error. By changing my config, the plugin works as expected.

Perhaps the plugin would be more stable if it used xcrun git to run the git binary included in Xcode's app bundle rather than relying on the system git.

larsxschneider commented 10 years ago

Thanks for the xcrun hint! I didn't know about this one. I will test the new version tomorrow and merge afterwards.